fix warnings, disable empty statement warning by default
[cparser] / adt / util.h
1 /**
2  * @file
3  * @date    16.03.2007
4  * @brief   Various utility functions that wrap compiler specific extensions
5  * @author  Matthias Braun
6  * @version $Id$
7  */
8 #ifndef _FIRM_UTIL_H_
9 #define _FIRM_UTIL_H_
10
11 /**
12  * Asserts that the constant expression x is not zero at compiletime. name has
13  * to be a unique identifier.
14  *
15  * @note This uses the fact, that double case labels are not allowed.
16  */
17 #define COMPILETIME_ASSERT(x, name)     \
18         static __attribute__((unused)) void compiletime_assert_##name (int h) { \
19                 switch(h) { case 0:     case (x): {} } \
20         }
21
22 /**
23  * Indicates to the compiler that the value of x is very likely 1
24  * @note Only use this in speed critical code and when you are sure x is often 1
25  */
26 #define LIKELY(x)   __builtin_expect((x), 1)
27 /**
28  * Indicates to the compiler that it's very likely that x is 0
29  * @note Only use this in speed critical code and when you are sure x is often 0
30  */
31 #define UNLIKELY(x) __builtin_expect((x), 0)
32
33 #endif