--- libcoro/coro.c 2005/03/21 14:35:22 1.15 +++ libcoro/coro.c 2006/10/26 05:20:47 1.20 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2005 Marc Alexander Lehmann + * Copyright (c) 2001-2006 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: @@ -40,17 +40,27 @@ # elif __i386__ && CORO_LINUX # define STACK_ADJUST_PTR(sp,ss) ((char *)(sp) + (ss)) # define STACK_ADJUST_SIZE(sp,ss) (ss) +# elif __amd64__ && CORO_LINUX +# define STACK_ADJUST_PTR(sp,ss) ((char *)(sp) + (ss) - 8) +# define STACK_ADJUST_SIZE(sp,ss) (ss) # else # define STACK_ADJUST_PTR(sp,ss) (sp) # define STACK_ADJUST_SIZE(sp,ss) (ss) # endif #endif -#if CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX +#if CORO_UCONTEXT +# include +#endif + +#if CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX + +#include #if CORO_SJLJ # include # include +# include #endif static volatile coro_func coro_init_func; @@ -105,7 +115,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; @@ -161,11 +171,11 @@ if (~ostk.ss_flags & SS_DISABLE) sigaltstack (&ostk, 0); - sigaction (SIGUSR1, &osa, 0); + sigaction (SIGUSR2, &osa, 0); sigprocmask (SIG_SETMASK, &osig, 0); -# elif CORO_LOOSE +# elif CORO_LOSER setjmp (ctx->env); ctx->env[7] = (long)((char *)sptr + ssize); @@ -187,7 +197,7 @@ 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); + ctx->env[0].__jmpbuf[JB_RSP] = (long)STACK_ADJUST_PTR (sptr,ssize); #else #error "linux libc or architecture not supported" #endif