1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_UNALIGNED_MEMMOVE_H
3 #define _LINUX_UNALIGNED_MEMMOVE_H
4
5 #include <linux/kernel.h>
6 #include <linux/string.h>
7
8 /* Use memmove here, so gcc does not insert a __builtin_memcpy. */
9
__get_unaligned_memmove16(const void * p)10 static inline u16 __get_unaligned_memmove16(const void *p)
11 {
12 u16 tmp;
13 memmove(&tmp, p, 2);
14 return tmp;
15 }
16
__get_unaligned_memmove32(const void * p)17 static inline u32 __get_unaligned_memmove32(const void *p)
18 {
19 u32 tmp;
20 memmove(&tmp, p, 4);
21 return tmp;
22 }
23
__get_unaligned_memmove64(const void * p)24 static inline u64 __get_unaligned_memmove64(const void *p)
25 {
26 u64 tmp;
27 memmove(&tmp, p, 8);
28 return tmp;
29 }
30
__put_unaligned_memmove16(u16 val,void * p)31 static inline void __put_unaligned_memmove16(u16 val, void *p)
32 {
33 memmove(p, &val, 2);
34 }
35
__put_unaligned_memmove32(u32 val,void * p)36 static inline void __put_unaligned_memmove32(u32 val, void *p)
37 {
38 memmove(p, &val, 4);
39 }
40
__put_unaligned_memmove64(u64 val,void * p)41 static inline void __put_unaligned_memmove64(u64 val, void *p)
42 {
43 memmove(p, &val, 8);
44 }
45
46 #endif /* _LINUX_UNALIGNED_MEMMOVE_H */
47