From a4fc3e8b1344ea48ec701b282dc70c02c0555c37 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 4 Jul 2008 01:05:16 +0000 Subject: [PATCH] Use compiler-specific defines when building universal for OS X to detect correct endianness and avoid using dynamic endian code for no reason. Originally committed to SVN as r2230. --- aegisub/aegisub_endian.h | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/aegisub/aegisub_endian.h b/aegisub/aegisub_endian.h index 3a4f45ce4..ecea19f3a 100644 --- a/aegisub/aegisub_endian.h +++ b/aegisub/aegisub_endian.h @@ -41,17 +41,31 @@ // Sanity check #ifndef HAVE_LITTLE_ENDIAN -#ifndef HAVE_BIG_ENDIAN -#ifndef HAVE_DYNAMIC_ENDIAN -#define HAVE_DYNAMIC_ENDIAN -#endif -#endif -#endif +# ifndef HAVE_BIG_ENDIAN +// We neither have big nor little endian from configuration +# ifdef HAVE_UNIVERSAL_ENDIAN +// But this is an OS X system building a universal binary +// Apple's GCC defines _BIG_ENDIAN when building for PPC +# ifdef _BIG_ENDIAN +# define HAVE_BIG_ENDIAN +# else +# define HAVE_LITTLE_ENDIAN +# endif +# undef HAVE_DYNAMIC_ENDIAN +# else // !HAVE_UNIVERSAL_ENDIAN +// We aren't building an OS X universal binary +// Use the dynamic endian code +# ifndef HAVE_DYNAMIC_ENDIAN +# define HAVE_DYNAMIC_ENDIAN +# endif +# endif //HAVE_UNIVERSAL_ENDIAN +# endif // HAVE_BIG_ENDIAN +#endif // HAVE_LITTLE_ENDIAN #ifdef HAVE_LITTLE_ENDIAN -#ifdef HAVE_BIG_ENDIAN -#error You cannot have both HAVE_LITTLE_ENDIAN and HAVE_BIG_ENDIAN defined at the same time -#endif +# ifdef HAVE_BIG_ENDIAN +# error You cannot have both HAVE_LITTLE_ENDIAN and HAVE_BIG_ENDIAN defined at the same time +# endif #endif