summaryrefslogtreecommitdiff
path: root/coroutine/win32/Context.h
diff options
context:
space:
mode:
Diffstat (limited to 'coroutine/win32/Context.h')
-rw-r--r--coroutine/win32/Context.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/coroutine/win32/Context.h b/coroutine/win32/Context.h
index 299515ed92..c1c8fbcd13 100644
--- a/coroutine/win32/Context.h
+++ b/coroutine/win32/Context.h
@@ -1,16 +1,22 @@
+#ifndef COROUTINE_WIN32_CONTEXT_H
+#define COROUTINE_WIN32_CONTEXT_H 1
+
/*
* This file is part of the "Coroutine" project and released under the MIT License.
*
* Created by Samuel Williams on 10/5/2018.
- * Copyright, 2018, by Samuel Williams. All rights reserved.
+ * Copyright, 2018, by Samuel Williams.
*/
#pragma once
#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#define COROUTINE __declspec(noreturn) void __fastcall
+#define COROUTINE_DECL void __fastcall
#define COROUTINE_LIMITED_ADDRESS_SPACE
/* This doesn't include thread information block */
@@ -19,6 +25,7 @@ enum {COROUTINE_REGISTERS = 4};
struct coroutine_context
{
void **stack_pointer;
+ void *argument;
};
typedef void(__fastcall * coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
@@ -39,7 +46,7 @@ static inline void coroutine_initialize(
char * top = (char*)stack + size;
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
/* Windows Thread Information Block */
*--context->stack_pointer = (void*)0xFFFFFFFF; /* fs:[0] */
@@ -55,3 +62,5 @@ struct coroutine_context * __fastcall coroutine_transfer(struct coroutine_contex
static inline void coroutine_destroy(struct coroutine_context * context)
{
}
+
+#endif /* COROUTINE_WIN32_CONTEXT_H */