From 5989869a493d6bb1fc49ec0f85e45e20922ae241 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Nov 2006 18:21:14 +0000 Subject: *** empty log message *** --- coro.c | 16 +++++++++++----- coro.h | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/coro.c b/coro.c index d431054..196a4d3 100644 --- a/coro.c +++ b/coro.c @@ -100,9 +100,9 @@ trampoline (int sig) #endif /* initialize a machine state */ -void coro_create(coro_context *ctx, - coro_func coro, void *arg, - void *sptr, long ssize) +void coro_create (coro_context *ctx, + coro_func coro, void *arg, + void *sptr, long ssize) { #if CORO_UCONTEXT @@ -142,7 +142,10 @@ void coro_create(coro_context *ctx, nsa.sa_flags = SA_ONSTACK; if (sigaction (SIGUSR2, &nsa, &osa)) - perror ("sigaction"); + { + perror ("sigaction"); + abort (); + } /* set the new stack */ nstk.ss_sp = STACK_ADJUST_PTR (sptr,ssize); /* yes, some platforms (IRIX) get this wrong. */ @@ -150,7 +153,10 @@ void coro_create(coro_context *ctx, nstk.ss_flags = 0; if (sigaltstack (&nstk, &ostk) < 0) - perror ("sigaltstack"); + { + perror ("sigaltstack"); + abort (); + } trampoline_count = 0; kill (getpid (), SIGUSR2); diff --git a/coro.h b/coro.h index b74ee22..788810f 100644 --- a/coro.h +++ b/coro.h @@ -101,9 +101,9 @@ typedef void (*coro_func)(void *); /* - * A coroutine state is saved in the following structure. Treat it as a + * A coroutine state is saved in the following structure. Treat it as an * opaque type. errno and sigmask might be saved, but don't rely on it, - * implement your own switching primitive if you need it. + * implement your own switching primitive if you need that. */ typedef struct coro_context coro_context; @@ -115,9 +115,11 @@ typedef struct coro_context coro_context; * Allocating/deallocating the stack is your own responsibility, so there is * no coro_destroy function. */ -void coro_create (coro_context *ctx, - coro_func coro, void *arg, - void *sptr, long ssize); +void coro_create (coro_context *ctx, /* an uninitialised coro_context */ + coro_func coro, /* the coroutine code to be executed */ + void *arg, /* a single pointer passed to the coro */ + void *sptr, /* start of stack area */ + long ssize); /* size of stack area */ /* * The following prototype defines the coroutine switching function. It is @@ -162,7 +164,7 @@ struct coro_context { #elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX #if defined(CORO_LINUX) && !defined(_GNU_SOURCE) -# define _GNU_SOURCE // for linux libc +# define _GNU_SOURCE /* for linux libc */ #endif #include @@ -172,9 +174,9 @@ struct coro_context { }; #if CORO_LINUX -# define coro_transfer(p,n) do { if (!_setjmp ((p)->env)) _longjmp ((n)->env, 1); } while(0) +# define coro_transfer(p,n) do { if (!_setjmp ((p)->env)) _longjmp ((n)->env, 1); } while (0) #else -# define coro_transfer(p,n) do { if (!setjmp ((p)->env)) longjmp ((n)->env, 1); } while(0) +# define coro_transfer(p,n) do { if (!setjmp ((p)->env)) longjmp ((n)->env, 1); } while (0) #endif #endif -- cgit v1.2.3