/* See COPYRIGHT for copyright information. */
-#ifndef ROS_INC_ASSERT_H
-#define ROS_INC_ASSERT_H
+#pragma once
-void ( _warn)(const char* NTS, int, const char* NTS, ...);
-void ( _panic)(const char* NTS, int, const char* NTS, ...)
+#include <compiler.h>
+
+void ( _warn)(const char *, int, const char *, ...);
+void ( _panic)(const char *, int, const char *, ...)
__attribute__((noreturn));
#define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__)
#define exhausted(...) _panic(__FILE__, __LINE__, __VA_ARGS__)
#define assert(x) \
- do { if (!(x)) panic("assertion failed: %s", #x); } while (0)
+ do { if (unlikely(!(x))) panic("assertion failed: %s", #x); } while (0)
+
+#define error_assert(e, x) \
+ do { if (unlikely(!(x))) error(e, "Assertion failed: " #x); } while (0)
// static_assert(x) will generate a compile-time error if 'x' is false.
#define static_assert(x) switch (x) case 0: case (x):
#else
#define dassert(x) ((void) (x)) // 'Use' value, stop compile warnings
#endif /* DEVELOPMENT_ASSERTIONS */
-
-#endif /* !ROS_INC_ASSERT_H */