_info 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include "config.h"
  4. /**
  5. * compiler - macros for common compiler extensions
  6. *
  7. * Abstracts away some compiler hints. Currently these include:
  8. * - COLD
  9. * For functions not called in fast paths (aka. cold functions)
  10. * - PRINTF_FMT
  11. * For functions which take printf-style parameters.
  12. * - IDEMPOTENT
  13. * For functions which return the same value for same parameters.
  14. * - NEEDED
  15. * For functions and variables which must be emitted even if unused.
  16. * - UNNEEDED
  17. * For functions and variables which need not be emitted if unused.
  18. * - UNUSED
  19. * For parameters which are not used.
  20. * - IS_COMPILE_CONSTANT
  21. * For using different tradeoffs for compiletime vs runtime evaluation.
  22. *
  23. * License: LGPL (3 or any later version)
  24. * Author: Rusty Russell <rusty@rustcorp.com.au>
  25. *
  26. * Example:
  27. * #include <ccan/compiler/compiler.h>
  28. * #include <stdio.h>
  29. * #include <stdarg.h>
  30. *
  31. * // Example of a (slow-path) logging function.
  32. * static int log_threshold = 2;
  33. * static void COLD PRINTF_FMT(2,3)
  34. * logger(int level, const char *fmt, ...)
  35. * {
  36. * va_list ap;
  37. * va_start(ap, fmt);
  38. * if (level >= log_threshold)
  39. * vfprintf(stderr, fmt, ap);
  40. * va_end(ap);
  41. * }
  42. *
  43. * int main(int argc, char *argv[])
  44. * {
  45. * if (argc != 1) {
  46. * logger(3, "Don't want %i arguments!\n", argc-1);
  47. * return 1;
  48. * }
  49. * return 0;
  50. * }
  51. */
  52. int main(int argc, char *argv[])
  53. {
  54. /* Expect exactly one argument */
  55. if (argc != 2)
  56. return 1;
  57. if (strcmp(argv[1], "depends") == 0) {
  58. return 0;
  59. }
  60. return 1;
  61. }