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

Comparing libcoro/coro.h (file contents):
Revision 1.11 by root, Sat Aug 20 01:03:31 2005 UTC vs.
Revision 1.15 by root, Thu Oct 26 07:27:50 2006 UTC

1/* 1/*
2 * Copyright (c) 2001-2005 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2001-2006 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,
33 * build your own process abstraction using it or - better - just use GNU 33 * build your own process abstraction using it or - better - just use GNU
34 * Portable Threads, http://www.gnu.org/software/pth/. 34 * Portable Threads, http://www.gnu.org/software/pth/.
35 * 35 *
36 */ 36 */
37 37
38/*
39 * 2006-10-26 Include stddef.h on OS X to work around one of its bugs.
40 * Reported by Michael_G_Schwern.
41 */
42
38#ifndef CORO_H 43#ifndef CORO_H
39#define CORO_H 44#define CORO_H
40 45
41#define CORO_VERSION 2 46#define CORO_VERSION 2
42 47
43/* 48/*
44 * Changes since API version 1: 49 * Changes since API version 1:
45 * replaced bogus -DCORO_LOOSE with gramattically more correct -DCORO_LOSER 50 * replaced bogus -DCORO_LOOSE with gramatically more correct -DCORO_LOSER
46 */ 51 */
47 52
48/* 53/*
49 * This library consists of only three files 54 * This library consists of only three files
50 * coro.h, coro.c and LICENSE (and optionally README) 55 * coro.h, coro.c and LICENSE (and optionally README)
55 * 60 *
56 * -DCORO_UCONTEXT 61 * -DCORO_UCONTEXT
57 * 62 *
58 * This flavour uses SUSv2's get/set/swap/makecontext functions that 63 * This flavour uses SUSv2's get/set/swap/makecontext functions that
59 * unfortunately only newer unices support. 64 * unfortunately only newer unices support.
60 * Use this for GNU/Linux + glibc-2.2.3. 65 * Use this for GNU/Linux + glibc-2.2.3 and possibly higher.
61 * 66 *
62 * -DCORO_SJLJ 67 * -DCORO_SJLJ
63 * 68 *
64 * This flavour uses SUSv'2 setjmp/longjmp and sigaltstack functions to 69 * This flavour uses SUSv2's setjmp/longjmp and sigaltstack functions to
65 * do it's job. Coroutine creation is much slower than UCONTEXT, but 70 * do it's job. Coroutine creation is much slower than UCONTEXT, but
66 * context switching is often a bit cheaper. It should work on almost 71 * context switching is often a bit cheaper. It should work on almost
67 * all unices. Use this for GNU/Linux + glibc-2.2. glibc-2.1 and below 72 * all unices. Use this for GNU/Linux + glibc-2.2. glibc-2.1 and below
68 * do not work with any sane model (neither sigaltstack nor context 73 * do not work with any sane model (neither sigaltstack nor context
69 * functions are implemented) 74 * functions are implemented)
70 * 75 *
71 * -DCORO_LINUX 76 * -DCORO_LINUX
72 * 77 *
73 * Old GNU/Linux systems (<= glibc-2.1) work with this implementation 78 * Old GNU/Linux systems (<= glibc-2.1) work with this implementation
74 * (very fast). 79 * (it is very fast and therefore recommended over other methods).
75 * 80 *
76 * -DCORO_LOSER 81 * -DCORO_LOSER
77 * 82 *
78 * Microsoft's highly proprietary platform doesn't support sigaltstack, and 83 * Microsoft's highly proprietary platform doesn't support sigaltstack, and
79 * this automatically selects a suitable workaround for this platform. 84 * this automatically selects a suitable workaround for this platform.
95typedef void (*coro_func)(void *); 100typedef void (*coro_func)(void *);
96 101
97/* 102/*
98 * A coroutine state is saved in the following structure. Treat it as a 103 * A coroutine state is saved in the following structure. Treat it as a
99 * opaque type. errno and sigmask might be saved, but don't rely on it, 104 * opaque type. errno and sigmask might be saved, but don't rely on it,
100 * implement your own switching primitive. 105 * implement your own switching primitive if you need it.
101 */ 106 */
102typedef struct coro_context coro_context; 107typedef struct coro_context coro_context;
103 108
104/* 109/*
105 * This function creates a new coroutine. Apart from a pointer to an 110 * This function creates a new coroutine. Apart from a pointer to an
106 * uninitialized coro_context, it expects a pointer to the entry function 111 * uninitialised coro_context, it expects a pointer to the entry function
107 * and the single pointer value that is given to it as argument. 112 * and the single pointer value that is given to it as argument.
108 * 113 *
109 * Allocating/deallocating the stack is your own responsibility, so there is 114 * Allocating/deallocating the stack is your own responsibility, so there is
110 * no coro_destroy function. 115 * no coro_destroy function.
111 */ 116 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines