From b88e0c40b777480e101a7524697656d6a03fb563 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 31 Aug 2011 13:57:14 +0930 Subject: ccan: fix likely redefinition warnings with --enable-tdb2 When we do --enable-tdb2, we start clashing with the replace.h version: In file included from ../lib/tdb2/tools/../private.h:25:0, from ../lib/tdb2/tools/tdb2torture.c:60: ../lib/ccan/likely/likely.h:32:0: warning: "likely" redefined ../lib/replace/replace.h:762:0: note: this is the location of the previous definition ../lib/ccan/likely/likely.h:53:0: warning: "unlikely" redefined ../lib/replace/replace.h:765:0: note: this is the location of the previous definition I don't like to #ifndef-protect them in general, since you don't want different parts of the code to silently have different definitions, but it's the simplest fix for now. Signed-off-by: Rusty Russell --- lib/ccan/likely/likely.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/ccan') diff --git a/lib/ccan/likely/likely.h b/lib/ccan/likely/likely.h index c43d276759..3a9c6d4640 100644 --- a/lib/ccan/likely/likely.h +++ b/lib/ccan/likely/likely.h @@ -30,7 +30,9 @@ * return false; * } */ +#ifndef likely #define likely(cond) __builtin_expect(!!(cond), 1) +#endif /** * unlikely - indicate that a condition is unlikely to be true. @@ -51,11 +53,17 @@ * fprintf(stderr, "Overflow!"); * } */ +#ifndef unlikely #define unlikely(cond) __builtin_expect(!!(cond), 0) +#endif #else +#ifndef likely #define likely(cond) (!!(cond)) +#endif +#ifndef unlikely #define unlikely(cond) (!!(cond)) #endif +#endif #else /* CCAN_LIKELY_DEBUG versions */ #define likely(cond) \ (_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__)) -- cgit