diff options
Diffstat (limited to 'include/linux/unaligned/memmove.h')
-rw-r--r-- | include/linux/unaligned/memmove.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/linux/unaligned/memmove.h b/include/linux/unaligned/memmove.h new file mode 100644 index 000000000000..eeb5a779a4fd --- /dev/null +++ b/include/linux/unaligned/memmove.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef _LINUX_UNALIGNED_MEMMOVE_H | ||
2 | #define _LINUX_UNALIGNED_MEMMOVE_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/string.h> | ||
6 | |||
7 | /* Use memmove here, so gcc does not insert a __builtin_memcpy. */ | ||
8 | |||
9 | static inline u16 __get_unaligned_memmove16(const void *p) | ||
10 | { | ||
11 | u16 tmp; | ||
12 | memmove(&tmp, p, 2); | ||
13 | return tmp; | ||
14 | } | ||
15 | |||
16 | static inline u32 __get_unaligned_memmove32(const void *p) | ||
17 | { | ||
18 | u32 tmp; | ||
19 | memmove(&tmp, p, 4); | ||
20 | return tmp; | ||
21 | } | ||
22 | |||
23 | static inline u64 __get_unaligned_memmove64(const void *p) | ||
24 | { | ||
25 | u64 tmp; | ||
26 | memmove(&tmp, p, 8); | ||
27 | return tmp; | ||
28 | } | ||
29 | |||
30 | static inline void __put_unaligned_memmove16(u16 val, void *p) | ||
31 | { | ||
32 | memmove(p, &val, 2); | ||
33 | } | ||
34 | |||
35 | static inline void __put_unaligned_memmove32(u32 val, void *p) | ||
36 | { | ||
37 | memmove(p, &val, 4); | ||
38 | } | ||
39 | |||
40 | static inline void __put_unaligned_memmove64(u64 val, void *p) | ||
41 | { | ||
42 | memmove(p, &val, 8); | ||
43 | } | ||
44 | |||
45 | #endif /* _LINUX_UNALIGNED_MEMMOVE_H */ | ||