kernel: add common infrastructure for unaligned access
[linux-2.6/openmoko-kernel/knife-kernel.git] / include / linux / unaligned / memmove.h
blobeeb5a779a4fdfdd834b7202985be243db00d84f2
1 #ifndef _LINUX_UNALIGNED_MEMMOVE_H
2 #define _LINUX_UNALIGNED_MEMMOVE_H
4 #include <linux/kernel.h>
5 #include <linux/string.h>
7 /* Use memmove here, so gcc does not insert a __builtin_memcpy. */
9 static inline u16 __get_unaligned_memmove16(const void *p)
11 u16 tmp;
12 memmove(&tmp, p, 2);
13 return tmp;
16 static inline u32 __get_unaligned_memmove32(const void *p)
18 u32 tmp;
19 memmove(&tmp, p, 4);
20 return tmp;
23 static inline u64 __get_unaligned_memmove64(const void *p)
25 u64 tmp;
26 memmove(&tmp, p, 8);
27 return tmp;
30 static inline void __put_unaligned_memmove16(u16 val, void *p)
32 memmove(p, &val, 2);
35 static inline void __put_unaligned_memmove32(u32 val, void *p)
37 memmove(p, &val, 4);
40 static inline void __put_unaligned_memmove64(u64 val, void *p)
42 memmove(p, &val, 8);
45 #endif /* _LINUX_UNALIGNED_MEMMOVE_H */