1 #ifndef __HAD_MY_ENDIAN_H
2 #define __HAD_MY_ENDIAN_H
3 
4 #include <sys/param.h>
5 
6 #if (defined(BSD) && (BSD >= 199306))
7 /* this should filter out NetBSD, FreeBSD and OpenBSD */
8 #include <machine/endian.h>
9 
10 #if BYTE_ORDER == BIG_ENDIAN
11 #define MSB_FIRST 1
12 #undef LSB_FIRST
13 #else
14 #define LSB_FIRST 1
15 #undef MSB_FIRST
16 #endif
17 
18 #else
19 /* for Linux, perhaps use #ifdef __linux__? */
20 #include <sys/types.h>
21 
22 #if defined(__BYTE_ORDER)
23 #if __BYTE_ORDER == __BIG_ENDIAN
24 #define MSB_FIRST 1
25 #undef LSB_FIRST
26 #else
27 #define LSB_FIRST 1
28 #undef MSB_FIRST
29 #endif /* __BYTE_ORDER == __BIG_ENDIAN */
30 
31 #else /* defined(__BYTE_ORDER) */
32 
33 /* not Linux, either, just set it to LSB */
34 #define LSB_FIRST 1
35 #undef MSB_FIRST
36 
37 #endif /* defined(__BYTE_ORDER) */
38 
39 #endif /* defined(BSD) && (BSD >= 199306) */
40 
41 #endif /* __HAD_MY_ENDIAN_H */
42