1#ifndef COROUTINE_X86_CONTEXT_H
2#define COROUTINE_X86_CONTEXT_H 1
18#define COROUTINE __attribute__((noreturn, fastcall)) void
19#define COROUTINE_LIMITED_ADDRESS_SPACE
21enum {COROUTINE_REGISTERS = 4};
32 context->stack_pointer = NULL;
35static inline void coroutine_initialize(
37 coroutine_start start,
41 assert(start && stack && size >= 1024);
44 char * top = (
char*)stack + size;
45 context->stack_pointer = (
void**)((uintptr_t)top & ~0xF);
47 *--context->stack_pointer = NULL;
48 *--context->stack_pointer = (
void*)(uintptr_t)start;
50 context->stack_pointer -= COROUTINE_REGISTERS;
51 memset(context->stack_pointer, 0,
sizeof(
void*) * COROUTINE_REGISTERS);
58 context->stack_pointer = NULL;