-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.h
36 lines (32 loc) · 915 Bytes
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdbool.h>
/** Define a proposition as likely true.
* @param prop Proposition
**/
#undef likely
#ifdef __GNUC__
#define likely(prop) \
__builtin_expect((prop) ? true : false, true /* likely \
*/)
#else
#define likely(prop) (prop)
#endif
/** Define a proposition as likely false.
* @param prop Proposition
**/
#undef unlikely
#ifdef __GNUC__
#define unlikely(prop) \
__builtin_expect((prop) ? true : false, false /* unlikely */)
#else
#define unlikely(prop) (prop)
#endif
/** Define a variable as unused.
**/
#undef unused
#ifdef __GNUC__
#define unused(variable) variable __attribute__((unused))
#else
#define unused(variable)
#warning This compiler has no support for GCC attributes
#endif
// =============