diff options
author | Charles Bailey <cbailey32@bloomberg.net> | 2014-05-02 08:55:29 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-05-02 12:31:59 -0700 |
commit | 3cf6bb34063406e107f51aa52db67d65839f5e58 (patch) | |
tree | 6b8e2455512f55a18fc4aab1d6803ca2bd56d446 /compat/bswap.h | |
parent | Merge git://github.com/git-l10n/git-po (diff) | |
download | tgif-3cf6bb34063406e107f51aa52db67d65839f5e58.tar.xz |
compat/bswap.h: detect endianness on more platforms that don't use BYTE_ORDER
Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/bswap.h')
-rw-r--r-- | compat/bswap.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/compat/bswap.h b/compat/bswap.h index 120c6c1d37..f08a9fe87c 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -101,19 +101,34 @@ static inline uint64_t git_bswap64(uint64_t x) #undef ntohll #undef htonll -#if !defined(__BYTE_ORDER) -# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) -# define __BYTE_ORDER BYTE_ORDER -# define __LITTLE_ENDIAN LITTLE_ENDIAN -# define __BIG_ENDIAN BIG_ENDIAN +#if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) + +# define GIT_BYTE_ORDER BYTE_ORDER +# define GIT_LITTLE_ENDIAN LITTLE_ENDIAN +# define GIT_BIG_ENDIAN BIG_ENDIAN + +#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN) + +# define GIT_BYTE_ORDER __BYTE_ORDER +# define GIT_LITTLE_ENDIAN __LITTLE_ENDIAN +# define GIT_BIG_ENDIAN __BIG_ENDIAN + +#else + +# define GIT_BIG_ENDIAN 4321 +# define GIT_LITTLE_ENDIAN 1234 + +# if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# define GIT_BYTE_ORDER GIT_BIG_ENDIAN +# elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN +# else +# error "Cannot determine endianness" # endif -#endif -#if !defined(__BYTE_ORDER) -# error "Cannot determine endianness" #endif -#if __BYTE_ORDER == __BIG_ENDIAN +#if GIT_BYTE_ORDER == GIT_BIG_ENDIAN # define ntohll(n) (n) # define htonll(n) (n) #else |