From 9d1360b28222065b5e9d78343aec597f3830cf47 Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Tue, 16 Feb 2016 20:29:56 +0100 Subject: [PATCH] endians.h: Fix bad assumption of valid __BYTE_ORDER__ values. On the OpenIndiana Hipster distribution, compiling with GCC 4.9 would fail because __BYTE_ORDER__ was defined but not to any of the values assumed to be associated with this define (__LITTLE_ENDIAN__ or __BIG_ENDIAN__). Instead it was defined to either __ORDER_LITTLE_ENDIAN__ or __ORDER_BIG_ENDIAN__. This caused compilation to fail. Fixed by checking that all referenced defines are in fact defined before using them and adding an additional #elif clause for this newly discovered condition. --- include/ntfs-3g/endians.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/ntfs-3g/endians.h b/include/ntfs-3g/endians.h index b93761d3..948295f2 100644 --- a/include/ntfs-3g/endians.h +++ b/include/ntfs-3g/endians.h @@ -61,10 +61,16 @@ # define __BYTE_ORDER BYTE_ORDER # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN -# elif defined(__BYTE_ORDER__) +# elif defined(__BYTE_ORDER__) && defined(__LITTLE_ENDIAN__) && \ + defined(__BIG_ENDIAN__) # define __BYTE_ORDER __BYTE_ORDER__ # define __LITTLE_ENDIAN __LITTLE_ENDIAN__ # define __BIG_ENDIAN __BIG_ENDIAN__ +# elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ + defined(__ORDER_BIG_ENDIAN__) +# define __BYTE_ORDER __BYTE_ORDER__ +# define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +# define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ # elif (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \ defined(WORDS_LITTLEENDIAN) # define __BYTE_ORDER 1