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

Comparing cvsroot/libcoro/coro.c (file contents):
Revision 1.23 by root, Thu Nov 30 18:21:14 2006 UTC vs.
Revision 1.25 by root, Fri Apr 27 19:26:18 2007 UTC

65 65
66static volatile coro_func coro_init_func; 66static volatile coro_func coro_init_func;
67static volatile void *coro_init_arg; 67static volatile void *coro_init_arg;
68static volatile coro_context *new_coro, *create_coro; 68static volatile coro_context *new_coro, *create_coro;
69 69
70/* what we really want to detect here is wether we use a new-enough version of GAS */
71/* instead, check for gcc 3 and ELF and hope for the best */
72#if __GNUC__ >= 3 && __ELF__
73# define HAVE_CFI 1
74#endif
75
70static void 76static void
71coro_init (void) 77coro_init (void)
72{ 78{
73 volatile coro_func func = coro_init_func; 79 volatile coro_func func = coro_init_func;
74 volatile void *arg = coro_init_arg; 80 volatile void *arg = coro_init_arg;
75 81
76 coro_transfer ((coro_context *)new_coro, (coro_context *)create_coro); 82 coro_transfer ((coro_context *)new_coro, (coro_context *)create_coro);
77 83
84#if HAVE_CFI
85 asm (".cfi_startproc");
86#endif
78 func ((void *)arg); 87 func ((void *)arg);
88#if HAVE_CFI
89 asm (".cfi_endproc");
90#endif
79 91
80 /* the new coro returned. bad. just abort() for now */ 92 /* the new coro returned. bad. just abort() for now */
81 abort (); 93 abort ();
82} 94}
83 95
201#endif 213#endif
202 214
203# elif CORO_LINUX 215# elif CORO_LINUX
204 216
205 _setjmp (ctx->env); 217 _setjmp (ctx->env);
206#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
207 && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(JB_PC) && defined(JB_SP) 218#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (JB_PC) && defined (JB_SP)
208 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 219 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init;
209 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr,ssize); 220 ctx->env[0].__jmpbuf[JB_SP] = (long)STACK_ADJUST_PTR (sptr, ssize);
210#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
211 && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined(__mc68000__) 221#elif __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && defined (__mc68000__)
212 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init; 222 ctx->env[0].__jmpbuf[0].__aregs[0] = (long int)coro_init;
213 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize); 223 ctx->env[0].__jmpbuf[0].__sp = (int *)((char *)sptr + ssize);
214#elif defined(__GNU_LIBRARY__) && defined(__i386__) 224#elif defined (__GNU_LIBRARY__) && defined (__i386__)
215 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init; 225 ctx->env[0].__jmpbuf[0].__pc = (char *)coro_init;
216 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize); 226 ctx->env[0].__jmpbuf[0].__sp = (void *)((char *)sptr + ssize);
217#elif defined(__GNU_LIBRARY__) && defined(__amd64__) 227#elif defined (__GNU_LIBRARY__) && defined (__amd64__)
218 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init; 228 ctx->env[0].__jmpbuf[JB_PC] = (long)coro_init;
219 ctx->env[0].__jmpbuf[JB_RSP] = (long)STACK_ADJUST_PTR (sptr,ssize); 229 ctx->env[0].__jmpbuf[JB_RSP] = (long)STACK_ADJUST_PTR (sptr, ssize);
220#else 230#else
221#error "linux libc or architecture not supported" 231#error "linux libc or architecture not supported"
222#endif 232#endif
223 233
224# elif CORO_IRIX 234# elif CORO_IRIX
225 235
226 setjmp (ctx->env); 236 setjmp (ctx->env);
227 ctx->env[JB_PC] = (__uint64_t)coro_init; 237 ctx->env[JB_PC] = (__uint64_t)coro_init;
228 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr,ssize); 238 ctx->env[JB_SP] = (__uint64_t)STACK_ADJUST_PTR (sptr, ssize);
229 239
230# endif 240# endif
231 241
232 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro); 242 coro_transfer ((coro_context *)create_coro, (coro_context *)new_coro);
233 243

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines