diff options
| author | root <root> | 2001-09-03 02:50:18 +0000 | 
|---|---|---|
| committer | root <root> | 2001-09-03 02:50:18 +0000 | 
| commit | 1a785df222780bdd7bae43b343622150cf934cee (patch) | |
| tree | 42c3c1c0f383c1c24b25f8fa2cb619cdb1e402f3 | |
| parent | 6c2bc57bdfc3eebecd17199e1c0cb677e7190f19 (diff) | |
*** empty log message ***
| -rw-r--r-- | coro.c | 28 | ||||
| -rw-r--r-- | coro.h | 13 | 
2 files changed, 30 insertions, 11 deletions
| @@ -32,7 +32,14 @@  #include "coro.h" -#if CORO_LOOSE || CORO_SJLJ || CORO_LINUX +#if CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX + +/* IRIX is decidedly NON-unix */ +#if __sgi +# define STACK_ADJUST(sp,ss) ((ss) - sizeof (long) + (char *)(sp)) +#else +# define STACK_ADJUST(sp,ss) (ss) +#endif  #include <signal.h> @@ -55,7 +62,6 @@ coro_init (void)  }  # if CORO_SJLJ -# define coro_save(ctx)     (void)setjmp((ctx)->env)  static volatile int trampoline_count; @@ -71,8 +77,6 @@ trampoline(int sig)  # endif -#elif CORO_UCONTEXT -# define coro_save(ctx)     getcontext(&((ctx)->uc))  #endif  /* initialize a machine state */ @@ -84,14 +88,14 @@ void coro_create(coro_context *ctx,    getcontext (&(ctx->uc)); -  ctx->uc.uc_link          =  0; -  ctx->uc.uc_stack.ss_sp    = sptr; +  ctx->uc.uc_link           =  0; +  ctx->uc.uc_stack.ss_sp    = STACK_ADJUST(sptr,ssize);    ctx->uc.uc_stack.ss_size  = (size_t) ssize;    ctx->uc.uc_stack.ss_flags = 0;    makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); -#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX +#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX  # if CORO_SJLJ    stack_t ostk, nstk; @@ -121,7 +125,7 @@ void coro_create(coro_context *ctx,      perror ("sigaction");    /* set the new stack */ -  nstk.ss_sp    = sptr; +  nstk.ss_sp    = STACK_ADJUST(sptr,ssize); /* yes, some platforms (IRIX) get this wrong. */    nstk.ss_size  = ssize;    nstk.ss_flags = 0; @@ -172,9 +176,15 @@ void coro_create(coro_context *ctx,    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" +#error "linux libc or architecture not supported"  #endif +# elif CORO_IRIX + +  setjmp (ctx->env); +  ctx->env[JB_PC] = (int)coro_init; +  ctx->env[JB_SP] = (int)((char *)sptr + ssize); +  # endif    coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro); @@ -73,6 +73,10 @@   *    this automatically selects a suitable workaround for this platform.   *    (untested)   * + * -DCORO_IRIX + * + *    SGI's version of Microsoft's NT ;) + *   * If you define neither of these symbols, coro.h will try to autodetect   * the model.  This currently works for CORO_LOOSE only. For the other   * alternatives you should check (e.g. using autoconf) and define the @@ -115,8 +119,11 @@ void coro_transfer(coro_context *prev, coro_context *next);   * That was it. No other user-visible functions are implemented here.   */ +/*****************************************************************************/ +  #if !defined(CORO_LOOSE) && !defined(CORO_UCONTEXT) \ -    && !defined(CORO_SJLJ) && !defined(CORO_LINUX) +    && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ +    && !defined(CORO_IRIX)  # if defined(WINDOWS)  #  define CORO_LOOSE 1 /* you don't win with windoze */  # elif defined(__linux) && defined(__x86) @@ -129,6 +136,8 @@ error unknown or unsupported architecture  # endif  #endif +/*****************************************************************************/ +  #if CORO_UCONTEXT  #include <ucontext.h> @@ -139,7 +148,7 @@ struct coro_context {  #define coro_transfer(p,n) swapcontext(&((p)->uc), &((n)->uc)) -#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX +#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX  #include <setjmp.h> | 
