diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-11 16:30:52 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-11 16:30:52 +0000 |
commit | c81b768ae551c035afc4cec0295a6c1551342452 (patch) | |
tree | 076be395abfd5311648a1ae5f220c01bf3cb02d4 /config.h.in | |
parent | b290d0de907db6f401e97b6dfed55043e1989ecc (diff) | |
download | rspamd-c81b768ae551c035afc4cec0295a6c1551342452.tar.gz rspamd-c81b768ae551c035afc4cec0295a6c1551342452.zip |
Improve and simplify endiannes detection
Diffstat (limited to 'config.h.in')
-rw-r--r-- | config.h.in | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/config.h.in b/config.h.in index 0f9e063dc..6615deadf 100644 --- a/config.h.in +++ b/config.h.in @@ -126,33 +126,43 @@ #cmakedefine WITH_SYSTEM_HIREDIS 1 /* Detect endiannes */ - #ifdef HAVE_ENDIAN_H + +#ifdef HAVE_ENDIAN_H #include <endian.h> - #else - #ifdef HAVE_SYS_ENDIAN_H +#elif defined(HAVE_SYS_ENDIAN_H) #include <sys/endian.h> - #else - #ifdef HAVE_MACHINE_ENDIAN_H +#elif defined(HAVE_MACHINE_ENDIAN_H) #include <machine/endian.h> - #else +#endif + +#ifndef BYTE_ORDER + +#ifndef LITTLE_ENDIAN #define LITTLE_ENDIAN 1234 +#endif +#ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 - #if defined(i386) || defined(__i386) || defined(__amd64) || \ - defined(BIT_ZERO_ON_RIGHT) || defined(__x86__) - #define BYTE_ORDER LITTLE_ENDIAN - #endif - - #if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) - #define BYTE_ORDER BIG_ENDIAN - #endif +#endif - #endif /* HAVE_MACHINE_ENDIAN_H */ - #endif /* HAVE_SYS_ENDIAN_H */ - #endif /* HAVE_ENDIAN_H */ +#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \ + defined(__BIG_ENDIAN__) || \ + defined(__ARMEB__) || \ + defined(__THUMBEB__) || \ + defined(__AARCH64EB__) || \ + defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) +#define BYTE_ORDER BIG_ENDIAN +#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \ + defined(__LITTLE_ENDIAN__) || \ + defined(__ARMEL__) || \ + defined(__THUMBEL__) || \ + defined(__AARCH64EL__) || \ + defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) +#define BYTE_ORDER LITTLE_ENDIAN +#else +#error "I don't know what architecture this is!" +#endif - #if !defined(BYTE_ORDER) - # error "Undefined or unknown BYTE_ORDER" - #endif +#endif /* BYTE_ORDER */ /* Configure allocator */ #define uthash_malloc(sz) g_slice_alloc(sz) @@ -227,6 +237,10 @@ #include <string.h> #endif +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif + #include <errno.h> #include <glib.h> |