...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
struct stack_t { void * base; void * limit; }; struct fcontext_t { < platform specific > stack_t fc_stack; }; intptr_t jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp); void make_fcontext( fcontext_t * fc, void(* fn)(intptr_t) );
base
Pointer to the top of the stack.
limit
Pointer to the bottom of the stack.
fc_stack
Tracks the memory for the context's stack.
intptr_t jump_fcontext( fcontext_t
* ofc, fcontext_t
* nfc, intptr_t p, bool
preserve_fpu)
Stores the current context data (stack pointer, instruction pointer,
and CPU registers) to *ofc
and restores the context data
from *nfc
,
which implies jumping to *nfc
's execution context. The intptr_t
argument, p
, is passed
to the current context to be returned by the most recent call to jump_fcontext()
in the same thread. The last argument controls if fpu registers have
to be preserved.
The third pointer argument passed to the most recent call to jump_fcontext()
,
if any.
void make_fcontext( fcontext_t
* fc, void(*fn)(intptr_t))
A stack is applied to *fc
before make_fcontext()
is called.
Modifies *fc
in order to execute fn
when the context is activated next.