util: Introduce ovs_assert macro.
[sliver-openvswitch.git] / lib / util.h
index 70f3691..b944ec7 100644 (file)
 #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.
  *