From 5f5d7ba1b07d22c44730c26f0858704d332bb2d2 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 4 Jul 2018 18:27:36 +0200 Subject: [PATCH] win32 : fix byteswapping function for MSVC/gcc --- src/fileformats.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fileformats.c b/src/fileformats.c index c180d139..0fb03133 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -57,11 +57,16 @@ #include +#if defined(WIN32) #if defined(_MSC_VER) #include #if _MSC_VER < 1900 #define snprintf _snprintf #endif +#define WIN32_BSWAP32 _byteswap_ulong +#else +#define WIN32_BSWAP32 __builtin_bswap32 +#endif #endif #if !defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2) @@ -1820,7 +1825,7 @@ void Load_IFF(T_IO_Context * context) #elif defined(WIN32) // assume WIN32 is little endian for (i = 0 ; i < ((LineCount + 31) >> 5); i++) - lineBitMask[i] = __builtin_bswap32(lineBitMask[i]); + lineBitMask[i] = WIN32_BSWAP32(lineBitMask[i]); #endif data = (const byte *)PCHGData + ((LineCount + 31) >> 5) * 4; for (y_pos = 0 ; y_pos < LineCount; y_pos++)