Remove dependancy on endian.h (which is not available on all systems)
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 2 Aug 2008 21:49:42 +0000 (14:49 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 2 Aug 2008 21:49:42 +0000 (14:49 -0700)
Cython/Compiler/Buffer.py

index 3e8f5ac454e0ed00f6a30e6ddc218111a91c3eba..59e6316597ca91429c961f30a5953ec8e285b3a4 100644 (file)
@@ -29,8 +29,6 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
         self.max_ndim = 0
         result = super(IntroduceBufferAuxiliaryVars, self).__call__(node)
         if self.buffers_exists:
-            if "endian.h" not in node.scope.include_files:
-                node.scope.include_files.append("endian.h")
             use_py2_buffer_functions(node.scope)
             use_empty_bufstruct_code(node.scope, self.max_ndim)
             node.scope.use_utility_code(access_utility_code)
@@ -656,18 +654,20 @@ static INLINE const char* __Pyx_ConsumeWhitespace(const char* ts) {
 }
 
 static INLINE const char* __Pyx_BufferTypestringCheckEndian(const char* ts) {
+  int num = 1;
+  int little_endian = ((char*)&num)[0];
   int ok = 1;
   switch (*ts) {
     case '@':
     case '=':
       ++ts; break;
     case '<':
-      if (__BYTE_ORDER == __LITTLE_ENDIAN) ++ts;
+      if (little_endian) ++ts;
       else ok = 0;
       break;
     case '>':
     case '!':
-      if (__BYTE_ORDER == __BIG_ENDIAN) ++ts;
+      if (!little_endian) ++ts;
       else ok = 0;
       break;
   }