History

endian: #define __BYTE_ORDER

Linux does not define __BYTE_ORDER in its endian header files which makes some header files bend backwards to get at the current endian. Lets #define __BYTE_ORDER in big_endian.h/litte_endian.h to make it easier for header files that are used in user space too. In userspace the convention is that 1. _both_ __LITTLE_ENDIAN and __BIG_ENDIAN are defined, 2. you have to test for e.g. __BYTE_ORDER == __BIG_ENDIAN.

Joakim Tjernlund committed 16 years ago

Commit b3b77c81 parent e47103b9 files · +8 −31Browse files

Unified · Split

9 files
  1. arch/alpha/math-emu/sfp-util.h +0 −5
  2. arch/powerpc/include/asm/sfp-machine.h +0 −6
  3. arch/s390/include/asm/sfp-util.h +0 −2
  4. arch/sh/math-emu/sfp-util.h +0 −4
  5. arch/sparc/math-emu/sfp-util_32.h +0 −6
  6. arch/sparc/math-emu/sfp-util_64.h +0 −6
  7. arch/x86/boot/compressed/relocs.c +2 −2
  8. include/linux/byteorder/big_endian.h +3 −0
  9. include/linux/byteorder/little_endian.h +3 −0
arch/alpha/math-emu/sfp-util.h+0−5
@@ -28,8 +28,3 @@ extern unsigned long __udiv_qrnnd (unsigned long *, unsigned long, · 27 unmodified lines
2828 #define UDIV_NEEDS_NORMALIZATION 1
2929
3030 #define abort() goto bad_insn
31−
32−#ifndef __LITTLE_ENDIAN
33−#define __LITTLE_ENDIAN -1
34−#endif
35−#define __BYTE_ORDER __LITTLE_ENDIAN
arch/powerpc/include/asm/sfp-machine.h+0−6
@@ -353,12 +353,6 @@ · 352 unmodified lines
353353 #define abort() \
354354 return 0
355355
356−#ifdef __BIG_ENDIAN
357−#define __BYTE_ORDER __BIG_ENDIAN
358−#else
359−#define __BYTE_ORDER __LITTLE_ENDIAN
360−#endif
361−
362356 /* Exception flags. */
363357 #define EFLAG_INVALID (1 << (31 - 2))
364358 #define EFLAG_OVERFLOW (1 << (31 - 3))
arch/s390/include/asm/sfp-util.h+0−2
@@ -73,5 +73,3 @@ extern unsigned long __udiv_qrnnd (unsigned int *, unsigned int, · 72 unmodified lines
7373 #define UDIV_NEEDS_NORMALIZATION 0
7474
7575 #define abort() return 0
76−
77−#define __BYTE_ORDER __BIG_ENDIAN
arch/sh/math-emu/sfp-util.h+0−4
@@ -66,7 +66,3 @@ · 65 unmodified lines
6666 } while (0)
6767
6868 #define abort() return 0
69−
70−#define __BYTE_ORDER __LITTLE_ENDIAN
71−
72−
arch/sparc/math-emu/sfp-util_32.h+0−6
@@ -107,9 +107,3 @@ · 106 unmodified lines
107107
108108 #define abort() \
109109 return 0
110−
111−#ifdef __BIG_ENDIAN
112−#define __BYTE_ORDER __BIG_ENDIAN
113−#else
114−#define __BYTE_ORDER __LITTLE_ENDIAN
115−#endif
arch/sparc/math-emu/sfp-util_64.h+0−6
@@ -112,9 +112,3 @@ · 111 unmodified lines
112112
113113 #define abort() \
114114 return 0
115−
116−#ifdef __BIG_ENDIAN
117−#define __BYTE_ORDER __BIG_ENDIAN
118−#else
119−#define __BYTE_ORDER __LITTLE_ENDIAN
120−#endif
arch/x86/boot/compressed/relocs.c+2−2
@@ -195,11 +195,11 @@ static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym) · 194 unmodified lines
195195
196196
197197
198−#if BYTE_ORDER == LITTLE_ENDIAN
198+#if __BYTE_ORDER == __LITTLE_ENDIAN
199199 #define le16_to_cpu(val) (val)
200200 #define le32_to_cpu(val) (val)
201201 #endif
202−#if BYTE_ORDER == BIG_ENDIAN
202+#if __BYTE_ORDER == __BIG_ENDIAN
203203 #define le16_to_cpu(val) bswap_16(val)
204204 #define le32_to_cpu(val) bswap_32(val)
205205 #endif
include/linux/byteorder/big_endian.h+3−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 #ifndef __BIG_ENDIAN_BITFIELD
88 #define __BIG_ENDIAN_BITFIELD
99 #endif
10+#ifndef __BYTE_ORDER
11+#define __BYTE_ORDER __BIG_ENDIAN
12+#endif
1013
1114 #include <linux/types.h>
1215 #include <linux/swab.h>
include/linux/byteorder/little_endian.h+3−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 #ifndef __LITTLE_ENDIAN_BITFIELD
88 #define __LITTLE_ENDIAN_BITFIELD
99 #endif
10+#ifndef __BYTE_ORDER
11+#define __BYTE_ORDER __LITTLE_ENDIAN
12+#endif
1013
1114 #include <linux/types.h>
1215 #include <linux/swab.h>