THRIFT-362. python: Detect endianness on Solaris
authorDavid Reiss <dreiss@apache.org>
Wed, 18 Mar 2009 23:14:13 +0000 (23:14 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 18 Mar 2009 23:14:13 +0000 (23:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@755776 13f79535-47bb-0310-9956-ffa450edef68

lib/py/src/protocol/fastbinary.c

index 7ada44c..71c0f8d 100644 (file)
 #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.)