]> git.ozlabs.org Git - ccan/blob - ccan/likely/_info
str: change example to match function being explained.
[ccan] / ccan / likely / _info
1 #include <string.h>
2 #include <stdio.h>
3 #include "config.h"
4
5 /**
6  * likely - macros for annotating likely/unlikely branches in the code
7  *
8  * Inspired by Andi Kleen's macros for the Linux Kernel, these macros
9  * help you annotate rare paths in your code for the convenience of the
10  * compiler and the reader.
11  *
12  * License: LGPL (2 or any later version)
13  * Author: Rusty Russell <rusty@rustcorp.com.au>
14  *
15  * Example:
16  *      #include <ccan/likely/likely.h>
17  *      #include <stdio.h>
18  *
19  *      int main(int argc, char *argv[])
20  *      {
21  *              // This example is silly: the compiler knows exit() is unlikely.
22  *              if (unlikely(argc == 1)) {
23  *                      fprintf(stderr, "Usage: %s <args>...\n", argv[0]);
24  *                      return 1;
25  *              }
26  *              for (argc++; argv[argc]; argc++)
27  *                      printf("%s\n", argv[argc]);
28  *              return 0;
29  *      }
30  */
31 int main(int argc, char *argv[])
32 {
33         /* Expect exactly one argument */
34         if (argc != 2)
35                 return 1;
36
37         if (strcmp(argv[1], "depends") == 0) {
38                 printf("ccan/str\n");
39                 printf("ccan/htable\n");
40                 printf("ccan/hash\n");
41                 return 0;
42         }
43
44         return 1;
45 }