File tree 1 file changed +22
-12
lines changed
1 file changed +22
-12
lines changed Original file line number Diff line number Diff line change 9
9
#ifndef ENDIAN_H
10
10
#define ENDIAN_H
11
11
12
+ #include "config.h"
13
+
12
14
#if _WIN32
13
15
#include <stdlib.h>
14
16
49
51
#elif __APPLE__
50
52
#include <libkern/OSByteOrder.h>
51
53
52
- #ifndef BYTE_ORDER
54
+ #if !defined BYTE_ORDER
53
55
# define BYTE_ORDER __BYTE_ORDER__
54
56
#endif
55
- #ifndef LITTLE_ENDIAN
57
+ #if !defined LITTLE_ENDIAN
56
58
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
57
59
#endif
58
- #ifndef BIG_ENDIAN
60
+ #if !defined BIG_ENDIAN
59
61
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
60
62
#endif
61
63
74
76
#define le64toh (x ) OSSwapLittleToHostInt64(x)
75
77
76
78
#else
77
- #include "config.h"
79
+ #if HAVE_ENDIAN_H
80
+ #include <endian.h>
81
+ #elif defined(__OpenBSD__ )
82
+ // endian.h was added in OpenBSD 5.6. machine/endian.h exports optimized
83
+ // bswap routines for use in sys/endian.h, which it includes.
84
+ #include <machine/endian.h>
85
+ #elif defined(__FreeBSD__ ) || defined(__NetBSD__ ) || defined(__DragonFly__ )
86
+ #include <sys/endian.h>
87
+ #endif
78
88
79
- #if defined(linux ) || defined(__OpenBSD__ )
80
- # ifdef HAVE_ENDIAN_H
81
- # include <endian.h> /* attempt to define endianness */
82
- # else
83
- # include <machine/endian.h> /* on older OpenBSD */
84
- # endif
89
+ #if !defined BYTE_ORDER
90
+ #error "missing definition of BYTE_ORDER"
85
91
#endif
86
- #if defined(__FreeBSD__ ) || defined(__NetBSD__ ) || defined(__DragonFly__ )
87
- #include <sys/endian.h> /* attempt to define endianness */
92
+
93
+ #if !defined LITTLE_ENDIAN
94
+ #error "missing definition of LITTLE_ENDIAN"
88
95
#endif
89
96
97
+ #if !defined BIG_ENDIAN
98
+ #error "missing definition of BIG_ENDIAN"
99
+ #endif
90
100
#endif
91
101
92
102
#endif // ENDIAN_H
You can’t perform that action at this time.
0 commit comments