kernel: Move arches to use common unaligned access
PATCH 2/2 kernel: Move arches to use common unaligned access
Unaligned access is ok for the following arches:
cris, m68k, mn10300, powerpc, s390, x86
Arches that use the no-builtin-memcpy implementation:
h8300, m32r, xtensa
generic_le:
alpha, blackfin, ia64,
generic_be:
parisc, sparc, sparc64
generic_le or be, choice based on compiler flags:
mips, sh
m86knommu is generic_be for Coldfire, otherwise unaligned access is ok.
frv uses the no_builtin_memcpy implementation when there is an MMU configured, otherwise uses the generic be byteshifting version.
arm chooses endianness based on compiler settings, uses the byteshifting versions.
v850 is le, uses the byteshifting versions for both be and le.
Remove the now unused asm-generic implementation.
---
David, this version uses the generic C versions, but if your testing finds the handrolled frv versions were better as we've been discussing, I will restore them.
include/asm-alpha/unaligned.h | 2 +- include/asm-arm/unaligned.h | 166 +--------------------------------- include/asm-avr32/unaligned.h | 2 +- include/asm-blackfin/unaligned.h | 2 +- include/asm-cris/unaligned.h | 8 +-- include/asm-frv/unaligned.h | 184 ++----------------------------------- include/asm-generic/unaligned.h | 124 ------------------------- include/asm-h8300/unaligned.h | 11 +-- include/asm-ia64/unaligned.h | 2 +- include/asm-m32r/unaligned.h | 15 +--- include/asm-m68k/unaligned.h | 9 +-- include/asm-m68knommu/unaligned.h | 10 +-- include/asm-mips/unaligned.h | 29 ++---- include/asm-mn10300/unaligned.h | 126 +------------------------- include/asm-parisc/unaligned.h | 2 +- include/asm-powerpc/unaligned.h | 9 +-- include/asm-s390/unaligned.h | 9 +-- include/asm-sh/unaligned.h | 6 +- include/asm-sparc/unaligned.h | 2 +- include/asm-sparc64/unaligned.h | 2 +- include/asm-v850/unaligned.h | 111 +---------------------- include/asm-x86/unaligned.h | 30 +------ include/asm-xtensa/unaligned.h | 12 +-- 23 files changed, 48 insertions(+), 825 deletions(-)
include/asm-alpha/unaligned.h +1 -1
@@ -1,6 +1,6 @@#ifndef __ALPHA_UNALIGNED_H#define __ALPHA_UNALIGNED_H -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> #endif
include/asm-arm/unaligned.h +1 -165
172 lines not on this page · raw message
include/asm-avr32/unaligned.h +1 -1
@@ -11,6 +11,6 @@* optimize word loads in general. */ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #endif /* __ASM_AVR32_UNALIGNED_H */
include/asm-blackfin/unaligned.h +1 -1
@@ -1,6 +1,6 @@#ifndef __BFIN_UNALIGNED_H#define __BFIN_UNALIGNED_H -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> #endif /* __BFIN_UNALIGNED_H */
include/asm-cris/unaligned.h +1 -7
@@ -3,14 +3,8 @@/* * CRIS can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif
include/asm-frv/unaligned.h +9 -175
202 lines not on this page · raw message
include/asm-generic/unaligned.h deleted +0 -124
124 lines not on this page · raw message
include/asm-h8300/unaligned.h +1 -10
@@ -1,15 +1,6 @@#ifndef __H8300_UNALIGNED_H#define __H8300_UNALIGNED_H - -/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) +#include <linux/unaligned/no_builtin_memcpy.h> #endif
include/asm-ia64/unaligned.h +1 -1
@@ -1,6 +1,6 @@#ifndef _ASM_IA64_UNALIGNED_H#define _ASM_IA64_UNALIGNED_H -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> #endif /* _ASM_IA64_UNALIGNED_H */
include/asm-m32r/unaligned.h +1 -14
@@ -1,19 +1,6 @@#ifndef _ASM_M32R_UNALIGNED_H#define _ASM_M32R_UNALIGNED_H -/* -* For the benefit of those who are trying to port Linux to another -* architecture, here are some C-language equivalents. -*/ - -#include <asm/string.h> - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) +#include <linux/unaligned/no_builtin_memcpy.h> #endif /* _ASM_M32R_UNALIGNED_H */
include/asm-m68k/unaligned.h +1 -8
@@ -3,14 +3,7 @@/* * The m68k can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif
include/asm-m68knommu/unaligned.h +2 -8
@@ -4,19 +4,13 @@#ifdef CONFIG_COLDFIRE -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #else /* * The m68k can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif
include/asm-mips/unaligned.h +10 -19
@@ -5,25 +5,16 @@* * Copyright (C) 2007 Ralf Baechle (ralf-6z/[email protected]) */ -#ifndef __ASM_GENERIC_UNALIGNED_H -#define __ASM_GENERIC_UNALIGNED_H +#ifndef __ASM_MIPS_UNALIGNED_H +#define __ASM_MIPS_UNALIGNED_H#include <linux/compiler.h> +#if defined(__MIPSEB__) +# include <linux/unaligned/generic_be.h> +#elif defined(__MIPSEL__) +# include <linux/unaligned/generic_le.h> +#else +# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" +#endif -#define get_unaligned (ptr) \ -({ \ - struct __packed { \ - typeof(*(ptr)) __v; \ - } *__p = (void *) (ptr); \ - __p->__v; \ -}) - -#define put_unaligned (val, ptr) \ -do { \ - struct __packed { \ - typeof(*(ptr)) __v; \ - } *__p = (void *) (ptr); \ - __p->__v = (val); \ -} while(0) - -#endif /* __ASM_GENERIC_UNALIGNED_H */ +#endif /* __ASM_MIPS_UNALIGNED_H */
include/asm-mn10300/unaligned.h +3 -123
132 lines not on this page · raw message
include/asm-parisc/unaligned.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASM_PARISC_UNALIGNED_H_#define _ASM_PARISC_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #ifdef __KERNEL__struct pt_regs ;
include/asm-powerpc/unaligned.h +1 -8
@@ -5,15 +5,8 @@/* * The PowerPC can do unaligned accesses itself in big endian mode. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UNALIGNED_H */
include/asm-s390/unaligned.h +1 -8
@@ -11,14 +11,7 @@/* * The S390 can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif
include/asm-sh/unaligned.h +5 -1
@@ -2,6 +2,10 @@#define __ASM_SH_UNALIGNED_H/* SH can't handle unaligned accesses. */ -#include <asm-generic/unaligned.h> +#ifdef __LITTLE_ENDIAN__ +#include <linux/unaligned/generic_le.h> +#else +#include <linux/unaligned/generic_be.h> +#endif #endif /* __ASM_SH_UNALIGNED_H */
include/asm-sparc/unaligned.h +1 -1
@@ -1,6 +1,6 @@#ifndef _ASM_SPARC_UNALIGNED_H_#define _ASM_SPARC_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #endif /* _ASM_SPARC_UNALIGNED_H */
include/asm-sparc64/unaligned.h +1 -1
@@ -1,6 +1,6 @@#ifndef _ASM_SPARC64_UNALIGNED_H_#define _ASM_SPARC64_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #endif /* _ASM_SPARC64_UNALIGNED_H */
include/asm-v850/unaligned.h +3 -108
117 lines not on this page · raw message
include/asm-x86/unaligned.h +1 -29
@@ -3,35 +3,7 @@/* * The x86 can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -/** -* get_unaligned - get value from possibly mis-aligned location -* @ptr: pointer to value -* -* This macro should be used for accessing values larger in size than -* single bytes at locations that are expected to be improperly aligned, -* e.g. retrieving a u16 value from a location not u16-aligned. -* -* Note that unaligned accesses can be very expensive on some architectures. -*/ -#define get_unaligned (ptr) (*(ptr)) - -/** -* put_unaligned - put value to a possibly mis-aligned location -* @val: value to place -* @ptr: pointer to location -* -* This macro should be used for placing values larger in size than -* single bytes at locations that are expected to be improperly aligned, -* e.g. writing a u16 value to a location not u16-aligned. -* -* Note that unaligned accesses can be very expensive on some architectures. -*/ -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif /* _ASM_X86_UNALIGNED_H */
include/asm-xtensa/unaligned.h +1 -11
@@ -13,16 +13,6 @@#ifndef _XTENSA_UNALIGNED_H#define _XTENSA_UNALIGNED_H -#include <linux/string.h> - -/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) +#include <linux/unaligned/no_builtin_memcpy.h> #endif /* _XTENSA_UNALIGNED_H */
Signature · 1 line
1.5.5.144.g3e42
include/asm-x86/unaligned.h
Quoted 4 lines · Harvey Harrison
include/asm-x86/unaligned.h +0
-0
nice work - the x86 bits and the general concept:
Ingo
include/asm-frv/unaligned.h line 13
Quoted 5 lines · Harvey Harrison
include/asm-frv/unaligned.h +2
-3-#ifndef _ASM_UNALIGNED_H -#define _ASM_UNALIGNED_H - +#ifndef _ASM_FRV_UNALIGNED_H_ +#define _ASM_FRV_UNALIGNED_H_
Why?
Quoted 2 lines
- * impractical. So, now we fall back to using memcpy.
+ * impractical. So, now we fall back to using memmov.
That's memmove, not memmov. Any why memmove, not memcpy? Is __tmp likely to overlap with *ptr?
Also, for FRV, I think calling memmove/memcpy for MMU kernels may be the wrong thing to do... I'm sort of leaning towards doing the same thing as NOMMU kernels and just using your inline ones.
The advantage of the inline ones is that they are quicker and probably involve fewer instructions executed; whereas using memcpy/memmove may end up with smaller, but slower code. Hmmm... Maybe key on CONFIG_CC_OPTIMIZE_FOR_SIZE?
David
From: David Howells <[email protected]>
Date: Fri, 11 Apr 2008 11:11:28 +0100
Quoted 7 lines
Quoted 2 lines · Harvey Harrison
- * impractical. So, now we fall back to using memcpy.
+ * impractical. So, now we fall back to using memmov.That's memmove, not memmov. Any why memmove, not memcpy? Is
__tmplikely to overlap with *ptr?
No, I think it has something to do with what cases GCC is allowed to optimize the call inline and what cases it cannot wrt. alignment of datums.
Quoted 3 lines · David Miller
No, I think it has something to do with what cases GCC is allowed to optimize the call inline and what cases it cannot wrt. alignment of datums.
As he says in his comment, in fact.
David
Quoted 9 lines · David Howells
include/asm-frv/unaligned.h line 13
Quoted 5 lines · Harvey Harrison
include/asm-frv/unaligned.h +2
-3-#ifndef _ASM_UNALIGNED_H -#define _ASM_UNALIGNED_H - +#ifndef _ASM_FRV_UNALIGNED_H_ +#define _ASM_FRV_UNALIGNED_H_Why?
Consistency with every other arch..no other reason.
Quoted 10 lines
Quoted 3 lines
- * impractical. So, now we fall back to using memcpy.
+ * impractical. So, now we fall back to using memmov.That's memmove, not memmov. Any why memmove, not memcpy? Is
__tmplikely to overlap with *ptr?Also, for FRV, I think calling memmove/memcpy for MMU kernels may be the wrong thing to do... I'm sort of leaning towards doing the same thing as NOMMU kernels and just using your inline ones.
OK, just let me know what you decide. I'm stil open to bringing back the frv asm versions if the do end up being faster.
Quoted 5 lines
The advantage of the inline ones is that they are quicker and probably involve fewer instructions executed; whereas using memcpy/memmove may end up with smaller, but slower code. Hmmm... Maybe key on
CONFIG_CC_OPTIMIZE_FOR_SIZE?
I suppose an out-of-line version could be easily added to accomplish this. It would be identical to the byteshifting implementation-wise.
Let me know if you'd like me to spin such a patch.
Harvey
Quoted 1 line · Harvey Harrison
Consistency with every other arch..no other reason.
But not M68K(NOMMU), Alpha, Blackfin, Cris, H8300, MN10300, ..., but generally consistent with the other FRV headers (some other people have added differ).
Hmmm... It looks like MIPS is weird. That says __ASM_GENERIC_UNALIGNED_H, which is probably wrong.
David
Quoted 11 lines · David Howells
Quoted 1 line · Harvey Harrison
Consistency with every other arch..no other reason.
But not M68K(NOMMU), Alpha, Blackfin, Cris, H8300, MN10300, ..., but generally consistent with the other FRV headers (some other people have added differ).
Hmmm... It looks like MIPS is weird. That says
__ASM_GENERIC_UNALIGNED_H, which is probably wrong.David
Well, now's the time to decide on something as I'm changing every arch.
What is the general pattern used for this kind of thing? Or am I just asking what color to paint this bikeshed?
Harvey
Unaligned access is ok for the following arches:
cris, m68k, mn10300, powerpc, s390, x86
Arches that use the no-builtin-memcpy implementation:
h8300, m32r, xtensa
generic_le:
alpha, blackfin, ia64,
generic_be:
parisc, sparc, sparc64
generic_le or be, choice based on compiler flags:
mips, sh
m86knommu is generic_be for Coldfire, otherwise unaligned access is ok.
frv uses the no_builtin_memcpy implementation when there is an MMU configured, otherwise uses the generic be byteshifting version.
arm chooses endianness based on compiler settings, uses the byteshifting versions.
v850 is le, uses the byteshifting versions for both be and le.
Remove the now unused asm-generic implementation.
[revised: standardize #ifdef testing across arches _ASM_ARCH_UNALIGNED_H_ ]
--- include/asm-alpha/unaligned.h | 8 +- include/asm-arm/unaligned.h | 172 +--------------------------------- include/asm-avr32/unaligned.h | 8 +- include/asm-blackfin/unaligned.h | 8 +- include/asm-cris/unaligned.h | 14 +-- include/asm-frv/unaligned.h | 184 ++----------------------------------- include/asm-generic/unaligned.h | 124 ------------------------- include/asm-h8300/unaligned.h | 17 +--- include/asm-ia64/unaligned.h | 8 +- include/asm-m32r/unaligned.h | 21 +---- include/asm-m68k/unaligned.h | 15 +-- include/asm-m68knommu/unaligned.h | 16 +-- include/asm-mips/unaligned.h | 29 ++---- include/asm-mn10300/unaligned.h | 128 +------------------------- include/asm-parisc/unaligned.h | 2 +- include/asm-powerpc/unaligned.h | 15 +-- include/asm-s390/unaligned.h | 15 +-- include/asm-sh/unaligned.h | 12 ++- include/asm-sparc/unaligned.h | 4 +- include/asm-sparc64/unaligned.h | 4 +- include/asm-um/unaligned.h | 6 +- include/asm-v850/unaligned.h | 117 +---------------------- include/asm-x86/unaligned.h | 36 +------- include/asm-xtensa/unaligned.h | 18 +--- 24 files changed, 102 insertions(+), 879 deletions(-)
include/asm-alpha/unaligned.h +4 -4
@@ -1,6 +1,6 @@ -#ifndef __ALPHA_UNALIGNED_H -#define __ALPHA_UNALIGNED_H +#ifndef _ASM_ALPHA_UNALIGNED_H_ +#define _ASM_ALPHA_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> -#endif +#endif /* _ASM_ALPHA_UNALIGNED_H_ */
include/asm-arm/unaligned.h +4 -168
179 lines not on this page · raw message
include/asm-avr32/unaligned.h +4 -4
@@ -1,5 +1,5 @@ -#ifndef __ASM_AVR32_UNALIGNED_H -#define __ASM_AVR32_UNALIGNED_H +#ifndef _ASM_AVR32_UNALIGNED_H_ +#define _ASM_AVR32_UNALIGNED_H_/* * AVR32 can handle some unaligned accesses, depending on the
@@ -11,6 +11,6 @@* optimize word loads in general. */ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> -#endif /* __ASM_AVR32_UNALIGNED_H */ +#endif /* _ASM_AVR32_UNALIGNED_H_ */
include/asm-blackfin/unaligned.h +4 -4
@@ -1,6 +1,6 @@ -#ifndef __BFIN_UNALIGNED_H -#define __BFIN_UNALIGNED_H +#ifndef _ASM_BLACKFIN_UNALIGNED_H_ +#define _ASM_BLACKFIN_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> -#endif /* __BFIN_UNALIGNED_H */ +#endif /* _ASM_BLACKFIN_UNALIGNED_H_ */
include/asm-cris/unaligned.h +4 -10
@@ -1,16 +1,10 @@ -#ifndef __CRIS_UNALIGNED_H -#define __CRIS_UNALIGNED_H +#ifndef _ASM_CRIS_UNALIGNED_H_ +#define _ASM_CRIS_UNALIGNED_H_/* * CRIS can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ -#define get_unaligned (ptr) (*(ptr)) +#include <linux/unaligned/access_ok.h> -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) - -#endif +#endif /* _ASM_CRIS_UNALIGNED_H_ */
include/asm-frv/unaligned.h +9 -175
202 lines not on this page · raw message
include/asm-generic/unaligned.h deleted +0 -124
124 lines not on this page · raw message
include/asm-h8300/unaligned.h +4 -13
@@ -1,15 +1,6 @@ -#ifndef __H8300_UNALIGNED_H -#define __H8300_UNALIGNED_H +#ifndef _ASM_H8300_UNALIGNED_H_ +#define _ASM_H8300_UNALIGNED_H_ +#include <linux/unaligned/no_builtin_memcpy.h> -/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) - -#endif +#endif /* _ASM_H8300_UNALIGNED_H_ */
include/asm-ia64/unaligned.h +4 -4
@@ -1,6 +1,6 @@ -#ifndef _ASM_IA64_UNALIGNED_H -#define _ASM_IA64_UNALIGNED_H +#ifndef _ASM_IA64_UNALIGNED_H_ +#define _ASM_IA64_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_le.h> -#endif /* _ASM_IA64_UNALIGNED_H */ +#endif /* _ASM_IA64_UNALIGNED_H_ */
include/asm-m32r/unaligned.h +4 -17
@@ -1,19 +1,6 @@ -#ifndef _ASM_M32R_UNALIGNED_H -#define _ASM_M32R_UNALIGNED_H +#ifndef _ASM_M32R_UNALIGNED_H_ +#define _ASM_M32R_UNALIGNED_H_ -/* -* For the benefit of those who are trying to port Linux to another -* architecture, here are some C-language equivalents. -*/ +#include <linux/unaligned/no_builtin_memcpy.h> -#include <asm/string.h> - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) - -#endif /* _ASM_M32R_UNALIGNED_H */ +#endif /* _ASM_M32R_UNALIGNED_H_ */
include/asm-m68k/unaligned.h +4 -11
@@ -1,16 +1,9 @@ -#ifndef __M68K_UNALIGNED_H -#define __M68K_UNALIGNED_H +#ifndef _ASM_M68K_UNALIGNED_H_ +#define _ASM_M68K_UNALIGNED_H_/* * The m68k can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ +#include <linux/unaligned/access_ok.h> -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) - -#endif +#endif /* _ASM_M68K_UNALIGNED_H_ */
include/asm-m68knommu/unaligned.h +5 -11
@@ -1,23 +1,17 @@ -#ifndef __M68K_UNALIGNED_H -#define __M68K_UNALIGNED_H +#ifndef _ASM_M68KNOMMU_UNALIGNED_H_ +#define _ASM_M68KNOMMU_UNALIGNED_H_#ifdef CONFIG_COLDFIRE -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #else /* * The m68k can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif -#endif +#endif /* _ASM_M68KNOMMU_UNALIGNED_H_ */
include/asm-mips/unaligned.h +10 -19
@@ -5,25 +5,16 @@* * Copyright (C) 2007 Ralf Baechle (ralf-6z/[email protected]) */ -#ifndef __ASM_GENERIC_UNALIGNED_H -#define __ASM_GENERIC_UNALIGNED_H +#ifndef _ASM_MIPS_UNALIGNED_H_ +#define _ASM_MIPS_UNALIGNED_H_#include <linux/compiler.h> +#if defined(__MIPSEB__) +# include <linux/unaligned/generic_be.h> +#elif defined(__MIPSEL__) +# include <linux/unaligned/generic_le.h> +#else +# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" +#endif -#define get_unaligned (ptr) \ -({ \ - struct __packed { \ - typeof(*(ptr)) __v; \ - } *__p = (void *) (ptr); \ - __p->__v; \ -}) - -#define put_unaligned (val, ptr) \ -do { \ - struct __packed { \ - typeof(*(ptr)) __v; \ - } *__p = (void *) (ptr); \ - __p->__v = (val); \ -} while(0) - -#endif /* __ASM_GENERIC_UNALIGNED_H */ +#endif /* _ASM_MIPS_UNALIGNED_H_ */
include/asm-mn10300/unaligned.h +4 -124
133 lines not on this page · raw message
include/asm-parisc/unaligned.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASM_PARISC_UNALIGNED_H_#define _ASM_PARISC_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> #ifdef __KERNEL__struct pt_regs ;
include/asm-powerpc/unaligned.h +4 -11
@@ -1,19 +1,12 @@ -#ifndef _ASM_POWERPC_UNALIGNED_H -#define _ASM_POWERPC_UNALIGNED_H +#ifndef _ASM_POWERPC_UNALIGNED_H_ +#define _ASM_POWERPC_UNALIGNED_H_#ifdef __KERNEL__/* * The PowerPC can do unaligned accesses itself in big endian mode. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ - -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) +#include <linux/unaligned/access_ok.h> #endif /* __KERNEL__ */ -#endif /* _ASM_POWERPC_UNALIGNED_H */ +#endif /* _ASM_POWERPC_UNALIGNED_H_ */
include/asm-s390/unaligned.h +4 -11
@@ -6,19 +6,12 @@* Derived from "include/asm-i386/unaligned.h" */ -#ifndef __S390_UNALIGNED_H -#define __S390_UNALIGNED_H +#ifndef _ASM_S390_UNALIGNED_H_ +#define _ASM_S390_UNALIGNED_H_/* * The S390 can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ +#include <linux/unaligned/access_ok.h> -#define get_unaligned (ptr) (*(ptr)) - -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) - -#endif +#endif /* _ASM_S390_UNALIGNED_H_ */
include/asm-sh/unaligned.h +8 -4
@@ -1,7 +1,11 @@ -#ifndef __ASM_SH_UNALIGNED_H -#define __ASM_SH_UNALIGNED_H +#ifndef _ASM_SH_UNALIGNED_H_ +#define _ASM_SH_UNALIGNED_H_/* SH can't handle unaligned accesses. */ -#include <asm-generic/unaligned.h> +#ifdef __LITTLE_ENDIAN__ +#include <linux/unaligned/generic_le.h> +#else +#include <linux/unaligned/generic_be.h> +#endif -#endif /* __ASM_SH_UNALIGNED_H */ +#endif /* _ASM_SH_UNALIGNED_H_ */
include/asm-sparc/unaligned.h +2 -2
@@ -1,6 +1,6 @@#ifndef _ASM_SPARC_UNALIGNED_H_#define _ASM_SPARC_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> -#endif /* _ASM_SPARC_UNALIGNED_H */ +#endif /* _ASM_SPARC_UNALIGNED_H_ */
include/asm-sparc64/unaligned.h +2 -2
@@ -1,6 +1,6 @@#ifndef _ASM_SPARC64_UNALIGNED_H_#define _ASM_SPARC64_UNALIGNED_H_ -#include <asm-generic/unaligned.h> +#include <linux/unaligned/generic_be.h> -#endif /* _ASM_SPARC64_UNALIGNED_H */ +#endif /* _ASM_SPARC64_UNALIGNED_H_ */
include/asm-um/unaligned.h +3 -3
@@ -1,6 +1,6 @@ -#ifndef __UM_UNALIGNED_H -#define __UM_UNALIGNED_H +#ifndef _ASM_UM_UNALIGNED_H_ +#define _ASM_UM_UNALIGNED_H_#include "asm/arch/unaligned.h" -#endif +#endif /* _ASM_UM_UNALIGNED_H_ */
include/asm-v850/unaligned.h +6 -111
123 lines not on this page · raw message
include/asm-x86/unaligned.h +4 -32
@@ -1,37 +1,9 @@ -#ifndef _ASM_X86_UNALIGNED_H -#define _ASM_X86_UNALIGNED_H +#ifndef _ASM_X86_UNALIGNED_H_ +#define _ASM_X86_UNALIGNED_H_/* * The x86 can do unaligned accesses itself. -* -* The strange macros are there to make sure these can't -* be misused in a way that makes them not work on other -* architectures where unaligned accesses aren't as simple. */ +#include <linux/unaligned/access_ok.h> -/** -* get_unaligned - get value from possibly mis-aligned location -* @ptr: pointer to value -* -* This macro should be used for accessing values larger in size than -* single bytes at locations that are expected to be improperly aligned, -* e.g. retrieving a u16 value from a location not u16-aligned. -* -* Note that unaligned accesses can be very expensive on some architectures. -*/ -#define get_unaligned (ptr) (*(ptr)) - -/** -* put_unaligned - put value to a possibly mis-aligned location -* @val: value to place -* @ptr: pointer to location -* -* This macro should be used for placing values larger in size than -* single bytes at locations that are expected to be improperly aligned, -* e.g. writing a u16 value to a location not u16-aligned. -* -* Note that unaligned accesses can be very expensive on some architectures. -*/ -#define put_unaligned (val, ptr) ((void)( *(ptr) = (val) )) - -#endif /* _ASM_X86_UNALIGNED_H */ +#endif /* _ASM_X86_UNALIGNED_H_ */
include/asm-xtensa/unaligned.h +4 -14
@@ -10,19 +10,9 @@* Copyright (C) 2001 - 2005 Tensilica Inc. */ -#ifndef _XTENSA_UNALIGNED_H -#define _XTENSA_UNALIGNED_H +#ifndef _ASM_XTENSA_UNALIGNED_H_ +#define _ASM_XTENSA_UNALIGNED_H_ -#include <linux/string.h> +#include <linux/unaligned/no_builtin_memcpy.h> -/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ - -#define get_unaligned (ptr) \ - ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) - -#define put_unaligned (val, ptr) \ - ({ __typeof__(*(ptr)) __tmp = (val); \ - memmove((ptr), &__tmp, sizeof(*(ptr))); \ - (void)0; }) - -#endif /* _XTENSA_UNALIGNED_H */ +#endif /* _ASM_XTENSA_UNALIGNED_H_ */
Signature · 1 line
1.5.5.144.g3e42