Pol  Revision:4b29d2b
clib_endian.h
Go to the documentation of this file.
1 
8 #ifndef __CLIB_ENDIAN_H
9 #define __CLIB_ENDIAN_H
10 
11 #include "rawtypes.h"
12 
13 #ifndef U_BIG_ENDIAN
14 #define U_LITTLE_ENDIAN
15 #endif
16 
17 #define flipEndian32( x ) \
18  ( ( (unsigned)( x ) >> 24 ) | ( ( (unsigned)( x ) >> 8 ) & 0x0000FF00 ) | \
19  ( ( ( x ) << 8 ) & 0x00FF0000 ) | ( ( x ) << 24 ) )
20 #define flipEndian16( x ) ( ( ( ( x ) >> 8 ) & 0x00FF ) | ( ( ( x ) << 8 ) & 0xFF00 ) )
21 
22 #ifdef U_BIG_ENDIAN
23 /* big endian */
24 
25 #define cfLEu32( x ) flipEndian32( x )
26 #define cfLEu16( x ) flipEndian16( x )
27 #define ctLEu32( x ) flipEndian32( x )
28 #define ctLEu16( x ) flipEndian16( x )
29 
30 #define cfBEu32( x ) ( x )
31 #define cfBEu16( x ) ( x )
32 #define ctBEu32( x ) ( x )
33 #define ctBEu16( x ) ( x )
34 
35 #else
36 /* little endian */
37 
38 #define cfLEu32( x ) ( x )
39 #define cfLEu16( x ) ( x )
40 #define ctLEu32( x ) ( x )
41 #define ctLEu16( x ) ( x )
42 
43 #define cfBEu32( x ) flipEndian32( x )
44 #define cfBEu16( x ) flipEndian16( x )
45 #define ctBEu32( x ) flipEndian32( x )
46 #define ctBEu16( x ) flipEndian16( x )
47 
48 #endif
49 
50 #endif