… | |
… | |
2 | #define UTIL_H__ |
2 | #define UTIL_H__ |
3 | |
3 | |
4 | //#define PREFER_MALLOC |
4 | //#define PREFER_MALLOC |
5 | |
5 | |
6 | #if __GNUC__ >= 3 |
6 | #if __GNUC__ >= 3 |
7 | # define is_constant(c) __builtin_constant_p (c) |
7 | # define is_constant(c) __builtin_constant_p (c) |
|
|
8 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
|
|
9 | # define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
8 | #else |
10 | #else |
9 | # define is_constant(c) 0 |
11 | # define is_constant(c) 0 |
|
|
12 | # define expect(expr,value) (expr) |
|
|
13 | # define prefetch(addr,rw,locality) |
10 | #endif |
14 | #endif |
|
|
15 | |
|
|
16 | // put into ifs if you are very sure that the expression |
|
|
17 | // is mostly true or mosty false. note that these return |
|
|
18 | // booleans, not the expression. |
|
|
19 | #define expect_false(expr) expect ((expr) != 0, 0) |
|
|
20 | #define expect_true(expr) expect ((expr) != 0, 1) |
11 | |
21 | |
12 | #include <cstddef> |
22 | #include <cstddef> |
13 | #include <cmath> |
23 | #include <cmath> |
14 | #include <new> |
24 | #include <new> |
15 | #include <vector> |
25 | #include <vector> |