summaryrefslogtreecommitdiff
path: root/target/linux/generic-2.6/patches-2.6.28/300-fix_byteorder_header.patch
blob: 5f68085a31414d68bb8e5a83e8ffc67822d2c570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
glibc headers define both __LITTLE_ENDIAN and __BIG_ENDIAN
which was tripping the check in linux/byteorder.h.  Let's
just stay out of userspace's way and use __KERN_{endian}

The old implementation got away with it as it kept the two
implementations in different headers and conditionally included
the right one.  The combined header does checks within each
function body and depends on only one being defined.

Converted the arches in mainline that have already moved to the
new header, as the other arches merge the will need simlar
fixups.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 arch/avr32/include/asm/byteorder.h |    2 +-
 arch/mips/include/asm/byteorder.h  |    4 +-
 arch/sh/include/asm/byteorder.h    |    4 +-
 arch/sparc/include/asm/byteorder.h |    2 +-
 include/linux/byteorder.h          |   84 ++++++++++++++++++------------------
 5 files changed, 48 insertions(+), 48 deletions(-)

--- a/arch/avr32/include/asm/byteorder.h
+++ b/arch/avr32/include/asm/byteorder.h
@@ -7,7 +7,7 @@
 #include <asm/types.h>
 #include <linux/compiler.h>
 
-#define __BIG_ENDIAN
+#define __KERN_BIG_ENDIAN
 #define __SWAB_64_THRU_32__
 
 #ifdef __CHECKER__
--- a/arch/mips/include/asm/byteorder.h
+++ b/arch/mips/include/asm/byteorder.h
@@ -12,9 +12,9 @@
 #include <asm/types.h>
 
 #if defined(__MIPSEB__)
-# define __BIG_ENDIAN
+# define __KERN_BIG_ENDIAN
 #elif defined(__MIPSEL__)
-# define __LITTLE_ENDIAN
+# define __KERN_LITTLE_ENDIAN
 #else
 # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
 #endif
--- a/arch/sh/include/asm/byteorder.h
+++ b/arch/sh/include/asm/byteorder.h
@@ -9,9 +9,9 @@
 #include <linux/types.h>
 
 #ifdef __LITTLE_ENDIAN__
-# define __LITTLE_ENDIAN
+# define __KERN_LITTLE_ENDIAN
 #else
-# define __BIG_ENDIAN
+# define __KERN_BIG_ENDIAN
 #endif
 
 #define __SWAB_64_THRU_32__
--- a/arch/sparc/include/asm/byteorder.h
+++ b/arch/sparc/include/asm/byteorder.h
@@ -4,7 +4,7 @@
 #include <asm/types.h>
 #include <asm/asi.h>
 
-#define __BIG_ENDIAN
+#define __KERN_BIG_ENDIAN
 
 #ifdef CONFIG_SPARC32
 #define __SWAB_64_THRU_32__
--- a/include/linux/byteorder.h
+++ b/include/linux/byteorder.h
@@ -4,33 +4,33 @@
 #include <linux/types.h>
 #include <linux/swab.h>
 
-#if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
+#if defined(__KERN_LITTLE_ENDIAN) && defined(__KERN_BIG_ENDIAN)
 # error Fix asm/byteorder.h to define one endianness
 #endif
 
-#if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
+#if !defined(__KERN_LITTLE_ENDIAN) && !defined(__KERN_BIG_ENDIAN)
 # error Fix asm/byteorder.h to define arch endianness
 #endif
 
-#ifdef __LITTLE_ENDIAN
-# undef __LITTLE_ENDIAN
-# define __LITTLE_ENDIAN 1234
+#ifdef __KERN_LITTLE_ENDIAN
+# ifndef __LITTLE_ENDIAN
+#  define __LITTLE_ENDIAN 1234
+# endif
+# ifndef __LITTLE_ENDIAN_BITFIELD
+#  define __LITTLE_ENDIAN_BITFIELD
+# endif
+#endif
+
+#ifdef __KERN_BIG_ENDIAN
+# ifndef __BIG_ENDIAN
+#  define __BIG_ENDIAN 4321
+# endif
+# ifndef __BIG_ENDIAN_BITFIELD
+#  define __BIG_ENDIAN_BITFIELD
+# endif
 #endif
 
-#ifdef __BIG_ENDIAN
-# undef __BIG_ENDIAN
-# define __BIG_ENDIAN 4321
-#endif
-
-#if defined(__LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN_BITFIELD)
-# define __LITTLE_ENDIAN_BITFIELD
-#endif
-
-#if defined(__BIG_ENDIAN) && !defined(__BIG_ENDIAN_BITFIELD)
-# define __BIG_ENDIAN_BITFIELD
-#endif
-
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 # define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
 # define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
 # define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
@@ -46,7 +46,7 @@
 # define __cpu_to_be64(x) ((__force __be64)__swab64(x))
 #endif
 
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 # define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
 # define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
 # define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
@@ -87,91 +87,91 @@
 
 static inline void __le16_to_cpus(__u16 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab16s(p);
 #endif
 }
 
 static inline void __cpu_to_le16s(__u16 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab16s(p);
 #endif
 }
 
 static inline void __le32_to_cpus(__u32 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab32s(p);
 #endif
 }
 
 static inline void __cpu_to_le32s(__u32 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab32s(p);
 #endif
 }
 
 static inline void __le64_to_cpus(__u64 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab64s(p);
 #endif
 }
 
 static inline void __cpu_to_le64s(__u64 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	__swab64s(p);
 #endif
 }
 
 static inline void __be16_to_cpus(__u16 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab16s(p);
 #endif
 }
 
 static inline void __cpu_to_be16s(__u16 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab16s(p);
 #endif
 }
 
 static inline void __be32_to_cpus(__u32 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab32s(p);
 #endif
 }
 
 static inline void __cpu_to_be32s(__u32 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab32s(p);
 #endif
 }
 
 static inline void __be64_to_cpus(__u64 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab64s(p);
 #endif
 }
 
 static inline void __cpu_to_be64s(__u64 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	__swab64s(p);
 #endif
 }
 
 static inline __u16 __le16_to_cpup(const __le16 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __u16)*p;
 #else
 	return __swab16p((__force __u16 *)p);
@@ -180,7 +180,7 @@ static inline __u16 __le16_to_cpup(const
 
 static inline __u32 __le32_to_cpup(const __le32 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __u32)*p;
 #else
 	return __swab32p((__force __u32 *)p);
@@ -189,7 +189,7 @@ static inline __u32 __le32_to_cpup(const
 
 static inline __u64 __le64_to_cpup(const __le64 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __u64)*p;
 #else
 	return __swab64p((__force __u64 *)p);
@@ -198,7 +198,7 @@ static inline __u64 __le64_to_cpup(const
 
 static inline __le16 __cpu_to_le16p(const __u16 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __le16)*p;
 #else
 	return (__force __le16)__swab16p(p);
@@ -207,7 +207,7 @@ static inline __le16 __cpu_to_le16p(cons
 
 static inline __le32 __cpu_to_le32p(const __u32 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __le32)*p;
 #else
 	return (__force __le32)__swab32p(p);
@@ -216,7 +216,7 @@ static inline __le32 __cpu_to_le32p(cons
 
 static inline __le64 __cpu_to_le64p(const __u64 *p)
 {
-#ifdef __LITTLE_ENDIAN
+#ifdef __KERN_LITTLE_ENDIAN
 	return (__force __le64)*p;
 #else
 	return (__force __le64)__swab64p(p);
@@ -225,7 +225,7 @@ static inline __le64 __cpu_to_le64p(cons
 
 static inline __u16 __be16_to_cpup(const __be16 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __u16)*p;
 #else
 	return __swab16p((__force __u16 *)p);
@@ -234,7 +234,7 @@ static inline __u16 __be16_to_cpup(const
 
 static inline __u32 __be32_to_cpup(const __be32 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __u32)*p;
 #else
 	return __swab32p((__force __u32 *)p);
@@ -243,7 +243,7 @@ static inline __u32 __be32_to_cpup(const
 
 static inline __u64 __be64_to_cpup(const __be64 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __u64)*p;
 #else
 	return __swab64p((__force __u64 *)p);
@@ -252,7 +252,7 @@ static inline __u64 __be64_to_cpup(const
 
 static inline __be16 __cpu_to_be16p(const __u16 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __be16)*p;
 #else
 	return (__force __be16)__swab16p(p);
@@ -261,7 +261,7 @@ static inline __be16 __cpu_to_be16p(cons
 
 static inline __be32 __cpu_to_be32p(const __u32 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __be32)*p;
 #else
 	return (__force __be32)__swab32p(p);
@@ -270,7 +270,7 @@ static inline __be32 __cpu_to_be32p(cons
 
 static inline __be64 __cpu_to_be64p(const __u64 *p)
 {
-#ifdef __BIG_ENDIAN
+#ifdef __KERN_BIG_ENDIAN
 	return (__force __be64)*p;
 #else
 	return (__force __be64)__swab64p(p);