5 #include <ccan/coroutine/coroutine.h>
8 * generator - generators for C
10 * Generators are a limited form of coroutines, which provide a useful
11 * way of expressing certain problems, while being much simpler to
12 * understand than general coroutines.
14 * Instead of returning a single value, a generator can "yield" a
15 * value at various points during its execution. Whenever it yields,
16 * the "calling" function resumes and obtains the newly yielded value
17 * to work with. When the caller asks for the next value from the
18 * generator, the generator resumes execution from the last yield and
19 * continues onto the next.
23 * #include <ccan/generator/generator.h>
25 * generator_def_static(simple_gen, int)
29 * generator_yield(17);
32 * int main(int argc, char *argv[])
34 * generator_t(int) gen = simple_gen();
37 * while ((ret = generator_next(gen)) != NULL) {
38 * printf("Generator returned %d\n", *ret);
44 * Author: David Gibson <david@gibson.dropbear.id.au>
45 * License: LGPL (v2.1 or any later version)
48 * // We need several gcc extensions
49 * objects_build_without_features FAIL
50 * tests_compile_without_features FAIL
51 * tests_helpers_compile_without_features FAIL
53 int main(int argc, char *argv[])
55 /* Expect exactly one argument */
59 if (strcmp(argv[1], "depends") == 0) {
60 printf("ccan/alignof\n");
61 printf("ccan/coroutine\n");
62 printf("ccan/cppmagic\n");
63 printf("ccan/compiler\n");
67 if (strcmp(argv[1], "ported") == 0) {
68 #if COROUTINE_AVAILABLE
72 printf("Needs coroutine support\n");
76 if (strcmp(argv[1], "testdepends") == 0) {