diff options
Diffstat (limited to 'include/compat/endian.h')
-rw-r--r-- | include/compat/endian.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/compat/endian.h b/include/compat/endian.h new file mode 100644 index 0000000..1ed255e --- /dev/null +++ b/include/compat/endian.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * endian.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_BYTE_ORDER_H_ | ||
7 | #define LIBCRYPTOCOMPAT_BYTE_ORDER_H_ | ||
8 | |||
9 | #if defined(_WIN32) | ||
10 | |||
11 | #define LITTLE_ENDIAN 1234 | ||
12 | #define BIG_ENDIAN 4321 | ||
13 | #define PDP_ENDIAN 3412 | ||
14 | |||
15 | /* | ||
16 | * Use GCC and Visual Studio compiler defines to determine endian. | ||
17 | */ | ||
18 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
19 | #define BYTE_ORDER LITTLE_ENDIAN | ||
20 | #else | ||
21 | #define BYTE_ORDER BIG_ENDIAN | ||
22 | #endif | ||
23 | |||
24 | #elif defined(HAVE_ENDIAN_H) | ||
25 | #include_next <endian.h> | ||
26 | |||
27 | #elif defined(__sun) || defined(_AIX) || defined(__hpux) | ||
28 | #include <sys/types.h> | ||
29 | #include <arpa/nameser_compat.h> | ||
30 | |||
31 | #elif defined(__sgi) | ||
32 | #include <standards.h> | ||
33 | #include <sys/endian.h> | ||
34 | |||
35 | #endif | ||
36 | |||
37 | #ifndef __STRICT_ALIGNMENT | ||
38 | #define __STRICT_ALIGNMENT | ||
39 | #if defined(__i386) || defined(__i386__) || \ | ||
40 | defined(__x86_64) || defined(__x86_64__) || \ | ||
41 | defined(__s390__) || defined(__s390x__) || \ | ||
42 | defined(__aarch64__) || \ | ||
43 | ((defined(__arm__) || defined(__arm)) && __ARM_ARCH >= 6) | ||
44 | #undef __STRICT_ALIGNMENT | ||
45 | #endif | ||
46 | #endif | ||
47 | |||
48 | #endif | ||