1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
workaround fortify-headers, due to some callers to those function depends
on compiler to optimize away the memcpy call for atomicity.
https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06183.html
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index a684c1a..f298653 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -323,44 +323,44 @@ static inline void stb_p(void *ptr, uint8_t v)
static inline int lduw_he_p(const void *ptr)
{
uint16_t r;
- memcpy(&r, ptr, sizeof(r));
+ __builtin_memcpy(&r, ptr, sizeof(r));
return r;
}
static inline int ldsw_he_p(const void *ptr)
{
int16_t r;
- memcpy(&r, ptr, sizeof(r));
+ __builtin_memcpy(&r, ptr, sizeof(r));
return r;
}
static inline void stw_he_p(void *ptr, uint16_t v)
{
- memcpy(ptr, &v, sizeof(v));
+ __builtin_memcpy(ptr, &v, sizeof(v));
}
static inline int ldl_he_p(const void *ptr)
{
int32_t r;
- memcpy(&r, ptr, sizeof(r));
+ __builtin_memcpy(&r, ptr, sizeof(r));
return r;
}
static inline void stl_he_p(void *ptr, uint32_t v)
{
- memcpy(ptr, &v, sizeof(v));
+ __builtin_memcpy(ptr, &v, sizeof(v));
}
static inline uint64_t ldq_he_p(const void *ptr)
{
uint64_t r;
- memcpy(&r, ptr, sizeof(r));
+ __builtin_memcpy(&r, ptr, sizeof(r));
return r;
}
static inline void stq_he_p(void *ptr, uint64_t v)
{
- memcpy(ptr, &v, sizeof(v));
+ __builtin_memcpy(ptr, &v, sizeof(v));
}
static inline int lduw_le_p(const void *ptr)
|