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