[compiler-rt] r218662 - [UBSan] Use <machine/endian.h> on Darwin.

Alexander Potapenko glider at google.com
Tue Sep 30 03:07:38 PDT 2014


Author: glider
Date: Tue Sep 30 05:07:37 2014
New Revision: 218662

URL: http://llvm.org/viewvc/llvm-project?rev=218662&view=rev
Log:
[UBSan] Use <machine/endian.h> on Darwin.

Modified:
    compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp

Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=218662&r1=218661&r2=218662&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
+++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Tue Sep 30 05:07:37 2014
@@ -14,7 +14,17 @@
 
 // This test assumes float and double are IEEE-754 single- and double-precision.
 
-#include <endian.h>
+#if defined(__APPLE__)
+# include <machine/endian.h>
+# define BYTE_ORDER __DARWIN_BYTE_ORDER
+# define BIG_ENDIAN __DARWIN_BIG_ENDIAN
+# define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
+#else
+# include <endian.h>
+# define BYTE_ORDER __BYTE_ORDER
+# define BIG_ENDIAN __BIG_ENDIAN
+# define LITTLE_ENDIAN __LITTLE_ENDIAN
+#endif  // __APPLE__
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
@@ -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 };





More information about the llvm-commits mailing list