From e9d4fb0cdf69561dfe1824b67b2a2c6f6330b797 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 30 Dec 2005 14:30:39 +0000 Subject: [PATCH] machine/endian.h is getting picked up on OS X with gcc 4.0 but no endian.h exists. --- stepmania/src/archutils/Darwin/arch_setup.h | 60 ++++++++++++++------- stepmania/src/global.h | 2 + 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/stepmania/src/archutils/Darwin/arch_setup.h b/stepmania/src/archutils/Darwin/arch_setup.h index 253f643471..d758ff3d46 100644 --- a/stepmania/src/archutils/Darwin/arch_setup.h +++ b/stepmania/src/archutils/Darwin/arch_setup.h @@ -10,11 +10,8 @@ typedef signed long SInt32; typedef signed long long SInt64; typedef unsigned long long UInt64; -#define __MACTYPES__ -#include -#undef __MACTYPES__ -#define BACKTRACE_LOOKUP_METHOD_DARWIN_DYLD -#define BACKTRACE_METHOD_POWERPC_DARWIN +#include + #define HAVE_VERSION_INFO #define HAVE_CXA_DEMANGLE #define HAVE_CRYPTOPP @@ -22,14 +19,21 @@ typedef unsigned long long UInt64; #define HAVE_FFMPEG #define HAVE_SDL #define HAVE_PTHREAD_COND_TIMEDWAIT -#define CRASH_HANDLER + +/* We have which gets pulled in when we use gcc 4.0's + * but no . The definitions of LITTLE_ENDIAN, BIG_ENDIAN and end up conflicting + * even though they resolve to the same thing (bug in gcc?). */ +#define HAVE_MACHINE_ENDIAN_H + // Looking ahead to "Universal binaries." -#ifdef __BIG_ENDIAN__ +#ifdef __ppc__ # define ENDIAN_BIG +# define BACKTRACE_LOOKUP_METHOD_DARWIN_DYLD +# define BACKTRACE_METHOD_POWERPC_DARWIN +# define CRASH_HANDLER #else # define ENDIAN_LITTLE #endif -#define ENDIAN_BIG #ifndef MACOSX # define MACOSX @@ -37,43 +41,55 @@ typedef unsigned long long UInt64; #ifndef __MACOSX__ # define __MACOSX__ #endif -#define ArchSwap32(n) OSSwapInt32((n)) -#define ArchSwap24(n) (OSSwapInt32((n)) >> 8) -#define ArchSwap16(n) OSSwapInt16((n)) + +// EndianX_Swap() will use the constant swapper macro if n is a compile time constant +#define ArchSwap32(n) Endian32_Swap(n) +#define ArchSwap24(n) (Endian32_Swap(n) >> 8) +#define ArchSwap16(n) Endian16_Swap(n) #define HAVE_BYTE_SWAPS #include -#if ! _GLIBCPP_HAVE_POWF +// This is very annoying. The 10.2.8 SDK uses GLIBCPP but the 10.4u SDK uses GLIBCXX +#if __GLIBCPP__ +# define GLIB_PREFIX _GLIBCPP_ +#elif __GLIBCXX__ +# define GLIB_PREFIX _GLIBCXX_ +#else +# error Neither __GLIBCPP__ nor __GLIBCXX__ was defined. +#endif +#define CHECK(x) (GLIB_PREFIX ## x) + +#if ! CHECK(HAVE_POWF) # define NEED_POWF #endif -#if ! _GLIBCPP_HAVE_SQRTF +#if ! CHECK(HAVE_SQRTF) # define NEED_SQRTF #endif -#if ! _GLIBCPP_HAVE_SINF +#if ! CHECK(HAVE_SINF) # define NEED_SINF #endif -#if ! _GLIBCPP_HAVE_TANF +#if ! CHECK(HAVE_TANF) # define NEED_TANF #endif -#if ! _GLIBCPP_HAVE_COSF +#if ! CHECK(HAVE_COSF) # define NEED_COSF #endif -#if ! _GLIBCPP_HAVE_ACOSF +#if ! CHECK(HAVE_ACOSF) # define NEED_ACOSF #endif -#if ! _GLIBCPP_HAVE_STRTOF +#if ! CHECK(HAVE_STRTOF) # define NEED_STRTOF #endif // Define the work around if needed. #include -#if _GLIBCPP_USE_C99 +#if CHECK(USE_C99) # define NEED_CSTDLIB_WORKAROUND #else inline int64_t llabs( int64_t x ) { return x < 0LL ? -x : x; } @@ -103,7 +119,7 @@ typedef int socklen_t; __isnan ( x ) ) #endif -#if ! _GLIBCPP_USE_WCHAR_T +#if ! CHECK(USE_WCHAR_T) #include extern "C" @@ -174,6 +190,10 @@ namespace std } #endif +// Cleanup macros +#undef GLIB_PREFIX +#undef CHECK + #endif /* diff --git a/stepmania/src/global.h b/stepmania/src/global.h index 611d71b656..e5837e5fb5 100644 --- a/stepmania/src/global.h +++ b/stepmania/src/global.h @@ -29,6 +29,8 @@ /* Define standard endianness macros, if they're missing. */ #if defined(HAVE_ENDIAN_H) #include +#elif defined(HAVE_MACHINE_ENDIAN_H) +#include #else #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321