|
Serene Runtime 1.0.0
C runtime for the Serene programming language
|
x86-64 fabrication of a fresh fiber's saved context. More...
Go to the source code of this file.
Functions | |
| void | srn_fiber_ctx_make (srn_fiber_ctx_t *fiber_ctx, srn_fiber_stack_t stack, void(*fn)(void *), void *arg) |
Initialise a fresh fiber context so the first srn_fiber_swap into it begins executing fn(arg) on stack. | |
x86-64 fabrication of a fresh fiber's saved context.
Paired with switch_x86_64.S; both are selected by CPU family in meson.build.
Definition in file ctx_x86_64.c.
| void srn_fiber_ctx_make | ( | srn_fiber_ctx_t * | fiber_ctx, |
| srn_fiber_stack_t | stack, | ||
| void(* | fn )(void *), | ||
| void * | arg ) |
Initialise a fresh fiber context so the first srn_fiber_swap into it begins executing fn(arg) on stack.
fn is the fiber's entry: a void (*)(void *) that runs on the new stack and receives arg. It must NEVER return – there is no frame beneath it, so a return traps in the trampoline. Instead it transfers control away with srn_fiber_switch (to yield) or srn_fiber_switch_final (when finished), and as its first action it calls srn_fiber_on_entry(). Typical shape:
static void worker(void *arg) { srn_fiber_on_entry(&scheduler); // hand the switch to the sanitizer ... do the fiber's work using arg ... srn_fiber_switch_final(&scheduler); // finished, never returns }
Definition at line 29 of file ctx_x86_64.c.