… | |
… | |
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. |
65 | * do not rely on makecontext passing a void * correctly. |
66 | * try harder to get _setjmp/_longjmp. |
66 | * try harder to get _setjmp/_longjmp. |
67 | * major code cleanup/restructuring. |
67 | * major code cleanup/restructuring. |
|
|
68 | * 2008-11-10 the .cfi hacks are no longer needed. |
68 | */ |
69 | */ |
69 | |
70 | |
70 | #ifndef CORO_H |
71 | #ifndef CORO_H |
71 | #define CORO_H |
72 | #define CORO_H |
72 | |
73 | |
… | |
… | |
225 | |
226 | |
226 | # if !CORO_LOSER |
227 | # if !CORO_LOSER |
227 | # include <unistd.h> |
228 | # include <unistd.h> |
228 | # endif |
229 | # endif |
229 | |
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 | |
230 | # include <setjmp.h> |
237 | # include <setjmp.h> |
231 | |
238 | |
232 | struct coro_context { |
239 | struct coro_context { |
|
|
240 | #if _XOPEN_UNIX > 0 || CORO_LOSER |
233 | jmp_buf env; |
241 | jmp_buf env; |
|
|
242 | #else |
|
|
243 | sigjmp_buf env; |
|
|
244 | #endif |
234 | }; |
245 | }; |
235 | |
246 | |
236 | # if _XOPEN_UNIX > 0 |
247 | # if _XOPEN_UNIX > 0 |
237 | # 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) |
238 | # elif CORO_LOSER |
249 | # elif CORO_LOSER |