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

Comparing libcoro/coro.h (file contents):
Revision 1.32 by root, Fri Nov 7 20:12:26 2008 UTC vs.
Revision 1.37 by root, Mon Nov 10 04:37:24 2008 UTC

60 * 2008-11-05 Hopefully fix misaligned stacks with CORO_ASM/SETJMP. 60 * 2008-11-05 Hopefully fix misaligned stacks with CORO_ASM/SETJMP.
61 * 2008-11-07 rbp wasn't saved in CORO_ASM on x86_64. 61 * 2008-11-07 rbp wasn't saved in CORO_ASM on x86_64.
62 * introduce coro_destroy, which is a nop except for pthreads. 62 * introduce coro_destroy, which is a nop except for pthreads.
63 * speed up CORO_PTHREAD. Do no longer leak threads either. 63 * speed up CORO_PTHREAD. Do no longer leak threads either.
64 * coro_create now allows one to create source coro_contexts. 64 * coro_create now allows one to create source coro_contexts.
65 * do not rely on makecontext passing a void * correctly.
66 * try harder to get _setjmp/_longjmp.
67 * major code cleanup/restructuring.
68 * 2008-11-10 the .cfi hacks are no longer needed.
65 */ 69 */
66 70
67#ifndef CORO_H 71#ifndef CORO_H
68#define CORO_H 72#define CORO_H
69 73
218 222
219# if defined(CORO_LINUX) && !defined(_GNU_SOURCE) 223# if defined(CORO_LINUX) && !defined(_GNU_SOURCE)
220# define _GNU_SOURCE /* for linux libc */ 224# define _GNU_SOURCE /* for linux libc */
221# endif 225# endif
222 226
227# if !CORO_LOSER
228# include <unistd.h>
229# endif
230
231/* solaris is hopelessly borked, it expands _XOPEN_UNIX to nothing */
232# if __sun
233# undef _XOPEN_UNIX
234# define _XOPEN_UNIX 1
235# endif
236
223# include <setjmp.h> 237# include <setjmp.h>
224 238
225struct coro_context { 239struct coro_context {
240#if _XOPEN_UNIX > 0 || CORO_LOSER
226 jmp_buf env; 241 jmp_buf env;
242#else
243 sigjmp_buf env;
244#endif
227}; 245};
228 246
229# if CORO_LINUX || (_XOPEN_SOURCE >= 600) 247# if _XOPEN_UNIX > 0
230# define coro_transfer(p,n) do { if (!_setjmp ((p)->env)) _longjmp ((n)->env, 1); } while (0) 248# define coro_transfer(p,n) do { if (! _setjmp ((p)->env )) _longjmp ((n)->env, 1); } while (0)
249# elif CORO_LOSER
250# define coro_transfer(p,n) do { if (! setjmp ((p)->env )) longjmp ((n)->env, 1); } while (0)
231# else 251# else
232# define coro_transfer(p,n) do { if (!setjmp ((p)->env)) longjmp ((n)->env, 1); } while (0) 252# define coro_transfer(p,n) do { if (!sigsetjmp ((p)->env, 0)) siglongjmp ((n)->env, 1); } while (0)
233# endif 253# endif
234 254
235# define coro_destroy(ctx) (void *)(ctx) 255# define coro_destroy(ctx) (void *)(ctx)
236 256
237#elif CORO_ASM 257#elif CORO_ASM
238 258
239struct coro_context { 259struct coro_context {
240 volatile void **sp; /* must be at offset 0 */ 260 void **sp; /* must be at offset 0 */
241}; 261};
242 262
243void __attribute__ ((__noinline__, __regparm__(2))) 263void __attribute__ ((__noinline__, __regparm__(2)))
244coro_transfer (coro_context *prev, coro_context *next); 264coro_transfer (coro_context *prev, coro_context *next);
245 265

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines