THRIFT-362. python: Detect endianness on Solaris
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@755776 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/protocol/fastbinary.c b/lib/py/src/protocol/fastbinary.c
index 7ada44c..71c0f8d 100644
--- a/lib/py/src/protocol/fastbinary.c
+++ b/lib/py/src/protocol/fastbinary.c
@@ -16,6 +16,25 @@
#include <stdint.h>
#include <netinet/in.h>
+/* Fix endianness issues on Solaris */
+#if defined (__SVR4) && defined (__sun)
+ #if defined(__i386) && !defined(__i386__)
+ #define __i386__
+ #endif
+
+ #ifndef BIG_ENDIAN
+ #define BIG_ENDIAN (4321)
+ #endif
+ #ifndef LITTLE_ENDIAN
+ #define LITTLE_ENDIAN (1234)
+ #endif
+
+ /* I386 is LE, even on Solaris */
+ #if !defined(BYTE_ORDER) && defined(__i386__)
+ #define BYTE_ORDER LITTLE_ENDIAN
+ #endif
+#endif
+
// TODO(dreiss): defval appears to be unused. Look into removing it.
// TODO(dreiss): Make parse_spec_args recursive, and cache the output
// permanently in the object. (Malloc and orphan.)