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

Comparing libcoro/coro.c (file contents):
Revision 1.42 by root, Mon Nov 10 04:37:23 2008 UTC vs.
Revision 1.44 by root, Wed Nov 19 02:56:16 2008 UTC

100 100
101/* trampoline signal handler */ 101/* trampoline signal handler */
102static void 102static void
103trampoline (int sig) 103trampoline (int sig)
104{ 104{
105 if (
106 #if _XOPEN_UNIX > 0
107 _setjmp (new_coro->env) 105 if (coro_setjmp (new_coro->env))
108 #else
109 sigsetjmp (new_coro->env, 0)
110 #endif
111 ) {
112 coro_init (); /* start it */ 106 coro_init (); /* start it */
113 }
114 else 107 else
115 trampoline_done = 1; 108 trampoline_done = 1;
116} 109}
117 110
118# endif 111# endif
229 sigaction (SIGUSR2, &osa, 0); 222 sigaction (SIGUSR2, &osa, 0);
230 sigprocmask (SIG_SETMASK, &osig, 0); 223 sigprocmask (SIG_SETMASK, &osig, 0);
231 224
232# elif CORO_LOSER 225# elif CORO_LOSER
233 226
234 setjmp (ctx->env); 227 coro_setjmp (ctx->env);
235 #if __CYGWIN__ 228 #if __CYGWIN__
236 ctx->env[7] = (long)((char *)sptr + ssize) - sizeof (long); 229 ctx->env[7] = (long)((char *)sptr + ssize) - sizeof (long);
237 ctx->env[8] = (long)coro_init; 230 ctx->env[8] = (long)coro_init;
238 #elif defined(_M_IX86) 231 #elif defined(_M_IX86)
239 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init; 232 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init;
248 #error "microsoft libc or architecture not supported" 241 #error "microsoft libc or architecture not supported"
249 #endif 242 #endif
250 243
251# elif CORO_LINUX 244# elif CORO_LINUX
252 245
253 _setjmp (ctx->env); 246 coro_setjmp (ctx->env);
254 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP) 247 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP)
255 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 248 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init;
256 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); 249 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
257 #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__) 250 #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__)
258 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; 251 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init;
267 #error "linux libc or architecture not supported" 260 #error "linux libc or architecture not supported"
268 #endif 261 #endif
269 262
270# elif CORO_IRIX 263# elif CORO_IRIX
271 264
272 sigsetjmp (ctx->env, 0); 265 coro_setjmp (ctx->env, 0);
273 ctx->env[JB_PC] = (__uint64_t)coro_init; 266 ctx->env[JB_PC] = (__uint64_t)coro_init;
274 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); 267 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
275 268
276# elif CORO_ASM 269# elif CORO_ASM
277 270
341void 334void
342coro_transfer (coro_context *prev, coro_context *next) 335coro_transfer (coro_context *prev, coro_context *next)
343{ 336{
344 pthread_cond_signal (&next->cv); 337 pthread_cond_signal (&next->cv);
345 pthread_cond_wait (&prev->cv, &coro_mutex); 338 pthread_cond_wait (&prev->cv, &coro_mutex);
339#if __FreeBSD__ /* freebsd is of course broken and needs manual testcancel calls... yay... */
340 pthread_testcancel ();
341#endif
346} 342}
347 343
348void 344void
349coro_create (coro_context *ctx, coro_func coro, void *arg, void *sptr, long ssize) 345coro_create (coro_context *ctx, coro_func coro, void *arg, void *sptr, long ssize)
350{ 346{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines