ref: d6aa4b3e1d81f48ef67f0b47ad09dbbe2a6964a9
parent: 10655c15c4d96dc52679a4f0f66ccb2d94c9a277
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue Sep 10 05:52:17 EDT 2019
Fix compilation with GCC <= 4.7.3 Thanks @ccawley2011 and @lordmulder for the solution in FAAD2, from which I have taken this, and @zvezdochiot for requesting this for FAAC. Fixes #26
--- a/frontend/mp4write.c
+++ b/frontend/mp4write.c
@@ -54,9 +54,14 @@
static inline uint32_t be32(uint32_t u32)
{
#ifndef WORDS_BIGENDIAN
- //return __bswap_32(u32);
+#if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
return __builtin_bswap32(u32);
+#elif defined (_MSC_VER)
+ return _byteswap_ulong(u32);
#else
+ return (u32 << 24) | ((u32 << 8) & 0xFF0000) | ((u32 >> 8) & 0xFF00) | (u32 >> 24);
+#endif
+#else
return u32;
#endif
}
@@ -64,8 +69,13 @@
static inline uint16_t be16(uint16_t u16)
{
#ifndef WORDS_BIGENDIAN
- //return __bswap_16(u16);
+#if defined (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))
return __builtin_bswap16(u16);
+#elif defined (_MSC_VER)
+ return _byteswap_ushort(u16);
+#else
+ return (u16 << 8) | (u16 >> 8);
+#endif
#else
return u16;
#endif
--- a/project/msvc/unistd.h
+++ b/project/msvc/unistd.h
@@ -5,6 +5,3 @@
#define W_OK 2
#define access _access
-
-#define __builtin_bswap32 _byteswap_ulong
-#define __builtin_bswap16 _byteswap_ushort