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

Comparing libcoro/coro.h (file contents):
Revision 1.44 by root, Fri Dec 3 19:21:59 2010 UTC vs.
Revision 1.51 by root, Wed Dec 5 01:09:12 2012 UTC

1/* 1/*
2 * Copyright (c) 2001-2009 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2001-2012 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,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * 9 *
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
68 * 2008-11-10 the .cfi hacks are no longer needed. 68 * 2008-11-10 the .cfi hacks are no longer needed.
69 * 2008-11-16 work around a freebsd pthread bug. 69 * 2008-11-16 work around a freebsd pthread bug.
70 * 2008-11-19 define coro_*jmp symbols for easier porting. 70 * 2008-11-19 define coro_*jmp symbols for easier porting.
71 * 2009-06-23 tentative win32-backend support for mingw32 (Yasuhiro Matsumoto). 71 * 2009-06-23 tentative win32-backend support for mingw32 (Yasuhiro Matsumoto).
72 * 2010-12-03 tentative support for uclibc (which lacks all sorts of things). 72 * 2010-12-03 tentative support for uclibc (which lacks all sorts of things).
73 * 2011-05-30 set initial callee-saved-registers to zero with CORO_ASM.
74 * use .cfi_undefined rip on linux-amd64 for better backtraces.
75 * 2011-06-08 maybe properly implement weird windows amd64 calling conventions.
76 * 2011-07-03 rely on __GCC_HAVE_DWARF2_CFI_ASM for cfi detection.
77 * 2011-08-08 cygwin trashes stacks, use pthreads with double stack on cygwin.
78 * 2012-12-04 reduce misprediction penalty for x86/amd64 assembly switcher.
79 * 2012-12-05 experimental fiber backend (allocates stack twice).
73 */ 80 */
74 81
75#ifndef CORO_H 82#ifndef CORO_H
76#define CORO_H 83#define CORO_H
77 84
115 * -DCORO_LOSER 122 * -DCORO_LOSER
116 * 123 *
117 * Microsoft's highly proprietary platform doesn't support sigaltstack, and 124 * Microsoft's highly proprietary platform doesn't support sigaltstack, and
118 * this automatically selects a suitable workaround for this platform. 125 * this automatically selects a suitable workaround for this platform.
119 * (untested) 126 * (untested)
127 *
128 * -DCORO_FIBER
129 *
130 * slower, but probably more portable variant for the Microsoft operating
131 * system, using fibers. ignores your stack.
120 * 132 *
121 * -DCORO_IRIX 133 * -DCORO_IRIX
122 * 134 *
123 * SGI's version of Microsoft's NT ;) 135 * SGI's version of Microsoft's NT ;)
124 * 136 *
198 * That was it. No other user-visible functions are implemented here. 210 * That was it. No other user-visible functions are implemented here.
199 */ 211 */
200 212
201/*****************************************************************************/ 213/*****************************************************************************/
202 214
203#if !defined(CORO_LOSER) && !defined(CORO_UCONTEXT) \ 215#if !defined CORO_LOSER && !defined CORO_UCONTEXT \
204 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ 216 && !defined CORO_SJLJ && !defined CORO_LINUX \
205 && !defined(CORO_IRIX) && !defined(CORO_ASM) \ 217 && !defined CORO_IRIX && !defined CORO_ASM \
206 && !defined(CORO_PTHREAD) 218 && !defined CORO_PTHREAD && !defined CORO_FIBER
207# if defined(WINDOWS) 219# if defined WINDOWS && (defined __x86 || defined __amd64 || defined _M_IX86 || defined _M_AMD64)
220# define CORO_ASM 1
221# elif defined WINDOWS || defined _WIN32
208# define CORO_LOSER 1 /* you don't win with windoze */ 222# define CORO_LOSER 1 /* you don't win with windoze */
209# elif defined(__linux) && (defined(__x86) || defined (__amd64)) 223# elif defined __linux && (defined __x86 || defined __amd64)
210# define CORO_ASM 1 224# define CORO_ASM 1
211# elif defined(HAVE_UCONTEXT_H) 225# elif defined HAVE_UCONTEXT_H
212# define CORO_UCONTEXT 1 226# define CORO_UCONTEXT 1
213# elif defined(HAVE_SETJMP_H) && defined(HAVE_SIGALTSTACK) 227# elif defined HAVE_SETJMP_H && defined HAVE_SIGALTSTACK
214# define CORO_SJLJ 1 228# define CORO_SJLJ 1
215# else 229# else
216error unknown or unsupported architecture 230error unknown or unsupported architecture
217# endif 231# endif
218#endif 232#endif
292}; 306};
293 307
294void coro_transfer (coro_context *prev, coro_context *next); 308void coro_transfer (coro_context *prev, coro_context *next);
295void coro_destroy (coro_context *ctx); 309void coro_destroy (coro_context *ctx);
296 310
311#elif CORO_FIBER
312
313struct coro_context {
314 void *fiber;
315 /* only used for initialisation */
316 coro_func coro;
317 void *arg;
318};
319
297#endif 320#endif
298 321
299#if __cplusplus 322#if __cplusplus
300} 323}
301#endif 324#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines