-
Notifications
You must be signed in to change notification settings - Fork 2
/
pcapsipdump_endian.h
38 lines (36 loc) · 1.15 KB
/
pcapsipdump_endian.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
// detect target system endianness
#if sparc
#define _BIG_ENDIAN 1
#else
#include <sys/param.h>
#endif
#if !(__BYTE_ORDER == __LITTLE_ENDIAN) && \
!(__BYTE_ORDER == __BIG_ENDIAN)
#if defined(BYTE_ORDER) && \
defined(LITTLE_ENDIAN) && \
defined(BIG_ENDIAN) && \
((BYTE_ORDER == LITTLE_ENDIAN) || \
(BYTE_ORDER == BIG_ENDIAN))
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BIG_ENDIAN BIG_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#elif defined(_BYTE_ORDER) && \
defined(_LITTLE_ENDIAN) && \
defined(_BIG_ENDIAN) && \
((_BYTE_ORDER == _LITTLE_ENDIAN) || \
(_BYTE_ORDER == _BIG_ENDIAN))
#define __LITTLE_ENDIAN _LITTLE_ENDIAN
#define __BIG_ENDIAN _BIG_ENDIAN
#define __BYTE_ORDER _BYTE_ORDER
#elif !defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN)
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __BYTE_ORDER 4321
#elif !defined(_BYTE_ORDER) && defined(_BIG_ENDIAN)
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __BYTE_ORDER 1234
#else
#error Unable to detect target system endianness
#endif
#endif