1#ifndef COROUTINE_WIN32_CONTEXT_H
2#define COROUTINE_WIN32_CONTEXT_H 1
18#define COROUTINE __declspec(noreturn) void __fastcall
19#define COROUTINE_LIMITED_ADDRESS_SPACE
22enum {COROUTINE_REGISTERS = 4};
33 context->stack_pointer = NULL;
36static inline void coroutine_initialize(
38 coroutine_start start,
42 assert(start && stack && size >= 1024);
45 char * top = (
char*)stack + size;
46 context->stack_pointer = (
void**)((uintptr_t)top & ~0xF);
48 *--context->stack_pointer = (
void*)(uintptr_t)start;
51 *--context->stack_pointer = (
void*)0xFFFFFFFF;
52 *--context->stack_pointer = (
void*)top;
53 *--context->stack_pointer = (
void*)stack;
55 context->stack_pointer -= COROUTINE_REGISTERS;
56 memset(context->stack_pointer, 0,
sizeof(
void*) * COROUTINE_REGISTERS);