2 #define CONFIG "config.h"
8 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
9 && defined(BS16) && defined(BS32) && defined(BS64)
11 #else // ! defined(__BYTE_ORDER)
13 void PUT_UAA64BE(void *p
, unsigned long long v
, unsigned int i
)
15 unsigned char *_p
= (unsigned char *)&((unsigned long long *)p
)[i
];
26 void PUT_UAA32BE(void *p
, unsigned int v
, unsigned int i
)
28 unsigned char *_p
= (unsigned char *)&((unsigned int *)p
)[i
];
35 void PUT_UAA16BE(void *p
, unsigned short v
, unsigned int i
)
37 unsigned char *_p
= (unsigned char *)&((unsigned short *)p
)[i
];
43 void PUT_UAA64LE(void *p
, unsigned long long v
, unsigned int i
)
45 unsigned char *_p
= (unsigned char *)&((unsigned long long *)p
)[i
];
56 void PUT_UAA32LE(void *p
, unsigned int v
, unsigned int i
)
58 unsigned char *_p
= (unsigned char *)&((unsigned int *)p
)[i
];
65 void PUT_UAA16LE(void *p
, unsigned short v
, unsigned int i
)
67 unsigned char *_p
= (unsigned char *)&((unsigned short *)p
)[i
];
73 unsigned long long GET_UAA64BE(void *p
, unsigned int i
)
75 unsigned char *_p
= (unsigned char *)&((unsigned long long *)p
)[i
];
77 (unsigned long long)_p
[ 0 ] << 56 |
78 (unsigned long long)_p
[ 1 ] << 48 |
79 (unsigned long long)_p
[ 2 ] << 40 |
80 (unsigned long long)_p
[ 3 ] << 32 |
81 (unsigned long long)_p
[ 4 ] << 24 |
82 (unsigned long long)_p
[ 5 ] << 16 |
83 (unsigned long long)_p
[ 6 ] << 8 |
84 (unsigned long long)_p
[ 7 ];
88 unsigned int GET_UAA32BE(void *p
, unsigned int i
)
90 unsigned char *_p
= (unsigned char *)&((unsigned int *)p
)[i
];
92 (unsigned int)_p
[ 0 ] << 24 |
93 (unsigned int)_p
[ 1 ] << 16 |
94 (unsigned int)_p
[ 2 ] << 8 |
95 (unsigned int)_p
[ 3 ];
98 unsigned short GET_UAA16BE(void *p
, unsigned int i
)
100 unsigned char *_p
= (unsigned char *)&((unsigned short *)p
)[i
];
102 (unsigned short)_p
[ 0 ] << 8 |
103 (unsigned short)_p
[ 1 ];
107 unsigned long long GET_UAA64LE(void *p
, unsigned int i
)
109 unsigned char *_p
= (unsigned char *)&((unsigned long long *)p
)[i
];
111 (unsigned long long)_p
[ 0 ] |
112 (unsigned long long)_p
[ 1 ] << 8 |
113 (unsigned long long)_p
[ 2 ] << 16 |
114 (unsigned long long)_p
[ 3 ] << 24 |
115 (unsigned long long)_p
[ 4 ] << 32 |
116 (unsigned long long)_p
[ 5 ] << 40 |
117 (unsigned long long)_p
[ 6 ] << 48 |
118 (unsigned long long)_p
[ 7 ] << 56;
122 unsigned int GET_UAA32LE(void *p
, unsigned int i
)
124 unsigned char *_p
= (unsigned char *)&((unsigned int *)p
)[i
];
126 (unsigned int)_p
[ 0 ] |
127 (unsigned int)_p
[ 1 ] << 8 |
128 (unsigned int)_p
[ 2 ] << 16 |
129 (unsigned int)_p
[ 3 ] << 24;
132 unsigned short GET_UAA16LE(void *p
, unsigned int i
)
134 unsigned char *_p
= (unsigned char *)&((unsigned short *)p
)[i
];
136 (unsigned short)_p
[ 0 ] |
137 (unsigned short)_p
[ 1 ] << 8;
141 unsigned short BE16(unsigned short x
)
143 return GET_UAA16BE(&x
, 0);
146 unsigned short LE16(unsigned short x
)
148 return GET_UAA16LE(&x
, 0);
151 unsigned int BE32(unsigned int x
)
153 return GET_UAA32BE(&x
, 0);
156 unsigned int LE32(unsigned int x
)
158 return GET_UAA32LE(&x
, 0);
161 unsigned long long BE64(unsigned long long x
)
163 return GET_UAA64BE(&x
, 0);
166 inline unsigned long long LE64(unsigned long long x
)
168 return GET_UAA64LE(&x
, 0);
171 #endif // defined(__BYTE_ORDER)