[Mesa-dev] [PATCH] mesa: Fix test for big-endian architecture in compiler.h

Jochen Rollwagen joro-2013 at t-online.de
Fri Feb 12 09:01:21 UTC 2016


Hi,

i think i found & fixed a bug in mesa concerning tests for big-endian 
machines. The defines tested don't exist or are wrongly defined so the 
test (probably) never fires. The gcc defines on my machine concerning 
big-endian are

jochen at mac-mini:~/sources/mesa$ gcc -dM -E - < /dev/null | grep BIG
#define __BIGGEST_ALIGNMENT__ 16
#define __BIG_ENDIAN__ 1
#define __FLOAT_WORD_ORDER__ __ORDER_BIG_ENDIAN__
#define _BIG_ENDIAN 1
#define __ORDER_BIG_ENDIAN__ 4321
#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__

The tested values in current mesa are quite different :-)

The following patch fixes this.

diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index c5ee741..99c63cb 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -52,7 +52,7 @@ 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(__BYTE_ORDER__) && defined(__BIG_ENDIAN__) && 
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  #if defined(__linux__)
  #include <byteswap.h>
  #define CPU_TO_LE32( x )       bswap_32( x )



More information about the mesa-dev mailing list