_info 1.8 KB

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