summaryrefslogtreecommitdiff
path: root/include/asm-generic/unaligned.h
AgeCommit message (Collapse)Author
2009-06-11asm-generic: add generic versions of common headersArnd Bergmann
These are all kernel internal interfaces that get copied around a lot. In most cases, architectures can provide their own optimized versions, but these generic versions can work as well. I have tried to use the most common contents of each header to allow existing architectures to migrate easily. Thanks to Remis for suggesting a number of cleanups. Signed-off-by: Remis Lima Baima <remis.developer@googlemail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2008-04-29kernel: Move arches to use common unaligned accessHarvey Harrison
Unaligned access is ok for the following arches: cris, m68k, mn10300, powerpc, s390, x86 Arches that use the memmove implementation for native endian, and the byteshifting for the opposite endianness. h8300, m32r, xtensa Packed struct for native endian, byteshifting for other endian: alpha, blackfin, ia64, parisc, sparc, sparc64, mips, sh m86knommu is generic_be for Coldfire, otherwise unaligned access is ok. frv, arm chooses endianness based on compiler settings, uses the byteshifting versions. Remove the unaligned trap handler from frv as it is now unused. v850 is le, uses the byteshifting versions for both be and le. Remove the now unused asm-generic implementation. Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-31use __val in __get_unalignedMike Frysinger
Use "__val" rather than "val" in the __get_unaligned macro in asm-generic/unaligned.h. This way gcc wont warn if you happen to also name something in the same scope "val". Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-17saner typechecking in generic unaligned.hAl Viro
Verify that types would match for assignment (under sizeof, so we are safe from side effects or any code actually getting generated), then explicitly cast everywhere to the fixed-sized types. Kills a bunch of bogus warnings about constants being truncated (gcc, sparse), finds a pile of endianness problems hidden by old noise (sparse). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2006-03-08[PATCH] __get_unaligned() gcc-4 fixAtsushi Nemoto
If the 'ptr' is a const, this code cause "assignment of read-only variable" error on gcc 4.x. Use __u64 instead of __typeof__(*(ptr)) for temporary variable to get rid of errors on gcc 4.x. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-07[PATCH] optimise 64bit unaligned access on 32bit kernelRalf Baechle
I've rewriten Atushi's fix for the 64-bit put_unaligned on 32-bit systems bug to generate more efficient code. This case has buzilla URL http://bugzilla.kernel.org/show_bug.cgi?id=5138. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-24[PATCH] __get_unaligned() turned into macroAl Viro
Turns __get_unaligned() and __put_unaligned into macros. That is definitely safe; leaving them as inlines breaks on e.g. alpha [try to build ncpfs there and you'll get unresolved symbols since we end up getting __get_unaligned() not inlined]. Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-03-16[ARCH]: Consolidate portable unaligned.h implementations.David S. Miller
Several architectures do their asm/unaligned.h support support by simply casting the pointer to a packed strcuture, then deref'ing that pointer. This forces gcc to assume the object is not aligned properly. This technique originated in Richard Henderson's asm-alpha/unaligned.h, IA64 uses the same technique as well. This works well on RISC systems for two reasons: 1) On systems like Alpha, MIPS, et al. which have special "load unaligned" instructions, GCC knows to emit them for code like this. 2) Even on systems without explicit unaligned load/store instruction support, the code emitted (basically, byte loads with shifts and ors) is about the same as what you get when emitting a memmove() call and you don't need the local stack slot. I was going to thus move asm-sparc64/unaligned.h over to such a scheme, but then I noticed that nobody actually includes the current memmove() based asm-generic/unaligned.h code. So why not put the portable packed structure implementation into asm-generic/unaligned.h and then make asm-{alpha,ia64,sparc64}/unaligned.h simply include that? I only had to make minor modifications to the alpha header when placing it into the generic area. In particular I had to convert some explicit "unsigned long", "unsigned int" et al. into the arch-agnostic "u64" "u32" etc. so that even 32-bit platforms could use this. Come to think of it I'll make sparc32 use this as well. I looked at all the other platform unaligned.h headers: I386/X86_64: can do unaligned loads directly ARM: is trying to be incredibly clever, and open codes the shifts and ors. I think it would be better if it used something similar to the packed structure technique. CRIS: like x86, can do unaligned stuff directly. FRV: needs help doing unaligned stuff, it probably also could use the packed structure stuff. H8300: needs help, could use this new asm-generic/unaligned.h header M32R: likewise M68K: can do unaligned access directly. MIPS: appears to be a copy of the original alpha/ia64 unaligned.h header, so I converted it to use the new asm-generic/unaligned.h too PARISC: is just a copy of asm-sparc/unaligned.h, so I converted it over to use asm-generic/unaligned.h too PPC/PPC64: can do unaligned access directly in big-endian mode which is what the Linux kernel runs in S390: can do it directly as well SH/SH64: just has the memmove() code ala asm-sparc/unaligned.h, I converted it to use asm-generic/unaligned.h V850: has some clever code just like ARM, so I didn't touch it. So this is the patch I came up with. Signed-off-by: David S. Miller <davem@davemloft.net>
2002-02-04Import changesetLinus Torvalds