summaryrefslogtreecommitdiff
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
commit5c6a23f8fab214f3b8587fd69c61a5e4d4e84de1 (patch)
treea05da0e1f818ddb1f99e7d038379fa2c9e08b1d5
parent660f6a232006916b4b0653ce838172f0634e2525 (diff)
downloadopenttd-5c6a23f8fab214f3b8587fd69c61a5e4d4e84de1.tar.xz
(svn r14232) -Codechange: use builtin for byte swapping for gcc >= 4.3
-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__) */
}
/**