1 |
root |
1.1 |
/* |
2 |
|
|
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
|
|
* |
4 |
|
|
* Copyright (©) 2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
|
|
* |
6 |
|
|
* Deliantra is free software: you can redistribute it and/or modify it under |
7 |
|
|
* the terms of the Affero GNU General Public License as published by the |
8 |
|
|
* Free Software Foundation, either version 3 of the License, or (at your |
9 |
|
|
* option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the Affero GNU General Public License |
17 |
|
|
* and the GNU General Public License along with this program. If not, see |
18 |
|
|
* <http://www.gnu.org/licenses/>. |
19 |
|
|
* |
20 |
|
|
* The authors can be reached via e-mail to <support@deliantra.net> |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#ifndef COMPILER_H |
24 |
|
|
#define COMPILER_H |
25 |
|
|
|
26 |
|
|
#if __GNUC__ >= 3 |
27 |
|
|
# define attribute(attrlist) __attribute__(attrlist) |
28 |
|
|
#else |
29 |
|
|
# define attribute(attrlist) |
30 |
|
|
#endif |
31 |
|
|
|
32 |
|
|
#if __GNUC__ >= 3 |
33 |
|
|
# define is_constant(c) __builtin_constant_p (c) |
34 |
|
|
# define expect(expr,value) __builtin_expect ((expr),(value)) |
35 |
|
|
# define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
36 |
|
|
# define noinline __attribute__((__noinline__)) |
37 |
|
|
#else |
38 |
|
|
# define is_constant(c) 0 |
39 |
|
|
# define expect(expr,value) (expr) |
40 |
|
|
# define prefetch(addr,rw,locality) |
41 |
|
|
# define noinline |
42 |
|
|
#endif |
43 |
|
|
|
44 |
|
|
#if __GNUC__ < 4 || (__GNUC__ == 4 || __GNUC_MINOR__ < 4) |
45 |
|
|
# define decltype(x) typeof(x) |
46 |
|
|
#endif |
47 |
|
|
|
48 |
|
|
// put into ifs if you are very sure that the expression |
49 |
|
|
// is mostly true or mosty false. note that these return |
50 |
|
|
// booleans, not the expression. |
51 |
|
|
#define expect_false(expr) expect ((expr) ? 1 : 0, 0) |
52 |
|
|
#define expect_true(expr) expect ((expr) ? 1 : 0, 1) |
53 |
|
|
|
54 |
|
|
#endif |
55 |
|
|
|