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

Comparing libcoro/coro.h (file contents):
Revision 1.24 by root, Sun Mar 2 16:10:22 2008 UTC vs.
Revision 1.30 by root, Wed Nov 5 01:54:34 2008 UTC

51 * Use _setjmp instead of setjmp on _XOPEN_SOURCE >= 600. 51 * Use _setjmp instead of setjmp on _XOPEN_SOURCE >= 600.
52 * 2007-05-02 Add assembly versions for x86 and amd64 (to avoid reliance 52 * 2007-05-02 Add assembly versions for x86 and amd64 (to avoid reliance
53 * on SIGUSR2 and sigaltstack in Crossfire). 53 * on SIGUSR2 and sigaltstack in Crossfire).
54 * 2008-01-21 Disable CFI usage on anything but GNU/Linux. 54 * 2008-01-21 Disable CFI usage on anything but GNU/Linux.
55 * 2008-03-02 Switched to 2-clause BSD license with GPL exception. 55 * 2008-03-02 Switched to 2-clause BSD license with GPL exception.
56 * 2008-04-04 New (but highly unrecommended) pthreads backend.
57 * 2008-04-24 Reinstate CORO_LOSER (had wrong stack adjustments).
58 * 2008-10-30 Support assembly method on x86 with and without frame pointer.
59 * 2008-11-03 Use a global asm statement for CORO_ASM, idea by pippijn.
60 * 2008-11-05 Hopefully fix misaligned stacks with CORO_ASM/SETJMP.
56 */ 61 */
57 62
58#ifndef CORO_H 63#ifndef CORO_H
59#define CORO_H 64#define CORO_H
60 65
103 * 108 *
104 * -DCORO_ASM 109 * -DCORO_ASM
105 * 110 *
106 * Handcoded assembly, known to work only on a few architectures/ABI: 111 * Handcoded assembly, known to work only on a few architectures/ABI:
107 * ELF Linux x86 && amd64 when gcc is used and optimisation is turned on. 112 * ELF Linux x86 && amd64 when gcc is used and optimisation is turned on.
113 *
114 * -DCORO_PTHREAD
115 *
116 * Use the pthread API. You have to provide <pthread.h> and -lpthread.
108 * 117 *
109 * If you define neither of these symbols, coro.h will try to autodetect 118 * If you define neither of these symbols, coro.h will try to autodetect
110 * the model. This currently works for CORO_LOSER only. For the other 119 * the model. This currently works for CORO_LOSER only. For the other
111 * alternatives you should check (e.g. using autoconf) and define the 120 * alternatives you should check (e.g. using autoconf) and define the
112 * following symbols: HAVE_UCONTEXT_H / HAVE_SETJMP_H / HAVE_SIGALTSTACK. 121 * following symbols: HAVE_UCONTEXT_H / HAVE_SETJMP_H / HAVE_SIGALTSTACK.
151 160
152/*****************************************************************************/ 161/*****************************************************************************/
153 162
154#if !defined(CORO_LOSER) && !defined(CORO_UCONTEXT) \ 163#if !defined(CORO_LOSER) && !defined(CORO_UCONTEXT) \
155 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ 164 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \
156 && !defined(CORO_IRIX) && !defined(CORO_ASM) 165 && !defined(CORO_IRIX) && !defined(CORO_ASM) \
166 && !defined(CORO_PTHREAD)
157# if defined(WINDOWS) 167# if defined(WINDOWS)
158# define CORO_LOSER 1 /* you don't win with windoze */ 168# define CORO_LOSER 1 /* you don't win with windoze */
159# elif defined(__linux) && (defined(__x86) || defined (__amd64)) 169# elif defined(__linux) && (defined(__x86) || defined (__amd64))
160# define CORO_ASM 1 170# define CORO_ASM 1
161# elif defined(HAVE_UCONTEXT_H) 171# elif defined(HAVE_UCONTEXT_H)
198# endif 208# endif
199 209
200#elif CORO_ASM 210#elif CORO_ASM
201 211
202struct coro_context { 212struct coro_context {
203 volatile void **sp; 213 volatile void **sp; /* must be at offset 0 */
204}; 214};
205 215
206void __attribute__ ((__noinline__, __fastcall__)) 216void __attribute__ ((__noinline__, __regparm__(2)))
207 coro_transfer(coro_context *prev, coro_context *next); 217coro_transfer (coro_context *prev, coro_context *next);
218
219#elif CORO_PTHREAD
220
221#include <pthread.h>
222
223extern pthread_mutex_t coro_mutex;
224
225struct coro_context {
226 pthread_cond_t c;
227};
228
229void coro_transfer (coro_context *prev, coro_context *next);
208 230
209#endif 231#endif
210 232
211#endif 233#endif
212 234

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines