treewide: remove FSF address
[osmocom-bb.git] / src / target / firmware / include / byteorder.h
blob41edb93dd48845ac85878215f62f155933a36352
1 #ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
2 #define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
4 #ifndef __LITTLE_ENDIAN
5 #define __LITTLE_ENDIAN 1234
6 #endif
7 #ifndef __LITTLE_ENDIAN_BITFIELD
8 #define __LITTLE_ENDIAN_BITFIELD
9 #endif
11 #include <stdint.h>
12 #include <swab.h>
14 #define __constant_htonl(x) ___constant_swab32(x)
15 #define __constant_ntohl(x) ___constant_swab32(x)
16 #define __constant_htons(x) ___constant_swab16(x)
17 #define __constant_ntohs(x) ___constant_swab16(x)
18 #define __constant_cpu_to_le64(x) (x)
19 #define __constant_le64_to_cpu(x) (x)
20 #define __constant_cpu_to_le32(x) (x)
21 #define __constant_le32_to_cpu(x) (x)
22 #define __constant_cpu_to_le16(x) (x)
23 #define __constant_le16_to_cpu(x) (x)
24 #define __constant_cpu_to_be64(x) ___constant_swab64(x)
25 #define __constant_be64_to_cpu(x) ___constant_swab64(x)
26 #define __constant_cpu_to_be32(x) ___constant_swab32(x)
27 #define __constant_be32_to_cpu(x) ___constant_swab32(x)
28 #define __constant_cpu_to_be16(x) ___constant_swab16(x)
29 #define __constant_be16_to_cpu(x) ___constant_swab16(x)
30 #define __cpu_to_le64(x) (x)
31 #define __le64_to_cpu(x) (x)
32 #define __cpu_to_le32(x) (x)
33 #define __le32_to_cpu(x) (x)
34 #define __cpu_to_le16(x) (x)
35 #define __le16_to_cpu(x) (x)
36 #define __cpu_to_be64(x) __swab64(x)
37 #define __be64_to_cpu(x) __swab64(x)
38 #define __cpu_to_be32(x) __swab32(x)
39 #define __be32_to_cpu(x) __swab32(x)
40 #define __cpu_to_be16(x) __swab16(x)
41 #define __be16_to_cpu(x) __swab16(x)
43 /* from include/linux/byteorder/generic.h */
44 #define cpu_to_le64 __cpu_to_le64
45 #define le64_to_cpu __le64_to_cpu
46 #define cpu_to_le32 __cpu_to_le32
47 #define le32_to_cpu __le32_to_cpu
48 #define cpu_to_le16 __cpu_to_le16
49 #define le16_to_cpu __le16_to_cpu
50 #define cpu_to_be64 __cpu_to_be64
51 #define be64_to_cpu __be64_to_cpu
52 #define cpu_to_be32 __cpu_to_be32
53 #define be32_to_cpu __be32_to_cpu
54 #define cpu_to_be16 __cpu_to_be16
55 #define be16_to_cpu __be16_to_cpu
58 * They have to be macros in order to do the constant folding
59 * correctly - if the argument passed into a inline function
60 * it is no longer constant according to gcc..
63 #undef ntohl
64 #undef ntohs
65 #undef htonl
66 #undef htons
68 #define ___htonl(x) __cpu_to_be32(x)
69 #define ___htons(x) __cpu_to_be16(x)
70 #define ___ntohl(x) __be32_to_cpu(x)
71 #define ___ntohs(x) __be16_to_cpu(x)
73 #define htonl(x) ___htonl(x)
74 #define ntohl(x) ___ntohl(x)
75 #define htons(x) ___htons(x)
76 #define ntohs(x) ___ntohs(x)
79 #endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */