SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SeCtx.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 ****************************************************************************
10 * HEADER
11 *
12 * $Id: SeCtx.h 6825 2026-11-10 21:17:44Z wini $
13 *
14 * COPYRIGHT: Real Time Logic LLC, 2014 - 2026
15 *
16 * This software is copyrighted by and is the sole property of Real
17 * Time Logic LLC. All rights, title, ownership, or other interests in
18 * the software remain the property of Real Time Logic LLC. This
19 * software may only be used in accordance with the terms and
20 * conditions stipulated in the corresponding license agreement under
21 * which the software has been supplied. Any unauthorized use,
22 * duplication, transmission, distribution, or disclosure of this
23 * software is expressly forbidden.
24 *
25 * This Copyright notice may not be removed or modified without prior
26 * written consent of Real Time Logic LLC.
27 *
28 * Real Time Logic LLC. reserves the right to modify this software
29 * without notice.
30 *
31 * http://sharkssl.com
32 ****************************************************************************
33 *
34 */
35
36#define SE_CTX
37
38
59#include <setjmp.h>
60#include <TargConfig.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66struct SeCtx;
67
69typedef void (*SeCtxTask)(struct SeCtx* ctx);
70
74typedef struct SeCtx
75{
76 jmp_buf savedContext;
77#ifndef NDEBUG
78 U32 magic1;
79#endif
80 jmp_buf startContext;
81#ifndef NDEBUG
82 U32 magic2;
83#endif
86 void* stackBuf;
87#ifndef NDEBUG
89#endif
95#ifdef SECTX_EX
96 SECTX_EX;
97#endif
99
100#define SeCtx_setStackTop(o, stackMark) \
101 (*(stackMark)=1,(o)->stackTop=stackMark,setjmp((o)->startContext))
102
103#ifdef DYNAMIC_SE_CTX
109void SeCtx_destructor(SeCtx* o);
110#else
111
112
121void SeCtx_constructor(SeCtx* o, SeCtxTask t, void* buf, int bufLen);
127#define SeCtx_destructor(o)
128#endif
129
131
133
139void SeCtx_panic(SeCtx* o, U32 size);
140 /* end group SeCtx */
142
143#ifdef __cplusplus
144}
145#endif
void SeCtx_panic(SeCtx *o, U32 size)
Function you must implement.
#define SeCtx_destructor(o)
No operation for a context using a caller-supplied static stack buffer.
Definition: SeCtx.h:127
void SeCtx_constructor(SeCtx *o, SeCtxTask t, void *buf, int bufLen)
Create a Context Manager instance.
void(* SeCtxTask)(struct SeCtx *ctx)
The task/thread entry point.
Definition: SeCtx.h:69
struct SeCtx SeCtx
SeCtx structure: See Context Manager and Bare Metal Systems for details.
void SeCtx_save(SeCtx *o)
Suspend the active bare-metal socket context and save its stack.
void SeCtx_restore(SeCtx *o)
Restore a previously saved bare-metal socket context.
SeCtx structure: See Context Manager and Bare Metal Systems for details.
Definition: SeCtx.h:75
jmp_buf startContext
Definition: SeCtx.h:80
SeCtxTask task
Definition: SeCtx.h:84
U32 magic1
Definition: SeCtx.h:78
void * stackBuf
Definition: SeCtx.h:86
U32 timeout
Definition: SeCtx.h:90
U8 * currentStack
Definition: SeCtx.h:88
U32 magic2
Definition: SeCtx.h:82
U8 ready
Definition: SeCtx.h:94
U16 stackBufLen
Definition: SeCtx.h:92
U8 hasContext
Definition: SeCtx.h:93
U32 startTime
Definition: SeCtx.h:91
U8 * stackTop
Definition: SeCtx.h:85
jmp_buf savedContext
Definition: SeCtx.h:76