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
28#define UDIV_NEEDS_NORMALIZATION 1 28#define UDIV_NEEDS_NORMALIZATION 1
29 29
30#define abort() goto bad_insn30#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
353#define abort() \353#define abort() \
354 return 0354 return 0
355 355
356#ifdef __BIG_ENDIAN
357#define __BYTE_ORDER __BIG_ENDIAN
358#else
359#define __BYTE_ORDER __LITTLE_ENDIAN
360#endif
361
362/* Exception flags. */356/* Exception flags. */
363#define EFLAG_INVALID (1 << (31 - 2))357#define EFLAG_INVALID (1 << (31 - 2))
364#define EFLAG_OVERFLOW (1 << (31 - 3))358#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
73#define UDIV_NEEDS_NORMALIZATION 073#define UDIV_NEEDS_NORMALIZATION 0
74 74
75#define abort() return 075#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
66 } while (0)66 } while (0)
67 67
68#define abort() return 068#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
107 107
108#define abort() \108#define abort() \
109 return 0109 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
112 112
113#define abort() \113#define abort() \
114 return 0114 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
195 195
196 196
197 197
198#if BYTE_ORDER == LITTLE_ENDIAN198#if __BYTE_ORDER == __LITTLE_ENDIAN
199#define le16_to_cpu(val) (val)199#define le16_to_cpu(val) (val)
200#define le32_to_cpu(val) (val)200#define le32_to_cpu(val) (val)
201#endif201#endif
202#if BYTE_ORDER == BIG_ENDIAN202#if __BYTE_ORDER == __BIG_ENDIAN
203#define le16_to_cpu(val) bswap_16(val)203#define le16_to_cpu(val) bswap_16(val)
204#define le32_to_cpu(val) bswap_32(val)204#define le32_to_cpu(val) bswap_32(val)
205#endif205#endif
include/linux/byteorder/big_endian.h+3−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
7#ifndef __BIG_ENDIAN_BITFIELD7#ifndef __BIG_ENDIAN_BITFIELD
8#define __BIG_ENDIAN_BITFIELD8#define __BIG_ENDIAN_BITFIELD
9#endif9#endif
10#ifndef __BYTE_ORDER
11#define __BYTE_ORDER __BIG_ENDIAN
12#endif
10 13
11#include <linux/types.h>14#include <linux/types.h>
12#include <linux/swab.h>15#include <linux/swab.h>
include/linux/byteorder/little_endian.h+3−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
7#ifndef __LITTLE_ENDIAN_BITFIELD7#ifndef __LITTLE_ENDIAN_BITFIELD
8#define __LITTLE_ENDIAN_BITFIELD8#define __LITTLE_ENDIAN_BITFIELD
9#endif9#endif
10#ifndef __BYTE_ORDER
11#define __BYTE_ORDER __LITTLE_ENDIAN
12#endif
10 13
11#include <linux/types.h>14#include <linux/types.h>
12#include <linux/swab.h>15#include <linux/swab.h>