/* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * * Copyright (©) 2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . * * The authors can be reached via e-mail to */ #ifndef COMPILER_H #define COMPILER_H #if __GNUC__ >= 3 # define attribute(attrlist) __attribute__(attrlist) #else # define attribute(attrlist) #endif #if __GNUC__ >= 3 # define is_constant(c) __builtin_constant_p (c) # define expect(expr,value) __builtin_expect ((expr),(value)) # define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) # define noinline __attribute__((__noinline__)) #else # define is_constant(c) 0 # define expect(expr,value) (expr) # define prefetch(addr,rw,locality) # define noinline #endif #if __GNUC__ < 4 || (__GNUC__ == 4 || __GNUC_MINOR__ < 4) # define decltype(x) typeof(x) #endif // put into ifs if you are very sure that the expression // is mostly true or mosty false. note that these return // booleans, not the expression. #define expect_false(expr) expect ((expr) ? 1 : 0, 0) #define expect_true(expr) expect ((expr) ? 1 : 0, 1) #endif