NetBurner 3.1
endian.h
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
5 #ifndef __NB_ENDIAN_H
6 #define __NB_ENDIAN_H
7 
8 #include <cpu.h>
9 
10 #ifdef NB_BIG_ENDIAN
11 #ifdef NB_LITTLE_ENDIAN
12 #error Both NB_BIG_ENDIAN and NB_LITTLE_ENDIAN defined.
13 #endif
14 #endif
15 
16 #ifdef NB_BIG_ENDIAN
17 #define HTOBES(x) (x)
18 #define HTOBEL(x) (x)
19 
20 #define HTOLES(x) ((((x)&0xff00) >> 8) | (((x)&0xff) << 8))
21 
22 #define HTOLEL(x) ((((x) >> 24) & 0xff) | (((x)&0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x)&0xff) << 24))
23 #endif /* ----- #ifdef NB_BIG_ENDIAN ----- */
24 
25 #ifdef NB_LITTLE_ENDIAN
26 #define HTOBES(x) ((((x)&0xff00) >> 8) | (((x)&0xff) << 8))
27 
28 #define HTOBEL(x) ((((x) >> 24) & 0xff) | (((x)&0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x)&0xff) << 24))
29 
30 #define HTOLES(x) (x)
31 #define HTOLEL(x) (x)
32 #endif /* ----- #ifdef NB_LITTLE_ENDIAN ----- */
33 
34 #endif /* ----- #ifndef __NB_ENDIAN_H ----- */