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

Comparing libcoro/coro.c (file contents):
Revision 1.35 by root, Mon Nov 3 16:05:38 2008 UTC vs.
Revision 1.36 by root, Wed Nov 5 01:54:34 2008 UTC

126 ".text\n" 126 ".text\n"
127 ".globl coro_transfer\n" 127 ".globl coro_transfer\n"
128 ".type coro_transfer, @function\n" 128 ".type coro_transfer, @function\n"
129 "coro_transfer:\n" 129 "coro_transfer:\n"
130#if __amd64 130#if __amd64
131# define NUM_ALIGN 1
131# define NUM_SAVED 5 132# define NUM_SAVED 5
132 "\tpush %rbx\n" 133 "\tpush %rbx\n"
133 "\tpush %r12\n" 134 "\tpush %r12\n"
134 "\tpush %r13\n" 135 "\tpush %r13\n"
135 "\tpush %r14\n" 136 "\tpush %r14\n"
140 "\tpop %r14\n" 141 "\tpop %r14\n"
141 "\tpop %r13\n" 142 "\tpop %r13\n"
142 "\tpop %r12\n" 143 "\tpop %r12\n"
143 "\tpop %rbx\n" 144 "\tpop %rbx\n"
144#elif __i386 145#elif __i386
146# define NUM_ALIGN 1
145# define NUM_SAVED 4 147# define NUM_SAVED 4
146 "\tpush %ebx\n" 148 "\tpush %ebx\n"
147 "\tpush %esi\n" 149 "\tpush %esi\n"
148 "\tpush %edi\n" 150 "\tpush %edi\n"
149 "\tpush %ebp\n" 151 "\tpush %ebp\n"
207 209
208 getcontext (&(ctx->uc)); 210 getcontext (&(ctx->uc));
209 211
210 ctx->uc.uc_link = 0; 212 ctx->uc.uc_link = 0;
211 ctx->uc.uc_stack.ss_sp = STACK_ADJUST_PTR (sptr,ssize); 213 ctx->uc.uc_stack.ss_sp = STACK_ADJUST_PTR (sptr,ssize);
212 ctx->uc.uc_stack.ss_size = (size_t) STACK_ADJUST_SIZE (sptr,ssize); 214 ctx->uc.uc_stack.ss_size = (size_t)STACK_ADJUST_SIZE (sptr,ssize);
213 ctx->uc.uc_stack.ss_flags = 0; 215 ctx->uc.uc_stack.ss_flags = 0;
214 216
215 makecontext (&(ctx->uc), (void (*)()) coro, 1, arg); 217 makecontext (&(ctx->uc), (void (*)()) coro, 1, arg);
216 218
217#elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX || CORO_ASM 219#elif CORO_SJLJ || CORO_LOSER || CORO_LINUX || CORO_IRIX || CORO_ASM
282 284
283# elif CORO_LOSER 285# elif CORO_LOSER
284 286
285 setjmp (ctx->env); 287 setjmp (ctx->env);
286#if __CYGWIN__ 288#if __CYGWIN__
287 ctx->env[7] = (long)((char *)sptr + ssize); 289 ctx->env[7] = (long)((char *)sptr + ssize) - sizeof (long);
288 ctx->env[8] = (long)coro_init; 290 ctx->env[8] = (long)coro_init;
289#elif defined(_M_IX86) 291#elif defined(_M_IX86)
290 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init; 292 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init;
291 ((_JUMP_BUFFER *)&ctx->env)->Esp = (long)STACK_ADJUST_PTR (sptr, ssize); 293 ((_JUMP_BUFFER *)&ctx->env)->Esp = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
292#elif defined(_M_AMD64) 294#elif defined(_M_AMD64)
293 ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64)coro_init; 295 ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64)coro_init;
294 ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64)STACK_ADJUST_PTR (sptr, ssize); 296 ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
295#elif defined(_M_IA64) 297#elif defined(_M_IA64)
296 ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64)coro_init; 298 ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64)coro_init;
297 ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64)STACK_ADJUST_PTR (sptr, ssize); 299 ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
298#else 300#else
299# error "microsoft libc or architecture not supported" 301# error "microsoft libc or architecture not supported"
300#endif 302#endif
301 303
302# elif CORO_LINUX 304# elif CORO_LINUX
303 305
304 _setjmp (ctx->env); 306 _setjmp (ctx->env);
305#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP) 307#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP)
306 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 308 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init;
307 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize); 309 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
308#elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__) 310#elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__)
309 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; 311 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init;
310 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize); 312 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize) - sizeof (long);
311#elif defined (__GNU_LIBRARY__) && defined (__i386__) 313#elif defined (__GNU_LIBRARY__) && defined (__i386__)
312 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init; 314 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init;
313 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize); 315 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize) - sizeof (long);
314#elif defined (__GNU_LIBRARY__) && defined (__amd64__) 316#elif defined (__GNU_LIBRARY__) && defined (__amd64__)
315 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 317 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init;
316 ctx->env[0].__jmpbuf[JB_RSP] = (long)STACK_ADJUST_PTR (sptr, ssize); 318 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize) - sizeof (long);
317#else 319#else
318# error "linux libc or architecture not supported" 320# error "linux libc or architecture not supported"
319#endif 321#endif
320 322
321# elif CORO_IRIX 323# elif CORO_IRIX
322 324
323 setjmp (ctx->env); 325 setjmp (ctx->env);
324 ctx->env[JB_PC] = (__uint64_t)coro_init; 326 ctx->env[JB_PC] = (__uint64_t)coro_init;
325 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize); 327 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
326 328
327# elif CORO_ASM 329# elif CORO_ASM
328 330
329 ctx->sp = (volatile void **)(ssize + (char *)sptr); 331 ctx->sp = (volatile void **)(ssize + (char *)sptr);
330 /* we try to allow for both functions with and without frame pointers */ 332 ctx->sp -= NUM_ALIGN;
331 *--ctx->sp = (void *)coro_init; 333 *--ctx->sp = (void *)coro_init;
332 { 334 ctx->sp -= NUM_SAVED;
333 int i;
334 for (i = NUM_SAVED; i--; )
335 *--ctx->sp = 0;
336 }
337 335
338# endif 336# endif
339 337
340 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro); 338 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro);
341 339

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines