diff --git a/blockmapbuilder.cpp b/blockmapbuilder.cpp index 5758019..3d51e2c 100644 --- a/blockmapbuilder.cpp +++ b/blockmapbuilder.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include diff --git a/getopt.c b/getopt.c index a24d94b..2c3ef3e 100644 --- a/getopt.c +++ b/getopt.c @@ -43,6 +43,7 @@ USA. */ #endif #include +#include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C diff --git a/getopt.h b/getopt.h index e2cdb12..70aff2d 100644 --- a/getopt.h +++ b/getopt.h @@ -99,6 +99,7 @@ struct option #define optional_argument 2 #if (defined (__STDC__) && __STDC__) || (defined (__cplusplus)) +#ifndef __APPLE__ #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation @@ -107,6 +108,7 @@ extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt (); #endif /* __GNU_LIBRARY__ */ +#endif extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, diff --git a/main.cpp b/main.cpp index 191abd0..acbeb9d 100644 --- a/main.cpp +++ b/main.cpp @@ -500,6 +500,8 @@ static void ShowVersion () "-x86" #elif defined(__amd64__) "-amd64" +#elif defined(__ppc__) + "-ppc" #endif #elif defined(_MSC_VER) diff --git a/nodebuild.cpp b/nodebuild.cpp index a2b20f1..25d319f 100644 --- a/nodebuild.cpp +++ b/nodebuild.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/nodebuild_utility.cpp b/nodebuild_utility.cpp index e625d54..9da4abf 100644 --- a/nodebuild_utility.cpp +++ b/nodebuild_utility.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include diff --git a/tarray.h b/tarray.h index 654e368..c944124 100644 --- a/tarray.h +++ b/tarray.h @@ -37,7 +37,9 @@ #include #include +#ifndef __APPLE__ #include +#endif #include // TArray ------------------------------------------------------------------- diff --git a/zdbsp.h b/zdbsp.h index 727bf9d..e7e319a 100644 --- a/zdbsp.h +++ b/zdbsp.h @@ -119,7 +119,7 @@ inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d) #pragma warning (default: 4035) -#elif defined(__GNUC__) +#elif defined(__GNUC__) && defined(__i386__) #ifdef __clang__ inline fixed_t Scale (fixed_t a, fixed_t b, fixed_t c) @@ -231,8 +231,51 @@ inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d) #endif -// FIXME: No macros defined for big-endian machines. -#define LittleShort(x) (x) -#define LittleLong(x) (x) +#ifdef __APPLE__ +#include + +#define LittleShort(x) CFSwapInt16LittleToHost(x) +#define LittleLong(x) CFSwapInt32LittleToHost(x) +#else +#ifdef __BIG_ENDIAN__ + +// Swap 16bit, that is, MSB and LSB byte. +// No masking with 0xFF should be necessary. +inline short LittleShort (short x) +{ + return (short)((((unsigned short)x)>>8) | (((unsigned short)x)<<8)); +} + +inline unsigned short LittleShort (unsigned short x) +{ + return (unsigned short)((x>>8) | (x<<8)); +} + +// Swapping 32bit. +inline unsigned int LittleLong (unsigned int x) +{ + return (unsigned int)( + (x>>24) + | ((x>>8) & 0xff00) + | ((x<<8) & 0xff0000) + | (x<<24)); +} + +inline int LittleLong (int x) +{ + return (int)( + (((unsigned int)x)>>24) + | ((((unsigned int)x)>>8) & 0xff00) + | ((((unsigned int)x)<<8) & 0xff0000) + | (((unsigned int)x)<<24)); +} + +#else + +#define LittleShort(x) (x) +#define LittleLong(x) (x) + +#endif // __BIG_ENDIAN__ +#endif // __APPLE__ #endif //__ZDBSP_H__