From 1cd97aef46e75c9b47df834bdd360b634aa20a4e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 10 Jun 2011 12:27:02 +0000 Subject: *** empty log message *** --- coro.c | 88 +++++++++++++++++++++++++++++++++++++++++------------------------- coro.h | 3 ++- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/coro.c b/coro.c index 39774e1..55d2dd2 100644 --- a/coro.c +++ b/coro.c @@ -125,31 +125,53 @@ trampoline (int sig) /* windows, of course, gives a shit on the amd64 ABI and uses different registers */ /* http://blogs.msdn.com/freik/archive/2005/03/17/398200.aspx */ #if __amd64 - #define NUM_SAVED 6 - "\tpush %rbp\n" - "\tpush %rbx\n" - "\tpush %r12\n" - "\tpush %r13\n" - "\tpush %r14\n" - "\tpush %r15\n" - #if CORO_WIN_TIB - "\tpush %gs:0x0\n" - "\tpush %gs:0x8\n" - "\tpush %gs:0xc\n" - #endif - "\tmov %rsp, (%rdi)\n" - "\tmov (%rsi), %rsp\n" - #if CORO_WIN_TIB - "\tpop %gs:0xc\n" - "\tpop %gs:0x8\n" - "\tpop %gs:0x0\n" + #ifdef _WIN32 + #define NUM_SAVED 8 + "\tpush %rsi\n" + "\tpush %rdi\n" + "\tpush %rbp\n" + "\tpush %rbx\n" + "\tpush %r12\n" + "\tpush %r13\n" + "\tpush %r14\n" + "\tpush %r15\n" + #if CORO_WIN_TIB + "\tpush %gs:0x0\n" + "\tpush %gs:0x8\n" + "\tpush %gs:0xc\n" + #endif + "\tmov %rsp, (%rcx)\n" + "\tmov (%rdx), %rsp\n" + #if CORO_WIN_TIB + "\tpop %gs:0xc\n" + "\tpop %gs:0x8\n" + "\tpop %gs:0x0\n" + #endif + "\tpop %r15\n" + "\tpop %r14\n" + "\tpop %r13\n" + "\tpop %r12\n" + "\tpop %rbx\n" + "\tpop %rbp\n" + "\tpop %rdi\n" + "\tpop %rsi\n" + #else + #define NUM_SAVED 6 + "\tpush %rbp\n" + "\tpush %rbx\n" + "\tpush %r12\n" + "\tpush %r13\n" + "\tpush %r14\n" + "\tpush %r15\n" + "\tmov %rsp, (%rdi)\n" + "\tmov (%rsi), %rsp\n" + "\tpop %r15\n" + "\tpop %r14\n" + "\tpop %r13\n" + "\tpop %r12\n" + "\tpop %rbx\n" + "\tpop %rbp\n" #endif - "\tpop %r15\n" - "\tpop %r14\n" - "\tpop %r13\n" - "\tpop %r12\n" - "\tpop %rbx\n" - "\tpop %rbp\n" #elif __i386 #define NUM_SAVED 4 "\tpush %ebp\n" @@ -161,17 +183,17 @@ trampoline (int sig) "\tpush %fs:4\n" "\tpush %fs:8\n" #endif - "\tmov %esp, (%eax)\n" - "\tmov (%edx), %esp\n" + "\tmov %esp, (%eax)\n" + "\tmov (%edx), %esp\n" #if CORO_WIN_TIB - "\tpop %fs:8\n" - "\tpop %fs:4\n" - "\tpop %fs:0\n" + "\tpop %fs:8\n" + "\tpop %fs:4\n" + "\tpop %fs:0\n" #endif - "\tpop %edi\n" - "\tpop %esi\n" - "\tpop %ebx\n" - "\tpop %ebp\n" + "\tpop %edi\n" + "\tpop %esi\n" + "\tpop %ebx\n" + "\tpop %ebp\n" #else #error unsupported architecture #endif diff --git a/coro.h b/coro.h index 399ed1f..c5602bb 100644 --- a/coro.h +++ b/coro.h @@ -72,6 +72,7 @@ * 2010-12-03 tentative support for uclibc (which lacks all sorts of things). * 2011-05-30 set initial callee-saved-registers to zero with CORO_ASM. * use .cfi_undefined rip on linux-amd64 for better backtraces. + * 2011-06-08 maybe properly implement weird windows amd64 calling conventions. */ #ifndef CORO_H @@ -206,7 +207,7 @@ void coro_destroy (coro_context *ctx); && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ && !defined(CORO_IRIX) && !defined(CORO_ASM) \ && !defined(CORO_PTHREAD) -# if defined(WINDOWS) +# if defined(WINDOWS) || defined(_WIN32) # define CORO_LOSER 1 /* you don't win with windoze */ # elif defined(__linux) && (defined(__x86) || defined (__amd64)) # define CORO_ASM 1 -- cgit v1.2.3