X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Futil.h;h=f5589e35b5a3dcae1a21be78c58e5df9cdb8054f;hb=825da1c6d1c7b9bc5128d7588b8bad6efaae650e;hp=70f36919a5bd0d645225902a10476bf24fe18a4a;hpb=35bedb6171b62dd528e01dbeb8943bb841365bf5;p=sliver-openvswitch.git diff --git a/lib/util.h b/lib/util.h index 70f36919a..f5589e35b 100644 --- a/lib/util.h +++ b/lib/util.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "compiler.h" @@ -62,6 +63,17 @@ #define BUILD_ASSERT_DECL_GCCONLY(EXPR) ((void) 0) #endif +/* Like the standard assert macro, except: + * + * - Writes the failure message to the log. + * + * - Not affected by NDEBUG. */ +#define ovs_assert(CONDITION) \ + if (!OVS_LIKELY(CONDITION)) { \ + ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION); \ + } +void ovs_assert_failure(const char *, const char *, const char *) NO_RETURN; + /* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes * anything other than an outermost "const" or "volatile" qualifier. * @@ -254,7 +266,7 @@ ctz(uint32_t n) int log_2_floor(uint32_t); int log_2_ceil(uint32_t); -int popcount(uint32_t); +unsigned int popcount(uint32_t); /* Returns the rightmost 1-bit in 'x' (e.g. 01011000 => 00001000), or 0 if 'x' * is 0. */