litex: reorganize things, first work working version
[litex.git] / litex / soc / software / include / base / endian.h
1 #ifndef __ENDIAN_H
2 #define __ENDIAN_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #define __LITTLE_ENDIAN 0
9 #define __BIG_ENDIAN 1
10 #define __BYTE_ORDER __BIG_ENDIAN
11
12 static inline unsigned int le32toh(unsigned int val)
13 {
14 return (val & 0xff) << 24 |
15 (val & 0xff00) << 8 |
16 (val & 0xff0000) >> 8 |
17 (val & 0xff000000) >> 24;
18 }
19
20 static inline unsigned short le16toh(unsigned short val)
21 {
22 return (val & 0xff) << 8 |
23 (val & 0xff00) >> 8;
24 }
25
26 #ifdef __cplusplus
27 }
28 #endif
29
30 #endif /* __ENDIAN_H */