Merge.
[cython.git] / Cython / Compiler / Buffer.py
index 2bac70dc46aa9cbd6399741eac6c147ba5c87e7a..994d48b461779fb9638d65be98f93905b52e777c 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)
         return result
@@ -590,18 +588,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;
   }