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.
This commit is contained in:
Niels Martin Hansen 2008-07-04 01:05:16 +00:00
parent d14d6b4b36
commit a4fc3e8b13

View file

@ -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