From b7ca5d14ce7ba410b0dab5c2289f6d7b75e763df Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 4 Jan 2007 15:37:33 -0800 Subject: [PATCH] Incorporate new byte-order related configure changes. --- GL/glx/glxbyteorder.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/GL/glx/glxbyteorder.h b/GL/glx/glxbyteorder.h index 3c094d702..0bcb91fb7 100644 --- a/GL/glx/glxbyteorder.h +++ b/GL/glx/glxbyteorder.h @@ -31,18 +31,25 @@ #if !defined(__GLXBYTEORDER_H__) #define __GLXBYTEORDER_H__ -#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#if HAVE_BYTESWAP_H #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 -#else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif #endif /* !defined(__GLXBYTEORDER_H__) */