… | |
… | |
33 | # define is_constant(c) 0 |
33 | # define is_constant(c) 0 |
34 | # define expect(expr,value) (expr) |
34 | # define expect(expr,value) (expr) |
35 | # define prefetch(addr,rw,locality) |
35 | # define prefetch(addr,rw,locality) |
36 | #endif |
36 | #endif |
37 | |
37 | |
|
|
38 | #if __GNUC__ < 4 || (__GNUC__ == 4 || __GNUC_MINOR__ < 4) |
|
|
39 | # define decltype(x) typeof(x) |
|
|
40 | #endif |
|
|
41 | |
38 | // put into ifs if you are very sure that the expression |
42 | // put into ifs if you are very sure that the expression |
39 | // is mostly true or mosty false. note that these return |
43 | // is mostly true or mosty false. note that these return |
40 | // booleans, not the expression. |
44 | // booleans, not the expression. |
41 | #define expect_false(expr) expect ((expr) != 0, 0) |
45 | #define expect_false(expr) expect ((expr) != 0, 0) |
42 | #define expect_true(expr) expect ((expr) != 0, 1) |
46 | #define expect_true(expr) expect ((expr) != 0, 1) |
… | |
… | |
50 | |
54 | |
51 | #include <shstr.h> |
55 | #include <shstr.h> |
52 | #include <traits.h> |
56 | #include <traits.h> |
53 | |
57 | |
54 | // use a gcc extension for auto declarations until ISO C++ sanctifies them |
58 | // use a gcc extension for auto declarations until ISO C++ sanctifies them |
55 | #define auto(var,expr) typeof(expr) var = (expr) |
59 | #define auto(var,expr) decltype(expr) var = (expr) |
56 | |
60 | |
57 | // very ugly macro that basicaly declares and initialises a variable |
61 | // very ugly macro that basicaly declares and initialises a variable |
58 | // that is in scope for the next statement only |
62 | // that is in scope for the next statement only |
59 | // works only for stuff that can be assigned 0 and converts to false |
63 | // works only for stuff that can be assigned 0 and converts to false |
60 | // (note: works great for pointers) |
64 | // (note: works great for pointers) |