Due to the way Mesa can be built there are two headers that setup endian
tests.

src/mesa/main/compiler.h and src/gallium/include/pipe/p_config.h

The former relies on indirect inclusion as was recently pointed out
on the Mesa list.

The compiler.h version is used in the following places, it turns out
endian.h is always included before compiler.h where it matters except
for shaderimage.c.

CPU_TO_LE32 not used

src/mesa/drivers/dri/r200/radeon_queryobj.c:            query->Base.Result += 
LE32_TO_CPU(result[i]);
src/mesa/drivers/dri/r200/radeon_queryobj.c:            
radeon_print(RADEON_STATE, RADEON_TRACE, "result[%d] = %d\n", i, 
LE32_TO_CPU(result[i]));
src/mesa/drivers/dri/radeon/radeon_queryobj.c:          query->Base.Result += 
LE32_TO_CPU(result[i]);
src/mesa/drivers/dri/radeon/radeon_queryobj.c:          
radeon_print(RADEON_STATE, RADEON_TRACE, "result[%d] = %d\n", i, 
LE32_TO_CPU(result[i]));

src/mesa/drivers/dri/r200/r200_state_init.c:#ifdef MESA_BIG_ENDIAN
src/mesa/drivers/dri/r200/r200_tcl.c:#ifdef MESA_BIG_ENDIAN
src/mesa/drivers/dri/radeon/radeon_state_init.c:#ifdef MESA_BIG_ENDIAN
src/mesa/drivers/dri/radeon/radeon_tcl.c:#ifdef MESA_BIG_ENDIAN
src/mesa/main/shaderimage.c:#ifdef MESA_BIG_ENDIAN
src/gallium/auxiliary/util/u_format_rgb9e5.h:#if defined(MESA_BIG_ENDIAN) || 
defined(PIPE_ARCH_BIG_ENDIAN)
src/gallium/auxiliary/util/u_format_rgb9e5.h:#if defined(MESA_BIG_ENDIAN) || 
defined(PIPE_ARCH_BIG_ENDIAN)

src/mesa/drivers/dri/r200/r200_swtcl.c:#if MESA_LITTLE_ENDIAN
src/mesa/drivers/dri/r200/r200_swtcl.c:#if MESA_LITTLE_ENDIAN
src/mesa/drivers/dri/radeon/radeon_swtcl.c:#if MESA_LITTLE_ENDIAN
src/mesa/drivers/dri/radeon/radeon_swtcl.c:#if MESA_LITTLE_ENDIAN

This should be handled better in future Mesa releases but for now I'd
like to commit the following.  Looking for testers.

Index: lib/mesa/src/mesa/main/compiler.h
===================================================================
RCS file: /cvs/xenocara/lib/mesa/src/mesa/main/compiler.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 compiler.h
--- lib/mesa/src/mesa/main/compiler.h   22 Nov 2015 02:39:08 -0000      1.1.1.1
+++ lib/mesa/src/mesa/main/compiler.h   16 Feb 2016 11:42:18 -0000
@@ -66,28 +66,16 @@ extern "C" {
  * Try to use a runtime test instead.
  * For now, only used by some DRI hardware drivers for color/texel packing.
  */
-#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
-#if defined(__linux__)
-#include <byteswap.h>
-#define CPU_TO_LE32( x )       bswap_32( x )
-#elif defined(__APPLE__)
-#include <CoreFoundation/CFByteOrder.h>
-#define CPU_TO_LE32( x )       CFSwapInt32HostToLittle( x )
-#elif defined(__OpenBSD__)
-#include <sys/types.h>
+#ifdef __OpenBSD__
+#include <endian.h>
 #define CPU_TO_LE32( x )       htole32( x )
-#else /*__linux__ */
-#include <sys/endian.h>
-#define CPU_TO_LE32( x )       bswap32( x )
-#endif /*__linux__*/
+#define LE32_TO_CPU( x )       letoh32( x )
+#if BYTE_ORDER == BIG_ENDIAN
 #define MESA_BIG_ENDIAN 1
 #else
-#define CPU_TO_LE32( x )       ( x )
 #define MESA_LITTLE_ENDIAN 1
 #endif
-#define LE32_TO_CPU( x )       CPU_TO_LE32( x )
-
-
+#endif /* __OpenBSD__ */
 
 #define IEEE_ONE 0x3f800000
 

Reply via email to