pmaports/temp/qemu/atomic-bswap.patch

62 lines
1.5 KiB
Diff
Raw Normal View History

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)