Remove redundant void argument list in function def
[openal-soft.git] / common / opthelpers.h
blobb496942c31d10fea2d37c19627dad55481907b89
1 #ifndef OPTHELPERS_H
2 #define OPTHELPERS_H
4 #ifdef __has_builtin
5 #define HAS_BUILTIN __has_builtin
6 #else
7 #define HAS_BUILTIN(x) (0)
8 #endif
10 #ifdef __GNUC__
11 /* LIKELY optimizes the case where the condition is true. The condition is not
12 * required to be true, but it can result in more optimal code for the true
13 * path at the expense of a less optimal false path.
15 #define LIKELY(x) __builtin_expect(!!(x), !0)
16 /* The opposite of LIKELY, optimizing the case where the condition is false. */
17 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
18 /* Unlike LIKELY, ASSUME requires the condition to be true or else it invokes
19 * undefined behavior. It's essentially an assert without actually checking the
20 * condition at run-time, allowing for stronger optimizations than LIKELY.
22 #if HAS_BUILTIN(__builtin_assume)
23 #define ASSUME __builtin_assume
24 #else
25 #define ASSUME(x) do { if(!(x)) __builtin_unreachable(); } while(0)
26 #endif
28 #else /* __GNUC__ */
30 #define LIKELY(x) (!!(x))
31 #define UNLIKELY(x) (!!(x))
32 #ifdef _MSC_VER
33 #define ASSUME __assume
34 #else
35 #define ASSUME(x) ((void)0)
36 #endif /* _MSC_VER */
37 #endif /* __GNUC__ */
39 #endif /* OPTHELPERS_H */