blob: cb8231e89f1fa4e498a7f230c70b766d6f23ae81 (
plain)
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
|
#if defined(ALF_LSB_FIRST) && defined(ALF_MSB_FIRST)
# error Cannot define both ALF_LSB_FIRST and ALF_MSB_FIRST
#endif
#if defined(ALF_LSB_FIRST) || defined(ALF_MSB_FIRST)
# define ALF_ENDIAN_OK
#endif
/* try to get the byte order on this platform.
if we succeed, either ALF_LSB_FIRST or ALF_MSB_FIRST will
defined, and so will ALF_ENDIAN_OK. */
#ifndef ALF_ENDIAN_OK
# if defined(__BYTE_ORDER__)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define ALF_LSB_FIRST
# define ALF_ENDIAN_OK
# else
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define ALF_MSB_FIRST
# define ALF_ENDIAN_OK
# endif
# endif
# endif
#endif
#ifndef ALF_ENDIAN_OK
# if defined(__LITTLE_ENDIAN__)
# define ALF_LSB_FIRST
# define ALF_ENDIAN_OK
# else
# if defined(__BIG_ENDIAN__)
# define ALF_MSB_FIRST
# define ALF_ENDIAN_OK
# endif
# endif
#endif
#ifdef ALF_ENDIAN_OK
# ifdef ALF_LSB_FIRST
# define HIBYTE 2
# define MIDBYTE 1
# define LOBYTE 0
# else
# define HIBYTE 1
# define MIDBYTE 2
# define LOBYTE 3
# endif
#else
# warning Cannot determine endianness, falling back to safe but slow append_bit().
# warning Recompile with -DALF_LSB_FIRST or -DALF_MSB_FIRST.
#endif
|