… | |
… | |
123 | "\tpush %rbx\n" |
123 | "\tpush %rbx\n" |
124 | "\tpush %r12\n" |
124 | "\tpush %r12\n" |
125 | "\tpush %r13\n" |
125 | "\tpush %r13\n" |
126 | "\tpush %r14\n" |
126 | "\tpush %r14\n" |
127 | "\tpush %r15\n" |
127 | "\tpush %r15\n" |
|
|
128 | #if CORO_WIN_TIB |
|
|
129 | "\tpush %fs:0xc\n" |
|
|
130 | "\tpush %fs:0x8\n" |
|
|
131 | "\tpush %fs:0x0\n" |
|
|
132 | #endif |
128 | "\tmov %rsp, (%rdi)\n" |
133 | "\tmov %rsp, (%rdi)\n" |
129 | "\tmov (%rsi), %rsp\n" |
134 | "\tmov (%rsi), %rsp\n" |
|
|
135 | #if CORO_WIN_TIB |
|
|
136 | "\tpop %fs:0x0\n" |
|
|
137 | "\tpop %fs:0x8\n" |
|
|
138 | "\tpop %fs:0xc\n" |
|
|
139 | #endif |
130 | "\tpop %r15\n" |
140 | "\tpop %r15\n" |
131 | "\tpop %r14\n" |
141 | "\tpop %r14\n" |
132 | "\tpop %r13\n" |
142 | "\tpop %r13\n" |
133 | "\tpop %r12\n" |
143 | "\tpop %r12\n" |
134 | "\tpop %rbx\n" |
144 | "\tpop %rbx\n" |
… | |
… | |
137 | #define NUM_SAVED 4 |
147 | #define NUM_SAVED 4 |
138 | "\tpush %ebp\n" |
148 | "\tpush %ebp\n" |
139 | "\tpush %ebx\n" |
149 | "\tpush %ebx\n" |
140 | "\tpush %esi\n" |
150 | "\tpush %esi\n" |
141 | "\tpush %edi\n" |
151 | "\tpush %edi\n" |
|
|
152 | #if CORO_WIN_TIB |
|
|
153 | "\tpush %fs:8\n" |
|
|
154 | "\tpush %fs:4\n" |
|
|
155 | "\tpush %fs:0\n" |
|
|
156 | #endif |
142 | "\tmov %esp, (%eax)\n" |
157 | "\tmov %esp, (%eax)\n" |
143 | "\tmov (%edx), %esp\n" |
158 | "\tmov (%edx), %esp\n" |
|
|
159 | #if CORO_WIN_TIB |
|
|
160 | "\tpop %fs:0\n" |
|
|
161 | "\tpop %fs:4\n" |
|
|
162 | "\tpop %fs:8\n" |
|
|
163 | #endif |
144 | "\tpop %edi\n" |
164 | "\tpop %edi\n" |
145 | "\tpop %esi\n" |
165 | "\tpop %esi\n" |
146 | "\tpop %ebx\n" |
166 | "\tpop %ebx\n" |
147 | "\tpop %ebp\n" |
167 | "\tpop %ebp\n" |
148 | #else |
168 | #else |
… | |
… | |
223 | sigprocmask (SIG_SETMASK, &osig, 0); |
243 | sigprocmask (SIG_SETMASK, &osig, 0); |
224 | |
244 | |
225 | # elif CORO_LOSER |
245 | # elif CORO_LOSER |
226 | |
246 | |
227 | coro_setjmp (ctx->env); |
247 | coro_setjmp (ctx->env); |
228 | #if __CYGWIN__ |
248 | #if __CYGWIN__ && __i386 |
229 | ctx->env[8] = (long) coro_init; |
249 | ctx->env[8] = (long) coro_init; |
230 | ctx->env[7] = (long) ((char *)sptr + ssize) - sizeof (long); |
250 | ctx->env[7] = (long) ((char *)sptr + ssize) - sizeof (long); |
|
|
251 | #elif __CYGWIN__ && __x86_64 |
|
|
252 | ctx->env[7] = (long) coro_init; |
|
|
253 | ctx->env[6] = (long) ((char *)sptr + ssize) - sizeof (long); |
231 | #elif defined(__MINGW32__) |
254 | #elif defined(__MINGW32__) |
232 | ctx->env[5] = (long) coro_init; |
255 | ctx->env[5] = (long) coro_init; |
233 | ctx->env[4] = (long) ((char *)sptr + ssize) - sizeof (long); |
256 | ctx->env[4] = (long) ((char *)sptr + ssize) - sizeof (long); |
234 | #elif defined(_M_IX86) |
257 | #elif defined(_M_IX86) |
235 | ((_JUMP_BUFFER *)&ctx->env)->Eip = (long) coro_init; |
258 | ((_JUMP_BUFFER *)&ctx->env)->Eip = (long) coro_init; |
236 | ((_JUMP_BUFFER *)&ctx->env)->Esp = (long) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
259 | ((_JUMP_BUFFER *)&ctx->env)->Esp = (long) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
237 | #elif defined(_M_AMD64) |
260 | #elif defined(_M_AMD64) |
238 | ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64) coro_init; |
261 | ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64) coro_init; |
239 | ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
262 | ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (__int64); |
240 | #elif defined(_M_IA64) |
263 | #elif defined(_M_IA64) |
241 | ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64) coro_init; |
264 | ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64) coro_init; |
242 | ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); |
265 | ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (__int64); |
243 | #else |
266 | #else |
244 | #error "microsoft libc or architecture not supported" |
267 | #error "microsoft libc or architecture not supported" |
245 | #endif |
268 | #endif |
246 | |
269 | |
247 | # elif CORO_LINUX |
270 | # elif CORO_LINUX |
… | |
… | |
274 | ctx->sp = (void **)(ssize + (char *)sptr); |
297 | ctx->sp = (void **)(ssize + (char *)sptr); |
275 | *--ctx->sp = (void *)abort; /* needed for alignment only */ |
298 | *--ctx->sp = (void *)abort; /* needed for alignment only */ |
276 | *--ctx->sp = (void *)coro_init; |
299 | *--ctx->sp = (void *)coro_init; |
277 | ctx->sp -= NUM_SAVED; |
300 | ctx->sp -= NUM_SAVED; |
278 | |
301 | |
|
|
302 | #if CORO_WIN_TIB |
|
|
303 | *--ctx->sp = sptr; /* StackLimit */ |
|
|
304 | *--ctx->sp = (char *)sptr + ssize; /* StackBase */ |
|
|
305 | *--ctx->sp = 0; /* ExceptionList */ |
|
|
306 | #endif |
|
|
307 | |
279 | # elif CORO_UCONTEXT |
308 | # elif CORO_UCONTEXT |
280 | |
309 | |
281 | getcontext (&(ctx->uc)); |
310 | getcontext (&(ctx->uc)); |
282 | |
311 | |
283 | ctx->uc.uc_link = 0; |
312 | ctx->uc.uc_link = 0; |