From 278b7d75445f15b13e4d78ad1f07ffc338272deb Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 21 Sep 2005 09:43:32 +0000 Subject: [PATCH] Better cross platform compatibility. --- src/MultiPlayer/tiny_xdr.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MultiPlayer/tiny_xdr.hpp b/src/MultiPlayer/tiny_xdr.hpp index 5d4d97de4..4db48604b 100644 --- a/src/MultiPlayer/tiny_xdr.hpp +++ b/src/MultiPlayer/tiny_xdr.hpp @@ -56,14 +56,16 @@ inline uint32_t bswap_32(unsigned int b) { return x; } -inline uint64_t bswap_64(unsigned long long b) { -#if __WORDSIZE == 64 +#if (SIZEOF_LONG_INT == 8) +inline uint64_t bswap_64(unsigned long int b) { uint64_t x = b; x = ((x >> 8) & 0x00FF00FF00FF00FFLL) | ((x << 8) & 0xFF00FF00FF00FF00LL); x = ((x >> 16) & 0x0000FFFF0000FFFFLL) | ((x << 16) & 0xFFFF0000FFFF0000LL); x = (x >> 32) | (x << 32); return x; +} #else +inline uint64_t bswap_64(unsigned long long int b) { union { uint64_t ll; uint32_t l[2]; @@ -72,8 +74,8 @@ inline uint64_t bswap_64(unsigned long long b) { r.l[0] = bswap_32 (w.l[1]); r.l[1] = bswap_32 (w.l[0]); return r.ll; -#endif } +#endif #if BYTE_ORDER == BIG_ENDIAN # define SWAP32(arg) arg