0001
0002 #ifndef _LINUX_BYTEORDER_GENERIC_H
0003 #define _LINUX_BYTEORDER_GENERIC_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 #define cpu_to_le64 __cpu_to_le64
0087 #define le64_to_cpu __le64_to_cpu
0088 #define cpu_to_le32 __cpu_to_le32
0089 #define le32_to_cpu __le32_to_cpu
0090 #define cpu_to_le16 __cpu_to_le16
0091 #define le16_to_cpu __le16_to_cpu
0092 #define cpu_to_be64 __cpu_to_be64
0093 #define be64_to_cpu __be64_to_cpu
0094 #define cpu_to_be32 __cpu_to_be32
0095 #define be32_to_cpu __be32_to_cpu
0096 #define cpu_to_be16 __cpu_to_be16
0097 #define be16_to_cpu __be16_to_cpu
0098 #define cpu_to_le64p __cpu_to_le64p
0099 #define le64_to_cpup __le64_to_cpup
0100 #define cpu_to_le32p __cpu_to_le32p
0101 #define le32_to_cpup __le32_to_cpup
0102 #define cpu_to_le16p __cpu_to_le16p
0103 #define le16_to_cpup __le16_to_cpup
0104 #define cpu_to_be64p __cpu_to_be64p
0105 #define be64_to_cpup __be64_to_cpup
0106 #define cpu_to_be32p __cpu_to_be32p
0107 #define be32_to_cpup __be32_to_cpup
0108 #define cpu_to_be16p __cpu_to_be16p
0109 #define be16_to_cpup __be16_to_cpup
0110 #define cpu_to_le64s __cpu_to_le64s
0111 #define le64_to_cpus __le64_to_cpus
0112 #define cpu_to_le32s __cpu_to_le32s
0113 #define le32_to_cpus __le32_to_cpus
0114 #define cpu_to_le16s __cpu_to_le16s
0115 #define le16_to_cpus __le16_to_cpus
0116 #define cpu_to_be64s __cpu_to_be64s
0117 #define be64_to_cpus __be64_to_cpus
0118 #define cpu_to_be32s __cpu_to_be32s
0119 #define be32_to_cpus __be32_to_cpus
0120 #define cpu_to_be16s __cpu_to_be16s
0121 #define be16_to_cpus __be16_to_cpus
0122
0123
0124
0125
0126
0127
0128
0129 #undef ntohl
0130 #undef ntohs
0131 #undef htonl
0132 #undef htons
0133
0134 #define ___htonl(x) __cpu_to_be32(x)
0135 #define ___htons(x) __cpu_to_be16(x)
0136 #define ___ntohl(x) __be32_to_cpu(x)
0137 #define ___ntohs(x) __be16_to_cpu(x)
0138
0139 #define htonl(x) ___htonl(x)
0140 #define ntohl(x) ___ntohl(x)
0141 #define htons(x) ___htons(x)
0142 #define ntohs(x) ___ntohs(x)
0143
0144 static inline void le16_add_cpu(__le16 *var, u16 val)
0145 {
0146 *var = cpu_to_le16(le16_to_cpu(*var) + val);
0147 }
0148
0149 static inline void le32_add_cpu(__le32 *var, u32 val)
0150 {
0151 *var = cpu_to_le32(le32_to_cpu(*var) + val);
0152 }
0153
0154 static inline void le64_add_cpu(__le64 *var, u64 val)
0155 {
0156 *var = cpu_to_le64(le64_to_cpu(*var) + val);
0157 }
0158
0159
0160 static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
0161 {
0162 while (words--) {
0163 __le32_to_cpus(buf);
0164 buf++;
0165 }
0166 }
0167
0168 static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
0169 {
0170 while (words--) {
0171 __cpu_to_le32s(buf);
0172 buf++;
0173 }
0174 }
0175
0176 static inline void be16_add_cpu(__be16 *var, u16 val)
0177 {
0178 *var = cpu_to_be16(be16_to_cpu(*var) + val);
0179 }
0180
0181 static inline void be32_add_cpu(__be32 *var, u32 val)
0182 {
0183 *var = cpu_to_be32(be32_to_cpu(*var) + val);
0184 }
0185
0186 static inline void be64_add_cpu(__be64 *var, u64 val)
0187 {
0188 *var = cpu_to_be64(be64_to_cpu(*var) + val);
0189 }
0190
0191 static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len)
0192 {
0193 size_t i;
0194
0195 for (i = 0; i < len; i++)
0196 dst[i] = cpu_to_be32(src[i]);
0197 }
0198
0199 static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len)
0200 {
0201 size_t i;
0202
0203 for (i = 0; i < len; i++)
0204 dst[i] = be32_to_cpu(src[i]);
0205 }
0206
0207 #endif