1 #ifndef ZTH_CONTEXT_SJLJ_H
2 #define ZTH_CONTEXT_SJLJ_H
12 #ifndef ZTH_CONTEXT_CONTEXT_H
13 # error This file must be included by libzth/context/context.h.
23 class Context :
public impl::ContextArch<Context> {
26 typedef ContextArch<Context>
base;
34 # ifdef ZTH_OS_BAREMETAL
36 typedef jmp_buf jmp_buf_type;
37 # define zth_sjlj_setjmp(env) ::setjmp(env)
38 # define zth_sjlj_longjmp(env, val) ::longjmp(env, val)
40 typedef sigjmp_buf jmp_buf_type;
41 # define zth_sjlj_setjmp(env) ::sigsetjmp(env, Config::ContextSignals)
42 # define zth_sjlj_longjmp(env, val) ::siglongjmp(env, val)
ContextArch< Context > base
impl::ContextArch< Context > base
void context_switch(Context &to) noexcept
constexpr Context(ContextAttr const &attr) noexcept
static void * sp() noexcept
static void stack_push(void **&sp, void *p) noexcept
Push data into the stack.
void context_pop_regs() noexcept
Post-sjlj context restoring.
Stack const & stack() const noexcept
Return the stack address.
static void set_sp(jmp_buf &env, void **sp) noexcept
Set the stack pointer in a jmp_buf.
static void context_trampoline_from_jmp_buf()
Entry point to jump to from a (sig)jmp_buf.
void context_prepare_jmp(Impl &to, jmp_buf &env) noexcept
Pre-sjlj jump.
static void set_pc(jmp_buf &env, void *sp) noexcept
Set the program counter in a jmp_buf.
int create() noexcept
Create context.
ContextAttr & attr() noexcept
Return the context attributes, requested by the user.
Stack const & stackUsable() const noexcept
Return the start of the actual usable stack.
void context_push_regs() noexcept
Pre-sjlj context saving.
#define ZTH_CLASS_NEW_DELETE(T)
Define new/delete operators for a class, which are allocator-aware.
#define zth_sjlj_setjmp(env)
#define zth_sjlj_longjmp(env, val)
#define unlikely(expr)
Marks the given expression to likely be evaluated to true.