forked from zlib-ng/zlib-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gzendian.h
52 lines (49 loc) · 1.47 KB
/
gzendian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* gzendian.h -- define BYTE_ORDER for endian tests
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#ifndef ENDIAN_H_
#define ENDIAN_H_
/* First check whether the compiler knows the target __BYTE_ORDER__. */
#if defined(__BYTE_ORDER__)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
# define BYTE_ORDER LITTLE_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
# define BYTE_ORDER BIG_ENDIAN
# endif
#elif defined(__MINGW32__)
# include <sys/param.h>
#elif defined(WIN32) || defined(_WIN32)
# define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321
# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM)
# define BYTE_ORDER LITTLE_ENDIAN
# else
# error Unknown endianness!
# endif
#elif defined(__linux__)
# include <endian.h>
#elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__)
# include <machine/endian.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
# include <sys/endian.h>
#elif defined(__sun) || defined(sun)
# include <sys/byteorder.h>
# if !defined(LITTLE_ENDIAN)
# define LITTLE_ENDIAN 4321
# endif
# if !defined(BIG_ENDIAN)
# define BIG_ENDIAN 1234
# endif
# if !defined(BYTE_ORDER)
# if defined(_BIG_ENDIAN)
# define BYTE_ORDER BIG_ENDIAN
# else
# define BYTE_ORDER LITTLE_ENDIAN
# endif
# endif
#else
# include <endian.h>
#endif
#endif