summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-09-02 21:11:48 +0000
committersmatz <smatz@openttd.org>2008-09-02 21:11:48 +0000
commitc620d5e5f066e62cf23197d16e40a07c41e2d9f8 (patch)
treea05da0e1f818ddb1f99e7d038379fa2c9e08b1d5 /src
parenta482f0053d4920359b7a010fbc47fcb3c5b0f13b (diff)
downloadopenttd-c620d5e5f066e62cf23197d16e40a07c41e2d9f8.tar.xz
(svn r14232) -Codechange: use builtin for byte swapping for gcc >= 4.3
Diffstat (limited to 'src')
-rw-r--r--src/core/bitmath_func.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp
index 6abcdcb80..27168e821 100644
--- a/src/core/bitmath_func.hpp
+++ b/src/core/bitmath_func.hpp
@@ -318,7 +318,12 @@ static FORCEINLINE T ROR(const T x, const uint8 n)
*/
static FORCEINLINE uint32 BSWAP32(uint32 x)
{
+#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3))
+ /* GCC >= 4.3 provides a builtin, resulting in faster code */
+ return (uint32)__builtin_bswap32((int32)x);
+#else
return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000);
+#endif /* defined(__GNUC__) */
}
/**