… | |
… | |
44 | # define STACK_ADJUST_PTR(sp,ss) (sp) |
44 | # define STACK_ADJUST_PTR(sp,ss) (sp) |
45 | # define STACK_ADJUST_SIZE(sp,ss) (ss) |
45 | # define STACK_ADJUST_SIZE(sp,ss) (ss) |
46 | # endif |
46 | # endif |
47 | #endif |
47 | #endif |
48 | |
48 | |
49 | #if CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX |
49 | #if CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX |
|
|
50 | |
|
|
51 | #include <stdlib.h> |
50 | |
52 | |
51 | #if CORO_SJLJ |
53 | #if CORO_SJLJ |
52 | # include <stdio.h> |
54 | # include <stdio.h> |
53 | # include <signal.h> |
55 | # include <signal.h> |
|
|
56 | # include <unistd.h> |
54 | #endif |
57 | #endif |
55 | |
58 | |
56 | static volatile coro_func coro_init_func; |
59 | static volatile coro_func coro_init_func; |
57 | static volatile void *coro_init_arg; |
60 | static volatile void *coro_init_arg; |
58 | static volatile coro_context *new_coro, *create_coro; |
61 | static volatile coro_context *new_coro, *create_coro; |
… | |
… | |
103 | ctx->uc.uc_stack.ss_size = (size_t) STACK_ADJUST_SIZE (sptr,ssize); |
106 | ctx->uc.uc_stack.ss_size = (size_t) STACK_ADJUST_SIZE (sptr,ssize); |
104 | ctx->uc.uc_stack.ss_flags = 0; |
107 | ctx->uc.uc_stack.ss_flags = 0; |
105 | |
108 | |
106 | makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); |
109 | makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); |
107 | |
110 | |
108 | #elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX |
111 | #elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX |
109 | |
112 | |
110 | # if CORO_SJLJ |
113 | # if CORO_SJLJ |
111 | stack_t ostk, nstk; |
114 | stack_t ostk, nstk; |
112 | struct sigaction osa, nsa; |
115 | struct sigaction osa, nsa; |
113 | sigset_t nsig, osig; |
116 | sigset_t nsig, osig; |
… | |
… | |
163 | |
166 | |
164 | sigaction (SIGUSR1, &osa, 0); |
167 | sigaction (SIGUSR1, &osa, 0); |
165 | |
168 | |
166 | sigprocmask (SIG_SETMASK, &osig, 0); |
169 | sigprocmask (SIG_SETMASK, &osig, 0); |
167 | |
170 | |
168 | # elif CORO_LOOSE |
171 | # elif CORO_LOSER |
169 | |
172 | |
170 | setjmp (ctx->env); |
173 | setjmp (ctx->env); |
171 | ctx->env[7] = (long)((char *)sptr + ssize); |
174 | ctx->env[7] = (long)((char *)sptr + ssize); |
172 | ctx->env[8] = (long)coro_init; |
175 | ctx->env[8] = (long)coro_init; |
173 | |
176 | |