From fc00f14087f911da23d1d89e02705c498447db22 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 24 Feb 2011 15:39:32 +1030 Subject: [PATCH] jmap,likely,tdb2: use CCAN__DEBUG instead of DEBUG. Samba (for example) uses a DEBUG() macro, which triggers these heuristics. Better to make it per-module anyway. --- ccan/jmap/jmap.h | 10 +++++----- ccan/jmap/test/run.c | 2 +- ccan/likely/likely.c | 4 ++-- ccan/likely/likely.h | 16 ++++++++-------- ccan/likely/test/run-debug.c | 2 +- ccan/tdb2/free.c | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ccan/jmap/jmap.h b/ccan/jmap/jmap.h index cfa2e26c..f1b2f038 100644 --- a/ccan/jmap/jmap.h +++ b/ccan/jmap/jmap.h @@ -6,7 +6,7 @@ #include #include #include -#ifdef DEBUG +#ifdef CCAN_JMAP_DEBUG #include #endif @@ -39,7 +39,7 @@ struct jmap { const char *errstr; /* Used if !NDEBUG */ int num_accesses; - /* Used if DEBUG */ + /* Used if CCAN_JMAP_DEBUG */ unsigned long *acc_value; unsigned long acc_index; const char *funcname; @@ -52,7 +52,7 @@ static inline void jmap_debug_add_access(const struct jmap *map, unsigned long *val, const char *funcname) { -#ifdef DEBUG +#ifdef CCAN_JMAP_DEBUG if (!map->acc_value) { ((struct jmap *)map)->acc_value = val; ((struct jmap *)map)->acc_index = index; @@ -66,7 +66,7 @@ static inline void jmap_debug_add_access(const struct jmap *map, static inline void jmap_debug_del_access(struct jmap *map, unsigned long **val) { assert(--map->num_accesses >= 0); -#ifdef DEBUG +#ifdef CCAN_JMAP_DEBUG if (map->acc_value == *val) map->acc_value = NULL; #endif @@ -76,7 +76,7 @@ static inline void jmap_debug_del_access(struct jmap *map, unsigned long **val) static inline void jmap_debug_access(struct jmap *map) { -#ifdef DEBUG +#ifdef CCAN_JMAP_DEBUG if (map->num_accesses && map->acc_value) fprintf(stderr, "jmap: still got index %lu, val %lu (%p) from %s\n", diff --git a/ccan/jmap/test/run.c b/ccan/jmap/test/run.c index 5f5c932f..e2c72ae3 100644 --- a/ccan/jmap/test/run.c +++ b/ccan/jmap/test/run.c @@ -1,5 +1,5 @@ #include -#define DEBUG +#define CCAN_JMAP_DEBUG #include int main(int argc, char *argv[]) diff --git a/ccan/likely/likely.c b/ccan/likely/likely.c index 1bdc1b1a..8893d0b6 100644 --- a/ccan/likely/likely.c +++ b/ccan/likely/likely.c @@ -1,4 +1,4 @@ -#ifdef DEBUG +#ifdef CCAN_LIKELY_DEBUG #include #include #include @@ -138,4 +138,4 @@ const char *likely_stats(unsigned int min_hits, unsigned int percent) return ret; } -#endif /*DEBUG*/ +#endif /*CCAN_LIKELY_DEBUG*/ diff --git a/ccan/likely/likely.h b/ccan/likely/likely.h index 137cb861..0fad89c4 100644 --- a/ccan/likely/likely.h +++ b/ccan/likely/likely.h @@ -4,7 +4,7 @@ #include #include -#ifndef DEBUG +#ifndef CCAN_LIKELY_DEBUG #if HAVE_BUILTIN_EXPECT /** * likely - indicate that a condition is likely to be true. @@ -55,7 +55,7 @@ #define likely(cond) (!!(cond)) #define unlikely(cond) (!!(cond)) #endif -#else /* DEBUG versions */ +#else /* CCAN_LIKELY_DEBUG versions */ #define likely(cond) \ (_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__)) #define unlikely(cond) \ @@ -66,15 +66,15 @@ long _likely_trace(bool cond, bool expect, const char *file, unsigned int line); #endif -#ifdef DEBUG +#ifdef CCAN_LIKELY_DEBUG /** * likely_stats - return description of abused likely()/unlikely() * @min_hits: minimum number of hits * @percent: maximum percentage correct * - * When DEBUG is defined, likely() and unlikely() trace their results: this - * causes a significant slowdown, but allows analysis of whether the stats - * are correct. + * When CCAN_LIKELY_DEBUG is defined, likely() and unlikely() trace their + * results: this causes a significant slowdown, but allows analysis of + * whether the branches are labelled correctly. * * This function returns a malloc'ed description of the least-correct * usage of likely() or unlikely(). It ignores places which have been @@ -90,7 +90,7 @@ long _likely_trace(bool cond, bool expect, * // Print every place hit more than twice which was wrong > 5%. * static void report_stats(void) * { - * #ifdef DEBUG + * #ifdef CCAN_LIKELY_DEBUG * const char *bad; * * while ((bad = likely_stats(2, 95)) != NULL) { @@ -101,5 +101,5 @@ long _likely_trace(bool cond, bool expect, * } */ const char *likely_stats(unsigned int min_hits, unsigned int percent); -#endif /* DEBUG */ +#endif /* CCAN_LIKELY_DEBUG */ #endif /* CCAN_LIKELY_H */ diff --git a/ccan/likely/test/run-debug.c b/ccan/likely/test/run-debug.c index 198ac5b7..df786192 100644 --- a/ccan/likely/test/run-debug.c +++ b/ccan/likely/test/run-debug.c @@ -1,4 +1,4 @@ -#define DEBUG 1 +#define CCAN_LIKELY_DEBUG 1 #include #include #include diff --git a/ccan/tdb2/free.c b/ccan/tdb2/free.c index 5d1bd3c6..ba14dfcd 100644 --- a/ccan/tdb2/free.c +++ b/ccan/tdb2/free.c @@ -116,7 +116,7 @@ static int remove_from_list(struct tdb_context *tdb, off = frec_prev(r) + offsetof(struct tdb_free_record, next); } -#ifdef DEBUG +#ifdef CCAN_TDB2_DEBUG if (tdb_read_off(tdb, off) != r_off) { tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL, "remove_from_list: %llu bad prev in list %llu", @@ -134,7 +134,7 @@ static int remove_from_list(struct tdb_context *tdb, off = r->next + offsetof(struct tdb_free_record,magic_and_prev); /* r->next->prev = r->prev */ -#ifdef DEBUG +#ifdef CCAN_TDB2_DEBUG if (tdb_read_off(tdb, off) & TDB_OFF_MASK != r_off) { tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL, "remove_from_list: %llu bad list %llu", @@ -171,7 +171,7 @@ static int enqueue_in_free(struct tdb_context *tdb, return -1; if (new.next) { -#ifdef DEBUG +#ifdef CCAN_TDB2_DEBUG if (tdb_read_off(tdb, new.next + offsetof(struct tdb_free_record, magic_and_prev)) -- 2.39.2