diff --git a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp index b9d88d23c738..abb65bfad76e 100644 --- a/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp +++ b/compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp @@ -14,7 +14,17 @@ // This test assumes float and double are IEEE-754 single- and double-precision. -#include +#if defined(__APPLE__) +# include +# define BYTE_ORDER __DARWIN_BYTE_ORDER +# define BIG_ENDIAN __DARWIN_BIG_ENDIAN +# define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +#else +# include +# define BYTE_ORDER __BYTE_ORDER +# define BIG_ENDIAN __BIG_ENDIAN +# define LITTLE_ENDIAN __LITTLE_ENDIAN +#endif // __APPLE__ #include #include #include @@ -42,7 +52,7 @@ int main(int argc, char **argv) { unsigned Zero = NearlyMinusOne; // ok // Build a '+Inf'. -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if BYTE_ORDER == LITTLE_ENDIAN char InfVal[] = { 0x00, 0x00, 0x80, 0x7f }; #else char InfVal[] = { 0x7f, 0x80, 0x00, 0x00 }; @@ -51,7 +61,7 @@ int main(int argc, char **argv) { memcpy(&Inf, InfVal, 4); // Build a 'NaN'. -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if BYTE_ORDER == LITTLE_ENDIAN char NaNVal[] = { 0x01, 0x00, 0x80, 0x7f }; #else char NaNVal[] = { 0x7f, 0x80, 0x00, 0x01 };