Skip to content

Commit

Permalink
compat/bswap.h: detect endianness from XL C compiler macros
Browse files Browse the repository at this point in the history
There is no /usr/include/endian.h equivalent on z/OS, but the
compiler will define macros to indicate endianness on host and
target hardware.  This adds a test for these macros as a last
resort for determining byte order.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Michael authored and Junio C Hamano committed Oct 27, 2014
1 parent 48a031a commit bfb0e6f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ static inline uint64_t git_bswap64(uint64_t x)
# define GIT_BYTE_ORDER GIT_BIG_ENDIAN
# elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
# define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
# elif defined(__THW_BIG_ENDIAN__) && !defined(__THW_LITTLE_ENDIAN__)
# define GIT_BYTE_ORDER GIT_BIG_ENDIAN
# elif defined(__THW_LITTLE_ENDIAN__) && !defined(__THW_BIG_ENDIAN__)
# define GIT_BYTE_ORDER GIT_LITTLE_ENDIAN
# else
# error "Cannot determine endianness"
# endif
Expand Down

0 comments on commit bfb0e6f

Please sign in to comment.