summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-11-15 12:56:08 +1030
committerRusty Russell <rusty@rustcorp.com.au>2012-11-15 12:56:08 +1030
commit8a83d6d131babba276fb602648f88b9e7e00cf58 (patch)
treef1e8711dc5f61ca215ca919a38fcc097594a4969
parentcf4e2150325ebab7798c23110d80ff52467b4fc7 (diff)
likely: make dependencies correctly conditional on CCAN_LIKELY_DEBUG.
Without this, it's a trivial header. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--ccan/likely/_info14
-rw-r--r--ccan/likely/likely.h6
-rw-r--r--ccan/likely/test/run-debug.c5
3 files changed, 20 insertions, 5 deletions
diff --git a/ccan/likely/_info b/ccan/likely/_info
index 252169b3..ac43cc2b 100644
--- a/ccan/likely/_info
+++ b/ccan/likely/_info
@@ -9,6 +9,9 @@
* 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>
*
@@ -35,11 +38,20 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
+#ifdef CCAN_LIKELY_DEBUG
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
return 0;
}
-
return 1;
}
diff --git a/ccan/likely/likely.h b/ccan/likely/likely.h
index 410772db..8683a2c9 100644
--- a/ccan/likely/likely.h
+++ b/ccan/likely/likely.h
@@ -2,7 +2,6 @@
#ifndef CCAN_LIKELY_H
#define CCAN_LIKELY_H
#include "config.h"
-#include <ccan/str/str.h>
#include <stdbool.h>
#ifndef CCAN_LIKELY_DEBUG
@@ -57,6 +56,8 @@
#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) \
@@ -65,9 +66,6 @@
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
diff --git a/ccan/likely/test/run-debug.c b/ccan/likely/test/run-debug.c
index afb21e2b..83f22afa 100644
--- a/ccan/likely/test/run-debug.c
+++ b/ccan/likely/test/run-debug.c
@@ -98,3 +98,8 @@ int main(int argc, char *argv[])
exit(exit_status());
}
+
+/* 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>