--- libcoro/coro.c 2003/03/22 23:08:40 1.10 +++ libcoro/coro.c 2005/08/20 01:03:31 1.16 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001 Marc Alexander Lehmann + * Copyright (c) 2001-2005 Marc Alexander Lehmann * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: @@ -46,9 +46,12 @@ # endif #endif -#if CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX +#if CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX -#include +#if CORO_SJLJ +# include +# include +#endif static volatile coro_func coro_init_func; static volatile void *coro_init_arg; @@ -74,7 +77,7 @@ /* trampoline signal handler */ static void -trampoline(int sig) +trampoline (int sig) { if (setjmp (((coro_context *)new_coro)->env)) coro_init (); /* start it */ @@ -102,7 +105,7 @@ makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); -#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX +#elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX # if CORO_SJLJ stack_t ostk, nstk; @@ -162,11 +165,11 @@ sigprocmask (SIG_SETMASK, &osig, 0); -# elif CORO_LOOSE +# elif CORO_LOSER setjmp (ctx->env); - ctx->env[7] = (int)((char *)sptr + ssize); - ctx->env[8] = (int)coro_init; + ctx->env[7] = (long)((char *)sptr + ssize); + ctx->env[8] = (long)coro_init; # elif CORO_LINUX @@ -182,6 +185,9 @@ #elif defined(__GNU_LIBRARY__) && defined(__i386__) ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init; ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize); +#elif defined(__GNU_LIBRARY__) && defined(__amd64__) + ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; + ctx->env[0].__jmpbuf[JB_RSP] = (long)((char *)sptr + ssize); #else #error "linux libc or architecture not supported" #endif