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

Comparing libcoro/coro.h (file contents):
Revision 1.4 by root, Tue Jul 24 20:18:12 2001 UTC vs.
Revision 1.6 by root, Sun Sep 16 01:34:36 2001 UTC

71 * 71 *
72 * Microsoft's highly proprietary platform doesn't support sigaltstack, and 72 * Microsoft's highly proprietary platform doesn't support sigaltstack, and
73 * this automatically selects a suitable workaround for this platform. 73 * this automatically selects a suitable workaround for this platform.
74 * (untested) 74 * (untested)
75 * 75 *
76 * -DCORO_IRIX
77 *
78 * SGI's version of Microsoft's NT ;)
79 *
76 * If you define neither of these symbols, coro.h will try to autodetect 80 * If you define neither of these symbols, coro.h will try to autodetect
77 * the model. This currently works for CORO_LOOSE only. For the other 81 * the model. This currently works for CORO_LOOSE only. For the other
78 * alternatives you should check (e.g. using autoconf) and define the 82 * alternatives you should check (e.g. using autoconf) and define the
79 * following symbols: HAVE_UCONTEXT_H / HAVE_SETJMP_H / HAVE_SIGALTSTACK. 83 * following symbols: HAVE_UCONTEXT_H / HAVE_SETJMP_H / HAVE_SIGALTSTACK.
80 */ 84 */
81 85
82/* 86/*
83 * This is the type for the top function of a new coroutine. 87 * This is the type for the initialization function of a new coroutine.
84 */ 88 */
85typedef void (*coro_func)(void *); 89typedef void (*coro_func)(void *);
86
87 90
88/* 91/*
89 * A coroutine state is saved in the following structure. Treat it as a 92 * A coroutine state is saved in the following structure. Treat it as a
90 * opaque type. errno and sigmask might be saved, but don't rely on it, 93 * opaque type. errno and sigmask might be saved, but don't rely on it,
91 * implement your own switching primitive. 94 * implement your own switching primitive.
113 116
114/* 117/*
115 * That was it. No other user-visible functions are implemented here. 118 * That was it. No other user-visible functions are implemented here.
116 */ 119 */
117 120
121/*****************************************************************************/
122
118#if !defined(CORO_LOOSE) && !defined(CORO_UCONTEXT) \ 123#if !defined(CORO_LOOSE) && !defined(CORO_UCONTEXT) \
119 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) 124 && !defined(CORO_SJLJ) && !defined(CORO_LINUX) \
125 && !defined(CORO_IRIX)
120# if defined(WINDOWS) 126# if defined(WINDOWS)
121# define CORO_LOOSE 1 /* you don't win with windoze */ 127# define CORO_LOOSE 1 /* you don't win with windoze */
122# elif defined(__linux) && defined(__x86) 128# elif defined(__linux) && defined(__x86)
123# elif defined(HAVE_UCONTEXT_H) 129# elif defined(HAVE_UCONTEXT_H)
124# define CORO_UCONTEXT 1 130# define CORO_UCONTEXT 1
127# else 133# else
128error unknown or unsupported architecture 134error unknown or unsupported architecture
129# endif 135# endif
130#endif 136#endif
131 137
138/*****************************************************************************/
139
132#if CORO_UCONTEXT 140#if CORO_UCONTEXT
133 141
134#include <ucontext.h> 142#include <ucontext.h>
135 143
136struct coro_context { 144struct coro_context {
137 ucontext_t uc; 145 ucontext_t uc;
138}; 146};
139 147
140#define coro_transfer(p,n) swapcontext(&((p)->uc), &((n)->uc)) 148#define coro_transfer(p,n) swapcontext(&((p)->uc), &((n)->uc))
141 149
142#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX 150#elif CORO_SJLJ || CORO_LOOSE || CORO_LINUX || CORO_IRIX
143 151
144#include <setjmp.h> 152#include <setjmp.h>
145 153
146struct coro_context { 154struct coro_context {
147 jmp_buf env; 155 jmp_buf env;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines