Blame SOURCES/endianness.patch

20c21b
commit b32dcedd13b3fc2ea7a8099cc0f67eaa31b8c298
20c21b
Author: Chris Liddell <chris.liddell@artifex.com>
20c21b
Date:   Thu May 21 09:06:01 2015 +0100
20c21b
20c21b
    Simplify/Improve endian decisions in lcms2.h
20c21b
    
20c21b
    Firstly, protect the endian decisions in lcms2.h so that settings given on the
20c21b
    compiler command line are not silently overridden. Thus being set explicitly
20c21b
    gets the highest priority.
20c21b
    
20c21b
    Secondly, use the endianness detected by the configure script, and remove the
20c21b
    complex and error prone stuff for PPC platforms from lcms2.h. Thus the endianess
20c21b
    from configure gets second highest priority.
20c21b
    
20c21b
    Thirdly, if neither of the above are set, fall back to some simple (and long
20c21b
    standing) platform/compiler specific tests. These should rarely, if ever, come
20c21b
    into play in a "normal" build for a "normal" Unix-like system.
20c21b
20c21b
diff --git a/include/lcms2.h b/include/lcms2.h
20c21b
index a0421d8..f32beec 100644
20c21b
--- a/include/lcms2.h
20c21b
+++ b/include/lcms2.h
20c21b
@@ -173,46 +173,43 @@
20c21b
 #  define CMS_IS_WINDOWS_ 1
20c21b
 #endif
20c21b
 
20c21b
-// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
20c21b
-// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
20c21b
-
20c21b
-#if defined(__sgi__) || defined(__sgi) || defined(sparc)
20c21b
-#   define CMS_USE_BIG_ENDIAN      1
20c21b
-#endif
20c21b
+// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
20c21b
+// on Unix-like systems, and allow it to be set on the compiler command line using
20c21b
+// -DCMS_USE_BIG_ENDIAN or something similar
20c21b
+#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
20c21b
+#  if CMS_USE_BIG_ENDIAN == 0
20c21b
+#    undef CMS_USE_BIG_ENDIAN
20c21b
+#  endif
20c21b
+#else // CMS_USE_BIG_ENDIAN
20c21b
 
20c21b
-#if defined(__s390__) || defined(__s390x__)
20c21b
-#   define CMS_USE_BIG_ENDIAN   1
20c21b
-#endif
20c21b
+#  ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
20c21b
+#    define CMS_USE_BIG_ENDIAN 1
20c21b
+#  else // WORDS_BIGENDIAN
20c21b
+// Fall back to platform/compiler specific tests
20c21b
+#    if defined(__sgi__) || defined(__sgi) || defined(sparc)
20c21b
+#      define CMS_USE_BIG_ENDIAN      1
20c21b
+#    endif
20c21b
 
20c21b
-#  ifdef TARGET_CPU_PPC
20c21b
-#    if TARGET_CPU_PPC
20c21b
+#    if defined(__s390__) || defined(__s390x__)
20c21b
 #      define CMS_USE_BIG_ENDIAN   1
20c21b
 #    endif
20c21b
-#  endif
20c21b
 
20c21b
-#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
20c21b
-#   define CMS_USE_BIG_ENDIAN   1
20c21b
-#   if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
20c21b
-#       if __BYTE_ORDER  == __LITTLE_ENDIAN
20c21b
-//               // Don't use big endian for PowerPC little endian mode
20c21b
-#                undef CMS_USE_BIG_ENDIAN
20c21b
-#       endif
20c21b
-#   endif
20c21b
-#endif
20c21b
+#    ifdef macintosh
20c21b
+#      ifdef __BIG_ENDIAN__
20c21b
+#        define CMS_USE_BIG_ENDIAN      1
20c21b
+#      endif
20c21b
+#      ifdef __LITTLE_ENDIAN__
20c21b
+#        undef CMS_USE_BIG_ENDIAN
20c21b
+#      endif
20c21b
+#    endif
20c21b
+#  endif  // WORDS_BIGENDIAN
20c21b
 
20c21b
-// WORDS_BIGENDIAN takes precedence
20c21b
-#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
20c21b
-#   define CMS_USE_BIG_ENDIAN      1
20c21b
-#endif
20c21b
+#  if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
20c21b
+#    define CMS_USE_BIG_ENDIAN      1
20c21b
+#  endif
20c21b
+
20c21b
+#endif  // CMS_USE_BIG_ENDIAN
20c21b
 
20c21b
-#ifdef macintosh
20c21b
-# ifdef __BIG_ENDIAN__
20c21b
-#   define CMS_USE_BIG_ENDIAN      1
20c21b
-# endif
20c21b
-# ifdef __LITTLE_ENDIAN__
20c21b
-#   undef CMS_USE_BIG_ENDIAN
20c21b
-# endif
20c21b
-#endif
20c21b
 
20c21b
 // Calling convention -- this is hardly platform and compiler dependent
20c21b
 #ifdef CMS_IS_WINDOWS_