1#ifndef COROUTINE_WIN32_CONTEXT_H
2#define COROUTINE_WIN32_CONTEXT_H 1
18#define COROUTINE __declspec(noreturn) void __fastcall
19#define COROUTINE_DECL void __fastcall
20#define COROUTINE_LIMITED_ADDRESS_SPACE
23enum {COROUTINE_REGISTERS = 4};
34 context->stack_pointer = NULL;
37static inline void coroutine_initialize(
39 coroutine_start start,
43 assert(start && stack && size >= 1024);
46 char * top = (
char*)stack + size;
47 context->stack_pointer = (
void**)((uintptr_t)top & ~0xF);
49 *--context->stack_pointer = (
void*)(uintptr_t)start;
52 *--context->stack_pointer = (
void*)0xFFFFFFFF;
53 *--context->stack_pointer = (
void*)top;
54 *--context->stack_pointer = (
void*)stack;
56 context->stack_pointer -= COROUTINE_REGISTERS;
57 memset(context->stack_pointer, 0,
sizeof(
void*) * COROUTINE_REGISTERS);