X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Fgenerator%2F_info;fp=ccan%2Fgenerator%2F_info;h=a6570e373e8e2489f443fd2e65385eb2ae2567e8;hb=707a8c0a899a4b645bcf778f7ea79565d6f3f13e;hp=0000000000000000000000000000000000000000;hpb=d4c7616d9ef5a55dd89ea878a07eedc7376d6973;p=ccan diff --git a/ccan/generator/_info b/ccan/generator/_info new file mode 100644 index 00000000..a6570e37 --- /dev/null +++ b/ccan/generator/_info @@ -0,0 +1,71 @@ +#include "config.h" +#include +#include + +/** + * generator - generators for C + * + * Generators are a limited form of coroutines, which provide a useful + * way of expressing certain problems, while being much simpler to + * understand than general coroutines. + * + * Instead of returning a single value, a generator can "yield" a + * value at various points during its execution. Whenever it yields, + * the "calling" function resumes and obtains the newly yielded value + * to work with. When the caller asks for the next value from the + * generator, the generator resumes execution from the last yield and + * continues onto the next. + * + * Example: + * #include + * #include + * + * generator_def_static(simple_gen, int) + * { + * generator_yield(1); + * generator_yield(3); + * generator_yield(17); + * } + * + * int main(int argc, char *argv[]) + * { + * generator_t(int) gen = simple_gen(); + * int *ret; + * + * while ((ret = generator_next(gen)) != NULL) { + * printf("Generator returned %d\n", *ret); + * } + * + * return 0; + * } + * + * Author: David Gibson + * License: LGPL (v2.1 or any later version) + * + * Ccanlint: + * // We need several gcc extensions + * objects_build_without_features FAIL + * tests_compile_without_features FAIL + * tests_helpers_compile_without_features FAIL + */ +int main(int argc, char *argv[]) +{ + /* Expect exactly one argument */ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/build_assert\n"); + printf("ccan/ptrint\n"); + printf("ccan/alignof\n"); + printf("ccan/cppmagic\n"); + return 0; + } + + if (strcmp(argv[1], "testdepends") == 0) { + printf("ccan/str\n"); + return 0; + } + + return 1; +}