--- cvsroot/libcoro/coro.c 2001/07/23 22:09:39 1.2 +++ cvsroot/libcoro/coro.c 2001/07/24 19:52:55 1.4 @@ -32,7 +32,7 @@ #include "coro.h" -#if CORO_LOOSE || CORO_SJLJ +#if CORO_LOOSE || CORO_SJLJ || CORO_LINUX #include @@ -48,7 +48,7 @@ coro_transfer ((coro_context *)new_coro, (coro_context *)create_coro); - func (arg); + func ((void *)arg); /* the new coro returned. bad. just abort() for now */ abort (); @@ -63,7 +63,7 @@ static void trampoline(int sig) { - if (setjmp (&(((coro_context *)new_coro)->env))) + if (setjmp (((coro_context *)new_coro)->env)) coro_init (); /* start it */ else trampoline_count++; @@ -91,7 +91,7 @@ makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); -#elif CORO_SJLJ || CORO_LOOSE +#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX # if CORO_SJLJ stack_t ostk, nstk; @@ -151,11 +151,29 @@ sigprocmask (SIG_SETMASK, &osig, 0); -# elif MS_LOOSE +# elif CORO_LOOSE - coro_save (ctx); + setjmp (ctx->env); ctx->env[7] = (int)((char *)sptr + ssize); - ctx->env[8] = (int)coro; + ctx->env[8] = (int)coro_init; + +# elif CORO_LINUX + + setjmp (ctx->env); +#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \ + && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(JB_PC) && defined(JB_SP) + ctx->env[0].__jmpbuf[JB_PC] = (int)coro_init; + ctx->env[0].__jmpbuf[JB_SP] = (int)((char *)sptr + ssize); +#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \ + && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(__mc68000__) + ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; + ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize); +#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); +#else +#error "Unsupported Linux (g)libc version and/or platform" +#endif # endif