Zth (libzth)
Loading...
Searching...
No Matches
zth::Context Class Reference

#include <sigaltstack.h>

Inheritance diagram for zth::Context:
zth::impl::ContextArch< Context > zth::impl::ContextArch< Context > zth::impl::ContextArch< Context > zth::impl::ContextArch< Context > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl > zth::impl::ContextBase< Impl >

Public Types

typedef impl::ContextArch< Contextbase
 
typedef ContextArch< Contextbase
 
typedef impl::ContextArch< Contextbase
 
typedef impl::ContextArch< Contextbase
 
- Public Types inherited from zth::impl::ContextArch< Context >
typedef ContextBase< Contextbase
 
typedef ContextBase< Contextbase
 

Public Member Functions

constexpr Context (ContextAttr const &attr) noexcept
 
int create () noexcept
 
void context_switch (Context &to) noexcept
 
constexpr Context (ContextAttr const &attr) noexcept
 
int create () noexcept
 
void context_switch (Context &to) noexcept
 
constexpr Context (ContextAttr const &attr) noexcept
 
int create () noexcept
 
void context_switch (Context &to) noexcept
 
constexpr Context (ContextAttr const &attr) noexcept
 
int initStack (Stack &UNUSED_PAR(stack), Stack &UNUSED_PAR(usable)) noexcept
 
void deinitStack (Stack &UNUSED_PAR(stack)) noexcept
 
int stackGuardInit () noexcept
 
void stackGuardDeinit () noexcept
 
void valgrindRegister () noexcept
 
void valgrindDeregister () noexcept
 
int create () noexcept
 
void destroy () noexcept
 
void context_switch (Context &to) noexcept
 
- Public Member Functions inherited from zth::impl::ContextArch< Context >
size_t calcStackSize (size_t size) noexcept
 
void stackAlign (Stack &stack) noexcept
 
Contextimpl () noexcept
 Return Impl this.
 
Context const & impl () const noexcept
 Return Impl this.
 
- Public Member Functions inherited from zth::impl::ContextBase< Impl >
ContextAttrattr () noexcept
 Return the context attributes, requested by the user.
 
ContextAttr const & attr () const noexcept
 Return the context attributes, requested by the user.
 
int create () noexcept
 Create context.
 
void destroy () noexcept
 Destroy and cleanup context.
 
int initStack (Stack &stack, Stack &usable) noexcept
 Allocate and initialize stack.
 
void deinitStack (Stack &stack) noexcept
 Deinit and free stack.
 
Stack const & stack () const noexcept
 Return the stack address.
 
Stack const & stackUsable () const noexcept
 Return the start of the actual usable stack.
 
size_t calcStackSize (size_t size) noexcept
 Compute the stack size, given the requested user size and current configuration.
 
void * allocStack (size_t size) noexcept
 Allocate requested size of stack memory.
 
void deallocStack (Stack &stack) noexcept
 Frees the previously allocated stack.
 
void stackAlign (Stack &stack) noexcept
 Compute and modify the stack alignment and size, within the allocated space.
 
void valgrindRegister () noexcept
 Register the current stack to valgrind.
 
void valgrindDeregister () noexcept
 Deregister the current stack from valgrind.
 
int stackGuardInit () noexcept
 Initialize guards around the stack memory.
 
void stackGuardDeinit () noexcept
 Release the guards around the memory.
 
void stackGuard () noexcept
 Configure the guard for the current fiber.
 
void stackGuard (Stack const &stack) noexcept
 Configure the guard for the given stack.
 
void * stackGuard (void *p) noexcept
 Configure the guard for the address.
 
void context_switch (Context &to) noexcept
 Perform a context switch.
 
void context_push_regs () noexcept
 Pre-sjlj context saving.
 
void context_pop_regs () noexcept
 Post-sjlj context restoring.
 
void context_prepare_jmp (Impl &to, jmp_buf &env) noexcept
 Pre-sjlj jump.
 
void die () noexcept
 Flag fiber as died after it returned from context_entry().
 
bool alive () const noexcept
 Check if fiber is still running.
 
void * stack_switch (void *stack, size_t size, void *(*f)(void *) noexcept, void *arg) noexcept
 

Static Public Member Functions

static int init () noexcept
 
static void deinit () noexcept
 
static int init () noexcept
 
- Static Public Member Functions inherited from zth::impl::ContextArch< Context >
static size_t pageSize () noexcept
 
static void * sp () noexcept
 
- Static Public Member Functions inherited from zth::impl::ContextBase< Impl >
static int init () noexcept
 One-time system initialization.
 
static void deinit () noexcept
 Final system cleanup.
 
static size_t pageSize () noexcept
 Get system's page size.
 
static bool stackGrowsDown (void const *reference)
 Checks if the stack grows down or up.
 
static void ** sp (Stack const &stack) noexcept
 Get the initial stack pointer for the given stack.
 
static void stack_push (void **&sp, void *p) noexcept
 Push data into the stack.
 
static void set_sp (jmp_buf &env, void **sp) noexcept
 Set the stack pointer in a jmp_buf.
 
static void set_pc (jmp_buf &env, void *sp) noexcept
 Set the program counter in a jmp_buf.
 
static void context_trampoline_from_jmp_buf () noexcept
 Entry point to jump to from a (sig)jmp_buf.
 

Additional Inherited Members

- Protected Member Functions inherited from zth::impl::ContextArch< Context >
constexpr ContextArch (ContextAttr const &attr) noexcept
 
constexpr ContextArch (ContextAttr const &attr) noexcept
 
- Protected Member Functions inherited from zth::impl::ContextBase< Impl >
constexpr ContextBase (ContextAttr const &attr) noexcept
 
 ~ContextBase ()
 Dtor.
 
Impl & impl () noexcept
 Return Impl this.
 
Impl const & impl () const noexcept
 Return Impl this.
 

Detailed Description

Examples
measure.cpp.

Definition at line 57 of file sigaltstack.h.

Member Typedef Documentation

◆ base [1/4]

Definition at line 60 of file sigaltstack.h.

◆ base [2/4]

Definition at line 23 of file sjlj.h.

◆ base [3/4]

Definition at line 34 of file ucontext.h.

◆ base [4/4]

Definition at line 27 of file winfiber.h.

Constructor & Destructor Documentation

◆ Context() [1/4]

constexpr zth::Context::Context ( ContextAttr const &  attr)
inlineexplicitconstexprnoexcept

Definition at line 62 of file sigaltstack.h.

◆ Context() [2/4]

constexpr zth::Context::Context ( ContextAttr const &  attr)
inlineexplicitconstexprnoexcept

Definition at line 25 of file sjlj.h.

◆ Context() [3/4]

constexpr zth::Context::Context ( ContextAttr const &  attr)
inlineexplicitconstexprnoexcept

Definition at line 36 of file ucontext.h.

◆ Context() [4/4]

constexpr zth::Context::Context ( ContextAttr const &  attr)
inlineexplicitconstexprnoexcept

Definition at line 29 of file winfiber.h.

Member Function Documentation

◆ context_switch() [1/4]

void zth::Context::context_switch ( Context to)
inlinenoexcept

Definition at line 288 of file sigaltstack.h.

◆ context_switch() [2/4]

void zth::Context::context_switch ( Context to)
inlinenoexcept

Definition at line 63 of file sjlj.h.

◆ context_switch() [3/4]

void zth::Context::context_switch ( Context to)
inlinenoexcept

Definition at line 141 of file ucontext.h.

◆ context_switch() [4/4]

void zth::Context::context_switch ( Context to)
inlinenoexcept

Definition at line 108 of file winfiber.h.

◆ create() [1/4]

int zth::Context::create ( )
inlinenoexcept

Definition at line 148 of file sigaltstack.h.

◆ create() [2/4]

int zth::Context::create ( )
inlinenoexcept

Definition at line 44 of file sjlj.h.

◆ create() [3/4]

int zth::Context::create ( )
inlinenoexcept

Definition at line 89 of file ucontext.h.

◆ create() [4/4]

int zth::Context::create ( )
inlinenoexcept

Definition at line 69 of file winfiber.h.

◆ deinit()

static void zth::Context::deinit ( )
inlinestaticnoexcept

Definition at line 136 of file sigaltstack.h.

◆ deinitStack()

void zth::Context::deinitStack ( Stack UNUSED_PARstack)
inlinenoexcept

Definition at line 52 of file winfiber.h.

◆ destroy()

void zth::Context::destroy ( )
inlinenoexcept

Definition at line 94 of file winfiber.h.

◆ init() [1/2]

static int zth::Context::init ( )
inlinestaticnoexcept

Definition at line 116 of file sigaltstack.h.

◆ init() [2/2]

static int zth::Context::init ( )
inlinestaticnoexcept

Definition at line 34 of file winfiber.h.

◆ initStack()

int zth::Context::initStack ( Stack UNUSED_PARstack,
Stack UNUSED_PARusable 
)
inlinenoexcept

Definition at line 45 of file winfiber.h.

◆ stackGuardDeinit()

void zth::Context::stackGuardDeinit ( )
inlinenoexcept

Definition at line 60 of file winfiber.h.

◆ stackGuardInit()

int zth::Context::stackGuardInit ( )
inlinenoexcept

Definition at line 54 of file winfiber.h.

◆ valgrindDeregister()

void zth::Context::valgrindDeregister ( )
inlinenoexcept

Definition at line 67 of file winfiber.h.

◆ valgrindRegister()

void zth::Context::valgrindRegister ( )
inlinenoexcept

Definition at line 62 of file winfiber.h.

Member Data Documentation

◆ m_did_trampoline

sig_atomic_t volatile zth::Context::m_did_trampoline

Definition at line 303 of file sigaltstack.h.

◆ m_env

sigjmp_buf zth::Context::m_env

Definition at line 299 of file sigaltstack.h.

◆ m_parent

sigjmp_buf* volatile zth::Context::m_parent

Definition at line 304 of file sigaltstack.h.

◆ m_trampoline_env

jmp_buf zth::Context::m_trampoline_env

Definition at line 298 of file sigaltstack.h.


The documentation for this class was generated from the following files: