summaryrefslogtreecommitdiff
path: root/coroutine/x86
diff options
context:
space:
mode:
Diffstat (limited to 'coroutine/x86')
-rw-r--r--coroutine/x86/Context.S7
-rw-r--r--coroutine/x86/Context.h8
2 files changed, 10 insertions, 5 deletions
diff --git a/coroutine/x86/Context.S b/coroutine/x86/Context.S
index 6983f21c3b..b04e71aa1c 100644
--- a/coroutine/x86/Context.S
+++ b/coroutine/x86/Context.S
@@ -6,12 +6,11 @@
##
#define TOKEN_PASTE(x,y) x##y
-#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
.text
-.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
-PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+.globl PREFIXED_SYMBOL(coroutine_transfer)
+PREFIXED_SYMBOL(coroutine_transfer):
# Save caller registers
pushl %ebp
@@ -37,6 +36,6 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
# Jump to the address on the stack
ret
-#if defined(__linux__) && defined(__ELF__)
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
diff --git a/coroutine/x86/Context.h b/coroutine/x86/Context.h
index dfdde24f5d..f33b338eab 100644
--- a/coroutine/x86/Context.h
+++ b/coroutine/x86/Context.h
@@ -1,3 +1,6 @@
+#ifndef COROUTINE_X86_CONTEXT_H
+#define COROUTINE_X86_CONTEXT_H 1
+
/*
* This file is part of the "Coroutine" project and released under the MIT License.
*
@@ -20,6 +23,7 @@ enum {COROUTINE_REGISTERS = 4};
struct coroutine_context
{
void **stack_pointer;
+ void *argument;
};
typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self) __attribute__((fastcall));
@@ -41,7 +45,7 @@ static inline void coroutine_initialize(
context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
*--context->stack_pointer = NULL;
- *--context->stack_pointer = (void*)start;
+ *--context->stack_pointer = (void*)(uintptr_t)start;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
@@ -53,3 +57,5 @@ static inline void coroutine_destroy(struct coroutine_context * context)
{
context->stack_pointer = NULL;
}
+
+#endif /* COROUTINE_X86_CONTEXT_H */