6 * likely - macros for annotating likely/unlikely branches in the code
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.
12 * With CCAN_LIKELY_DEBUG defined, it provides statistics for each
13 * likely()/unlikely() call (but note that this requires LGPL dependencies).
15 * License: CC0 (Public domain)
16 * Author: Rusty Russell <rusty@rustcorp.com.au>
19 * #include <ccan/likely/likely.h>
22 * int main(int argc, char *argv[])
24 * // This example is silly: the compiler knows exit() is unlikely.
25 * if (unlikely(argc == 1)) {
26 * fprintf(stderr, "Usage: %s <args>...\n", argv[0]);
29 * for (argc++; argv[argc]; argc++)
30 * printf("%s\n", argv[argc]);
34 int main(int argc, char *argv[])
36 /* Expect exactly one argument */
40 if (strcmp(argv[1], "depends") == 0) {
41 #ifdef CCAN_LIKELY_DEBUG
43 printf("ccan/htable\n");
44 printf("ccan/hash\n");
48 if (strcmp(argv[1], "testdepends") == 0) {
49 #ifndef CCAN_LIKELY_DEBUG
51 printf("ccan/htable\n");
52 printf("ccan/hash\n");