6 * generator - generators for C
8 * Generators are a limited form of coroutines, which provide a useful
9 * way of expressing certain problems, while being much simpler to
10 * understand than general coroutines.
12 * Instead of returning a single value, a generator can "yield" a
13 * value at various points during its execution. Whenever it yields,
14 * the "calling" function resumes and obtains the newly yielded value
15 * to work with. When the caller asks for the next value from the
16 * generator, the generator resumes execution from the last yield and
17 * continues onto the next.
21 * #include <ccan/generator/generator.h>
23 * generator_def_static(simple_gen, int)
27 * generator_yield(17);
30 * int main(int argc, char *argv[])
32 * generator_t(int) gen = simple_gen();
35 * while ((ret = generator_next(gen)) != NULL) {
36 * printf("Generator returned %d\n", *ret);
42 * Author: David Gibson <david@gibson.dropbear.id.au>
43 * License: LGPL (v2.1 or any later version)
46 * // We need several gcc extensions
47 * objects_build_without_features FAIL
48 * tests_compile_without_features FAIL
49 * tests_helpers_compile_without_features FAIL
51 int main(int argc, char *argv[])
53 /* Expect exactly one argument */
57 if (strcmp(argv[1], "depends") == 0) {
58 printf("ccan/build_assert\n");
59 printf("ccan/ptrint\n");
60 printf("ccan/alignof\n");
61 printf("ccan/cppmagic\n");
62 printf("ccan/compiler\n");
66 if (strcmp(argv[1], "ported") == 0) {
70 printf("Needs ucontext support\n");
74 if (strcmp(argv[1], "testdepends") == 0) {