X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Flikely%2Flikely.h;h=a8f003d72777bf884dbd9831c30eb0b0f0a2ae94;hb=78158c87e37ce3b41cd5145e29baea38fd002374;hp=5e4fc831c960dbe09d480fbc20182c596e3703f6;hpb=74257cee33ae3033f961d5f22a0313b8cb1b18d4;p=ccan diff --git a/ccan/likely/likely.h b/ccan/likely/likely.h index 5e4fc831..a8f003d7 100644 --- a/ccan/likely/likely.h +++ b/ccan/likely/likely.h @@ -1,8 +1,7 @@ -/* Licensed under LGPLv2.1+ - see LICENSE file for details */ +/* CC0 (Public domain) - see LICENSE file for details */ #ifndef CCAN_LIKELY_H #define CCAN_LIKELY_H #include "config.h" -#include #include #ifndef CCAN_LIKELY_DEBUG @@ -57,6 +56,8 @@ #define unlikely(cond) (!!(cond)) #endif #else /* CCAN_LIKELY_DEBUG versions */ +#include + #define likely(cond) \ (_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__)) #define unlikely(cond) \ @@ -65,16 +66,13 @@ 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 * @percent: maximum percentage correct * * When CCAN_LIKELY_DEBUG is defined, likely() and unlikely() trace their - * results: this causes a significant slowdown, but allows analysis of + * 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 @@ -101,6 +99,13 @@ long _likely_trace(bool cond, bool expect, * #endif * } */ -const char *likely_stats(unsigned int min_hits, unsigned int percent); +char *likely_stats(unsigned int min_hits, unsigned int percent); + +/** + * likely_stats_reset - free up memory of likely()/unlikely() branches. + * + * This can also plug memory leaks. + */ +void likely_stats_reset(void); #endif /* CCAN_LIKELY_DEBUG */ #endif /* CCAN_LIKELY_H */