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

Comparing libcoro/coro.c (file contents):
Revision 1.44 by root, Wed Nov 19 02:56:16 2008 UTC vs.
Revision 1.47 by root, Fri Jul 17 14:05:00 2009 UTC

1/* 1/*
2 * Copyright (c) 2001-2008 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2001-2009 Marc Alexander Lehmann <schmorp@schmorp.de>
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without modifica- 4 * Redistribution and use in source and binary forms, with or without modifica-
5 * tion, are permitted provided that the following conditions are met: 5 * tion, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
224 224
225# elif CORO_LOSER 225# elif CORO_LOSER
226 226
227 coro_setjmp (ctx->env); 227 coro_setjmp (ctx->env);
228 #if __CYGWIN__ 228 #if __CYGWIN__
229 ctx->env[8] = (long) coro_init;
229 ctx->env[7] = (long)((char *)sptr + ssize) - sizeof (long); 230 ctx->env[7] = (long) ((char *)sptr + ssize) - sizeof (long);
230 ctx->env[8] = (long)coro_init; 231 #elif defined(__MINGW32__)
232 ctx->env[5] = (long) coro_init;
233 ctx->env[4] = (long) ((char *)sptr + ssize) - sizeof (long);
231 #elif defined(_M_IX86) 234 #elif defined(_M_IX86)
232 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long)coro_init; 235 ((_JUMP_BUFFER *)&ctx->env)->Eip = (long) coro_init;
233 ((_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);
234 #elif defined(_M_AMD64) 237 #elif defined(_M_AMD64)
235 ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64)coro_init; 238 ((_JUMP_BUFFER *)&ctx->env)->Rip = (__int64) coro_init;
236 ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); 239 ((_JUMP_BUFFER *)&ctx->env)->Rsp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
237 #elif defined(_M_IA64) 240 #elif defined(_M_IA64)
238 ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64)coro_init; 241 ((_JUMP_BUFFER *)&ctx->env)->StIIP = (__int64) coro_init;
239 ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64)STACK_ADJUST_PTR (sptr, ssize) - sizeof (long); 242 ((_JUMP_BUFFER *)&ctx->env)->IntSp = (__int64) STACK_ADJUST_PTR (sptr, ssize) - sizeof (long);
240 #else 243 #else
241 #error "microsoft libc or architecture not supported" 244 #error "microsoft libc or architecture not supported"
242 #endif 245 #endif
243 246
244# elif CORO_LINUX 247# elif CORO_LINUX
245 248
246 coro_setjmp (ctx->env); 249 coro_setjmp (ctx->env);
247 #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)
248 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 251 ctx->env[0].__jmpbuf[JB_PC] = (long) coro_init;
249 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);
250 #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__) 253 #elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__)
251 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; 254 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init;
252 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize) - sizeof (long); 255 ctx->env[0].__jmpbuf[0].__sp = (int *) ((char *)sptr + ssize) - sizeof (long);
253 #elif defined (__GNU_LIBRARY__) && defined (__i386__) 256 #elif defined (__GNU_LIBRARY__) && defined (__i386__)
254 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init; 257 ctx->env[0].__jmpbuf[0].__pc = (char *) coro_init;
255 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize) - sizeof (long); 258 ctx->env[0].__jmpbuf[0].__sp = (void *) ((char *)sptr + ssize) - sizeof (long);
256 #elif defined (__GNU_LIBRARY__) && defined (__amd64__) 259 #elif defined (__GNU_LIBRARY__) && defined (__amd64__)
257 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 260 ctx->env[0].__jmpbuf[JB_PC] = (long) coro_init;
258 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize) - sizeof (long); 261 ctx->env[0].__jmpbuf[0].__sp = (void *) ((char *)sptr + ssize) - sizeof (long);
259 #else 262 #else
260 #error "linux libc or architecture not supported" 263 #error "linux libc or architecture not supported"
261 #endif 264 #endif
262 265
263# elif CORO_IRIX 266# elif CORO_IRIX
264 267
265 coro_setjmp (ctx->env, 0); 268 coro_setjmp (ctx->env, 0);
266 ctx->env[JB_PC] = (__uint64_t)coro_init; 269 ctx->env[JB_PC] = (__uint64_t)coro_init;
267 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);
268 271
269# elif CORO_ASM 272# elif CORO_ASM
270 273
271 ctx->sp = (void **)(ssize + (char *)sptr); 274 ctx->sp = (void **)(ssize + (char *)sptr);
272 *--ctx->sp = (void *)abort; /* needed for alignment only */ 275 *--ctx->sp = (void *)abort; /* needed for alignment only */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines