From b9f0e6923d645a044f837d61a9343ea16d56504e Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 25 Nov 2013 22:55:24 -0400 Subject: util: detect byte order Unfortunately old versions of GCC and clang do not provide byte order macros, so we re-invent them. If UTIL_BYTE_ORDER is not defined or defined to 0, we fall back to macros supported by recent versions of GCC and clang --- configure | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 1a8e939f..13b60620 100755 --- a/configure +++ b/configure @@ -441,6 +441,19 @@ else EOF fi +printf "Checking byte order... " +cat> _byteorder.c < +#include +uint32_t test = 0x34333231; +int main() { printf("%.4s\n", (const char*)&test); return 0; } +EOF +${CC} ${CFLAGS} _byteorder.c -o _byteorder > /dev/null 2>&1 +util_byte_order=$(./_byteorder) +echo $util_byte_order + +rm -f _byteorder _byteorder.c + if [ $errors -gt 0 ]; then cat <