arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1656: [C++] Endianness Macro is Incorrect on Windows And Mac
Date Sun, 08 Oct 2017 17:04:14 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 208e79812 -> 33d446dd4


ARROW-1656: [C++] Endianness Macro is Incorrect on Windows And Mac

Author: Phillip Cloud <cpcloud@gmail.com>

Closes #1184 from cpcloud/ARROW-1656 and squashes the following commits:

04a92621 [Phillip Cloud] ARROW-1656: [C++] Endianness Macro is Incorrect on Windows And Mac


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/33d446dd
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/33d446dd
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/33d446dd

Branch: refs/heads/master
Commit: 33d446dd4d69cfc6cbbf91cd7af51c6c7d6eee8f
Parents: 208e798
Author: Phillip Cloud <cpcloud@gmail.com>
Authored: Sun Oct 8 13:04:02 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sun Oct 8 13:04:02 2017 -0400

----------------------------------------------------------------------
 cpp/src/arrow/util/bit-util.h | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/33d446dd/cpp/src/arrow/util/bit-util.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util.h b/cpp/src/arrow/util/bit-util.h
index dd10245..2509de2 100644
--- a/cpp/src/arrow/util/bit-util.h
+++ b/cpp/src/arrow/util/bit-util.h
@@ -18,13 +18,29 @@
 #ifndef ARROW_UTIL_BIT_UTIL_H
 #define ARROW_UTIL_BIT_UTIL_H
 
-#if defined(__APPLE__)
+#ifdef _WIN32
+#define ARROW_LITTLE_ENDIAN 1
+#else
+#ifdef __APPLE__
 #include <machine/endian.h>
-#elif defined(_WIN32)
-#define __LITTLE_ENDIAN 1
 #else
 #include <endian.h>
 #endif
+#
+#ifndef __BYTE_ORDER__
+#error "__BYTE_ORDER__ not defined"
+#endif
+#
+#ifndef __ORDER_LITTLE_ENDIAN__
+#error "__ORDER_LITTLE_ENDIAN__ not defined"
+#endif
+#
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define ARROW_LITTLE_ENDIAN 1
+#else
+#define ARROW_LITTLE_ENDIAN 0
+#endif
+#endif
 
 #if defined(_MSC_VER)
 #define ARROW_BYTE_SWAP64 _byteswap_uint64
@@ -324,7 +340,7 @@ static inline void ByteSwap(void* dst, const void* src, int len) {
 
 /// Converts to big endian format (if not already in big endian) from the
 /// machine's native endian format.
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if ARROW_LITTLE_ENDIAN
 static inline int64_t ToBigEndian(int64_t value) { return ByteSwap(value); }
 static inline uint64_t ToBigEndian(uint64_t value) { return ByteSwap(value); }
 static inline int32_t ToBigEndian(int32_t value) { return ByteSwap(value); }
@@ -341,7 +357,7 @@ static inline uint16_t ToBigEndian(uint16_t val) { return val; }
 #endif
 
 /// Converts from big endian format to the machine's native endian format.
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if ARROW_LITTLE_ENDIAN
 static inline int64_t FromBigEndian(int64_t value) { return ByteSwap(value); }
 static inline uint64_t FromBigEndian(uint64_t value) { return ByteSwap(value); }
 static inline int32_t FromBigEndian(int32_t value) { return ByteSwap(value); }


Mime
View raw message