glx: Use the same endian swapping as the rest of the server.

This dumps a ton of configure-time checks for system endian macros.
Given that we're marking the mixed-endian fixup code as cold, getting
at the system macros is a waste of code.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Eric Anholt
2017-03-27 14:21:43 -07:00
parent dae97e1bb4
commit be80a3cb48
3 changed files with 20 additions and 95 deletions

View File

@@ -35,27 +35,27 @@
#include <dix-config.h>
#endif
#if HAVE_BYTESWAP_H
#include <byteswap.h>
#elif defined(USE_SYS_ENDIAN_H)
#include <sys/endian.h>
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define bswap_16 OSSwapInt16
#define bswap_32 OSSwapInt32
#define bswap_64 OSSwapInt64
#else
#define bswap_16(value) \
((((value) & 0xff) << 8) | ((value) >> 8))
#include "misc.h"
#define bswap_32(value) \
(((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
(uint32_t)bswap_16((uint16_t)((value) >> 16)))
static inline uint16_t
bswap_16(uint16_t val)
{
swap_uint16(&val);
return val;
}
#define bswap_64(value) \
(((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
<< 32) | \
(uint64_t)bswap_32((uint32_t)((value) >> 32)))
#endif
static inline uint32_t
bswap_32(uint32_t val)
{
swap_uint32(&val);
return val;
}
static inline uint64_t
bswap_64(uint64_t val)
{
swap_uint64(&val);
return val;
}
#endif /* !defined(__GLXBYTEORDER_H__) */