mirror of
https://github.com/FEX-Emu/xxHash.git
synced 2024-11-23 22:49:39 +00:00
Merge pull request #269 from easyaspi314/endianness_fix
Fix endianness detection on GCC, avoid XXH_cpuIsLittleEndian.
This commit is contained in:
commit
b604c7bee5
6
xxh3.h
6
xxh3.h
@ -122,7 +122,8 @@
|
||||
# define XXH_VECTOR XXH_SSE2
|
||||
# elif defined(__GNUC__) /* msvc support maybe later */ \
|
||||
&& (defined(__ARM_NEON__) || defined(__ARM_NEON)) \
|
||||
&& defined(__LITTLE_ENDIAN__) /* ARM big endian is a thing */
|
||||
&& (defined(__LITTLE_ENDIAN__) /* We only support little endian NEON */ \
|
||||
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||
# define XXH_VECTOR XXH_NEON
|
||||
# elif defined(__PPC64__) && defined(__POWER8_VECTOR__) && defined(__GNUC__)
|
||||
# define XXH_VECTOR XXH_VSX
|
||||
@ -165,7 +166,8 @@ typedef __vector unsigned char U8x16;
|
||||
typedef __vector unsigned U32x4;
|
||||
|
||||
#ifndef XXH_VSX_BE
|
||||
# ifdef __BIG_ENDIAN__
|
||||
# if defined(__BIG_ENDIAN__) \
|
||||
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
# define XXH_VSX_BE 1
|
||||
# elif defined(__VEC_ELEMENT_REG_ORDER__) && __VEC_ELEMENT_REG_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
# warning "-maltivec=be is not recommended. Please use native endianness."
|
||||
|
9
xxhash.c
9
xxhash.c
@ -211,12 +211,21 @@ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
||||
|
||||
/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */
|
||||
#ifndef XXH_CPU_LITTLE_ENDIAN
|
||||
# if defined(_WIN32) /* Windows is always little endian */ \
|
||||
|| defined(__LITTLE_ENDIAN__) \
|
||||
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
# define XXH_CPU_LITTLE_ENDIAN 1
|
||||
# elif defined(__BIG_ENDIAN__) \
|
||||
|| (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
# define XXH_CPU_LITTLE_ENDIAN 0
|
||||
# else
|
||||
static int XXH_isLittleEndian(void)
|
||||
{
|
||||
const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
|
||||
return one.c[0];
|
||||
}
|
||||
# define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user