_info 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include "config.h"
  4. /**
  5. * likely - macros for annotating likely/unlikely branches in the code
  6. *
  7. * Inspired by Andi Kleen's macros for the Linux Kernel, these macros
  8. * help you annotate rare paths in your code for the convenience of the
  9. * compiler and the reader.
  10. *
  11. * With CCAN_LIKELY_DEBUG defined, it provides statistics for each
  12. * likely()/unlikely() call (but note that this requires LGPL dependencies).
  13. *
  14. * License: CC0 (Public domain)
  15. * Author: Rusty Russell <rusty@rustcorp.com.au>
  16. *
  17. * Example:
  18. * #include <ccan/likely/likely.h>
  19. * #include <stdio.h>
  20. *
  21. * int main(int argc, char *argv[])
  22. * {
  23. * // This example is silly: the compiler knows exit() is unlikely.
  24. * if (unlikely(argc == 1)) {
  25. * fprintf(stderr, "Usage: %s <args>...\n", argv[0]);
  26. * return 1;
  27. * }
  28. * for (argc++; argv[argc]; argc++)
  29. * printf("%s\n", argv[argc]);
  30. * return 0;
  31. * }
  32. */
  33. int main(int argc, char *argv[])
  34. {
  35. /* Expect exactly one argument */
  36. if (argc != 2)
  37. return 1;
  38. if (strcmp(argv[1], "depends") == 0) {
  39. #ifdef CCAN_LIKELY_DEBUG
  40. printf("ccan/str\n");
  41. printf("ccan/htable\n");
  42. printf("ccan/hash\n");
  43. #endif
  44. return 0;
  45. }
  46. if (strcmp(argv[1], "testdepends") == 0) {
  47. #ifndef CCAN_LIKELY_DEBUG
  48. printf("ccan/str\n");
  49. printf("ccan/htable\n");
  50. printf("ccan/hash\n");
  51. #endif
  52. return 0;
  53. }
  54. return 1;
  55. }