Undefine static_assert() in parlib/rassert.h
[akaros.git] / user / parlib / include / rassert.h
1 /* See COPYRIGHT for copyright information. */
2
3 #ifndef PARLIB_RASSERT_H
4 #define PARLIB_RASSERT_H
5
6 #include <assert.h>
7 #include <parlib/vcore.h>
8 #include <parlib/ros_debug.h>
9
10 __BEGIN_DECLS
11
12 #undef assert
13 #undef static_assert
14
15 void _warn(const char*, int, const char*, ...);
16 void _panic(const char*, int, const char*, ...) __attribute__((noreturn));
17
18 #define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__)
19 #define panic(...) _panic(__FILE__, __LINE__, __VA_ARGS__)
20
21 #define assert(x)                                                                  \
22         do {                                                                       \
23                 if (!(x)) {                                                            \
24                         ros_debug("[user] %s:%d, vcore %d, Assertion failed: %s\n",        \
25                                   __FILE__, __LINE__, vcore_id(), #x);                     \
26                         breakpoint();                                                      \
27                         abort();                                                           \
28                 }                                                                      \
29         } while (0)
30
31 // static_assert(x) will generate a compile-time error if 'x' is false.
32 #define static_assert(x)        switch (x) case 0: case (x):
33
34 __END_DECLS
35
36 #endif /* PARLIB_RASSERT_H */