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