blob: ac71b53bc6dcc3fc1f7cd2fa65ca4762dc8c5687 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Harvey Harrison064106a2008-04-29 01:03:27 -07002#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
10static inline u16 __get_unaligned_memmove16(const void *p)
11{
12 u16 tmp;
13 memmove(&tmp, p, 2);
14 return tmp;
15}
16
17static inline u32 __get_unaligned_memmove32(const void *p)
18{
19 u32 tmp;
20 memmove(&tmp, p, 4);
21 return tmp;
22}
23
24static inline u64 __get_unaligned_memmove64(const void *p)
25{
26 u64 tmp;
27 memmove(&tmp, p, 8);
28 return tmp;
29}
30
31static inline void __put_unaligned_memmove16(u16 val, void *p)
32{
33 memmove(p, &val, 2);
34}
35
36static inline void __put_unaligned_memmove32(u32 val, void *p)
37{
38 memmove(p, &val, 4);
39}
40
41static inline void __put_unaligned_memmove64(u64 val, void *p)
42{
43 memmove(p, &val, 8);
44}
45
46#endif /* _LINUX_UNALIGNED_MEMMOVE_H */