_info 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * generator - generators for C
  6. *
  7. * Generators are a limited form of coroutines, which provide a useful
  8. * way of expressing certain problems, while being much simpler to
  9. * understand than general coroutines.
  10. *
  11. * Instead of returning a single value, a generator can "yield" a
  12. * value at various points during its execution. Whenever it yields,
  13. * the "calling" function resumes and obtains the newly yielded value
  14. * to work with. When the caller asks for the next value from the
  15. * generator, the generator resumes execution from the last yield and
  16. * continues onto the next.
  17. *
  18. * Example:
  19. * #include <stdio.h>
  20. * #include <ccan/generator/generator.h>
  21. *
  22. * generator_def_static(simple_gen, int)
  23. * {
  24. * generator_yield(1);
  25. * generator_yield(3);
  26. * generator_yield(17);
  27. * }
  28. *
  29. * int main(int argc, char *argv[])
  30. * {
  31. * generator_t(int) gen = simple_gen();
  32. * int *ret;
  33. *
  34. * while ((ret = generator_next(gen)) != NULL) {
  35. * printf("Generator returned %d\n", *ret);
  36. * }
  37. *
  38. * return 0;
  39. * }
  40. *
  41. * Author: David Gibson <david@gibson.dropbear.id.au>
  42. * License: LGPL (v2.1 or any later version)
  43. *
  44. * Ccanlint:
  45. * // We need several gcc extensions
  46. * objects_build_without_features FAIL
  47. * tests_compile_without_features FAIL
  48. * tests_helpers_compile_without_features FAIL
  49. */
  50. int main(int argc, char *argv[])
  51. {
  52. /* Expect exactly one argument */
  53. if (argc != 2)
  54. return 1;
  55. if (strcmp(argv[1], "depends") == 0) {
  56. printf("ccan/build_assert\n");
  57. printf("ccan/ptrint\n");
  58. printf("ccan/alignof\n");
  59. printf("ccan/cppmagic\n");
  60. printf("ccan/compiler\n");
  61. return 0;
  62. }
  63. if (strcmp(argv[1], "ported") == 0) {
  64. #if HAVE_UCONTEXT
  65. printf("\n");
  66. #else
  67. printf("Needs ucontext support\n");
  68. #endif
  69. }
  70. if (strcmp(argv[1], "testdepends") == 0) {
  71. printf("ccan/str\n");
  72. return 0;
  73. }
  74. return 1;
  75. }