Without this, it's a trivial header.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* help you annotate rare paths in your code for the convenience of the
* compiler and the reader.
*
* help you annotate rare paths in your code for the convenience of the
* compiler and the reader.
*
+ * With CCAN_LIKELY_DEBUG defined, it provides statistics for each
+ * likely()/unlikely() call.
+ *
* License: LGPL (v2.1 or any later version)
* Author: Rusty Russell <rusty@rustcorp.com.au>
*
* License: LGPL (v2.1 or any later version)
* Author: Rusty Russell <rusty@rustcorp.com.au>
*
return 1;
if (strcmp(argv[1], "depends") == 0) {
return 1;
if (strcmp(argv[1], "depends") == 0) {
+#ifdef CCAN_LIKELY_DEBUG
printf("ccan/str\n");
printf("ccan/htable\n");
printf("ccan/hash\n");
printf("ccan/str\n");
printf("ccan/htable\n");
printf("ccan/hash\n");
+#endif
+ return 0;
+ }
+ if (strcmp(argv[1], "testdepends") == 0) {
+#ifndef CCAN_LIKELY_DEBUG
+ printf("ccan/str\n");
+ printf("ccan/htable\n");
+ printf("ccan/hash\n");
+#endif
#ifndef CCAN_LIKELY_H
#define CCAN_LIKELY_H
#include "config.h"
#ifndef CCAN_LIKELY_H
#define CCAN_LIKELY_H
#include "config.h"
-#include <ccan/str/str.h>
#include <stdbool.h>
#ifndef CCAN_LIKELY_DEBUG
#include <stdbool.h>
#ifndef CCAN_LIKELY_DEBUG
#define unlikely(cond) (!!(cond))
#endif
#else /* CCAN_LIKELY_DEBUG versions */
#define unlikely(cond) (!!(cond))
#endif
#else /* CCAN_LIKELY_DEBUG versions */
+#include <ccan/str/str.h>
+
#define likely(cond) \
(_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__))
#define unlikely(cond) \
#define likely(cond) \
(_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__))
#define unlikely(cond) \
long _likely_trace(bool cond, bool expect,
const char *condstr,
const char *file, unsigned int line);
long _likely_trace(bool cond, bool expect,
const char *condstr,
const char *file, unsigned int line);
-#endif
-
-#ifdef CCAN_LIKELY_DEBUG
/**
* likely_stats - return description of abused likely()/unlikely()
* @min_hits: minimum number of hits
/**
* likely_stats - return description of abused likely()/unlikely()
* @min_hits: minimum number of hits
+
+/* Fools ccanlint: it doesn't think we use str, htable or hash. */
+#include <ccan/hash/hash.h>
+#include <ccan/htable/htable.h>
+#include <ccan/str/str.h>