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

Comparing libcoro/coro.h (file contents):
Revision 1.50 by root, Mon Aug 8 22:00:18 2011 UTC vs.
Revision 1.51 by root, Wed Dec 5 01:09:12 2012 UTC

1/* 1/*
2 * Copyright (c) 2001-2011 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,
73 * 2011-05-30 set initial callee-saved-registers to zero with CORO_ASM. 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. 74 * use .cfi_undefined rip on linux-amd64 for better backtraces.
75 * 2011-06-08 maybe properly implement weird windows amd64 calling conventions. 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. 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. 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).
78 */ 80 */
79 81
80#ifndef CORO_H 82#ifndef CORO_H
81#define CORO_H 83#define CORO_H
82 84
120 * -DCORO_LOSER 122 * -DCORO_LOSER
121 * 123 *
122 * Microsoft's highly proprietary platform doesn't support sigaltstack, and 124 * Microsoft's highly proprietary platform doesn't support sigaltstack, and
123 * this automatically selects a suitable workaround for this platform. 125 * this automatically selects a suitable workaround for this platform.
124 * (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.
125 * 132 *
126 * -DCORO_IRIX 133 * -DCORO_IRIX
127 * 134 *
128 * SGI's version of Microsoft's NT ;) 135 * SGI's version of Microsoft's NT ;)
129 * 136 *
203 * That was it. No other user-visible functions are implemented here. 210 * That was it. No other user-visible functions are implemented here.
204 */ 211 */
205 212
206/*****************************************************************************/ 213/*****************************************************************************/
207 214
208#if !defined(CORO_LOSER) && !defined(CORO_UCONTEXT) \ 215#if !defined CORO_LOSER && !defined CORO_UCONTEXT \
209 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \ 216 && !defined CORO_SJLJ && !defined CORO_LINUX \
210 && !defined(CORO_IRIX) && !defined(CORO_ASM) \ 217 && !defined CORO_IRIX && !defined CORO_ASM \
211 && !defined(CORO_PTHREAD) 218 && !defined CORO_PTHREAD && !defined CORO_FIBER
219# if defined WINDOWS && (defined __x86 || defined __amd64 || defined _M_IX86 || defined _M_AMD64)
220# define CORO_ASM 1
212# if defined(WINDOWS) || defined(_WIN32) 221# elif defined WINDOWS || defined _WIN32
213# define CORO_LOSER 1 /* you don't win with windoze */ 222# define CORO_LOSER 1 /* you don't win with windoze */
214# elif defined(__linux) && (defined(__x86) || defined (__amd64)) 223# elif defined __linux && (defined __x86 || defined __amd64)
215# define CORO_ASM 1 224# define CORO_ASM 1
216# elif defined(HAVE_UCONTEXT_H) 225# elif defined HAVE_UCONTEXT_H
217# define CORO_UCONTEXT 1 226# define CORO_UCONTEXT 1
218# elif defined(HAVE_SETJMP_H) && defined(HAVE_SIGALTSTACK) 227# elif defined HAVE_SETJMP_H && defined HAVE_SIGALTSTACK
219# define CORO_SJLJ 1 228# define CORO_SJLJ 1
220# else 229# else
221error unknown or unsupported architecture 230error unknown or unsupported architecture
222# endif 231# endif
223#endif 232#endif
297}; 306};
298 307
299void coro_transfer (coro_context *prev, coro_context *next); 308void coro_transfer (coro_context *prev, coro_context *next);
300void coro_destroy (coro_context *ctx); 309void coro_destroy (coro_context *ctx);
301 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
302#endif 320#endif
303 321
304#if __cplusplus 322#if __cplusplus
305} 323}
306#endif 324#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines