]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c++/util/assert.h
minor orb stuff
[polintos/scott/priv.git] / include / c++ / util / assert.h
1 #ifndef _UTIL_ASSERT_H
2 #define _UTIL_ASSERT_H
3
4 #ifndef _UTIL_ASSERT_LEVEL
5 #define _UTIL_ASSERT_LEVEL 1
6 #endif
7
8 namespace Assert {
9         enum {
10                 Always = 0,
11                 Normal = 1,
12                 Excessive = 2
13         };
14
15         static inline void __attribute__((always_inline))
16         do_assert(const char *file, int line, bool condition, int level)
17         {
18                 void level_must_be_const();
19         
20                 if (!__builtin_constant_p(level))
21                         level_must_be_const();
22                 
23                 if (level <= _UTIL_ASSERT_LEVEL && __builtin_expect(!condition, 0))
24                         assert_failure(file, line);
25         }
26 }
27
28 #define assertl(cond, level) (::Assert::do_assert(__FILE__, __LINE__, cond, level))
29 #define BUG() assertl(0, ::Assert::Always)
30
31 #endif