ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libcoro/coro.c
(Generate patch)

Comparing libcoro/coro.c (file contents):
Revision 1.3 by root, Mon Jul 23 22:16:38 2001 UTC vs.
Revision 1.4 by root, Tue Jul 24 19:52:55 2001 UTC

30 * go to Ralf S. Engelschall <rse@engelschall.com>. 30 * go to Ralf S. Engelschall <rse@engelschall.com>.
31 */ 31 */
32 32
33#include "coro.h" 33#include "coro.h"
34 34
35#if CORO_LOOSE || CORO_SJLJ 35#if CORO_LOOSE || CORO_SJLJ || CORO_LINUX
36 36
37#include <signal.h> 37#include <signal.h>
38 38
39static volatile coro_func coro_init_func; 39static volatile coro_func coro_init_func;
40static volatile void *coro_init_arg; 40static volatile void *coro_init_arg;
89 ctx->uc.uc_stack.ss_size = (size_t) ssize; 89 ctx->uc.uc_stack.ss_size = (size_t) ssize;
90 ctx->uc.uc_stack.ss_flags = 0; 90 ctx->uc.uc_stack.ss_flags = 0;
91 91
92 makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); 92 makecontext (&(ctx->uc), (void (*)()) coro, 1, arg);
93 93
94#elif CORO_SJLJ || CORO_LOOSE 94#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX
95 95
96# if CORO_SJLJ 96# if CORO_SJLJ
97 stack_t ostk, nstk; 97 stack_t ostk, nstk;
98 struct sigaction osa, nsa; 98 struct sigaction osa, nsa;
99 sigset_t nsig, osig; 99 sigset_t nsig, osig;
149 149
150 sigaction (SIGUSR1, &osa, 0); 150 sigaction (SIGUSR1, &osa, 0);
151 151
152 sigprocmask (SIG_SETMASK, &osig, 0); 152 sigprocmask (SIG_SETMASK, &osig, 0);
153 153
154# elif MS_LOOSE 154# elif CORO_LOOSE
155 155
156 coro_save (ctx); 156 setjmp (ctx->env);
157 ctx->env[7] = (int)((char *)sptr + ssize); 157 ctx->env[7] = (int)((char *)sptr + ssize);
158 ctx->env[8] = (int)coro; 158 ctx->env[8] = (int)coro_init;
159
160# elif CORO_LINUX
161
162 setjmp (ctx->env);
163#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
164 && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(JB_PC) && defined(JB_SP)
165 ctx->env[0].__jmpbuf[JB_PC] = (int)coro_init;
166 ctx->env[0].__jmpbuf[JB_SP] = (int)((char *)sptr + ssize);
167#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
168 && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(__mc68000__)
169 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init;
170 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize);
171#elif defined(__GNU_LIBRARY__) && defined(__i386__)
172 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init;
173 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize);
174#else
175#error "Unsupported Linux (g)libc version and/or platform"
176#endif
159 177
160# endif 178# endif
161 179
162 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro); 180 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro);
163 181

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines