… | |
… | |
100 | |
100 | |
101 | /* trampoline signal handler */ |
101 | /* trampoline signal handler */ |
102 | static void |
102 | static void |
103 | trampoline (int sig) |
103 | trampoline (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; |
|
|
231 | #elif defined(__MINGW32__) |
|
|
232 | ctx->env[4] = (long)((char *)sptr + ssize) - sizeof (long); |
|
|
233 | ctx->env[5] = (long)coro_init; |
238 | #elif defined(_M_IX86) |
234 | #elif defined(_M_IX86) |
239 | ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init; |
235 | ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init; |
240 | ((_JUMP_BUFFER *)&ctx->env)->Esp = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
236 | ((_JUMP_BUFFER *)&ctx->env)->Esp = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
241 | #elif defined(_M_AMD64) |
237 | #elif defined(_M_AMD64) |
242 | ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64)coro_init; |
238 | ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64)coro_init; |
… | |
… | |
248 | #error "microsoft libc or architecture not supported" |
244 | #error "microsoft libc or architecture not supported" |
249 | #endif |
245 | #endif |
250 | |
246 | |
251 | # elif CORO_LINUX |
247 | # elif CORO_LINUX |
252 | |
248 | |
253 | _setjmp (ctx->env); |
249 | coro_setjmp (ctx->env); |
254 | #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP) |
250 | #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP) |
255 | ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; |
251 | ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; |
256 | ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
252 | ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
257 | #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__) |
253 | #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__) |
258 | ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; |
254 | ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; |
… | |
… | |
267 | #error "linux libc or architecture not supported" |
263 | #error "linux libc or architecture not supported" |
268 | #endif |
264 | #endif |
269 | |
265 | |
270 | # elif CORO_IRIX |
266 | # elif CORO_IRIX |
271 | |
267 | |
272 | sigsetjmp (ctx->env, 0); |
268 | coro_setjmp (ctx->env, 0); |
273 | ctx->env[JB_PC] = (__uint64_t)coro_init; |
269 | ctx->env[JB_PC] = (__uint64_t)coro_init; |
274 | ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
270 | ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
275 | |
271 | |
276 | # elif CORO_ASM |
272 | # elif CORO_ASM |
277 | |
273 | |