qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hw/display/qxl: Suppress clang-7 warning about


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] hw/display/qxl: Suppress clang-7 warning about misaligned atomic operation
Date: Fri, 5 Oct 2018 09:13:46 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0

On 9/27/18 10:55 AM, Peter Maydell wrote:

Newer Spice versions (with Spice commit
beda5ec7a6848be20c0cac2a9a8ef2a41e8069c1) will fix the bug;
for older Spice versions, work around it by telling the compiler
explicitly that the alignment is OK using __builtin_assume_aligned().

Signed-off-by: Peter Maydell <address@hidden>
---
  include/qemu/compiler.h |  9 +++++++++
  hw/display/qxl.c        | 26 +++++++++++++++++++++++++-
  2 files changed, 34 insertions(+), 1 deletion(-)


+#ifdef HAS_ASSUME_ALIGNED
+#define ALIGNED_UINT32_PTR(P) ((uint32_t *)__builtin_assume_aligned(P, 4))
+#else
+#define ALIGNED_UINT32_PTR(P) ((uint32_t *)P)
+#endif
+
+    old_pending = atomic_fetch_or(ALIGNED_UINT32_PTR(&d->ram->int_pending),

The only client of your macro is not impacted, but if you want to be technically robust against all future uses of the macro, the fallback is underparenthesized, and would be safer as:

#define ALIGNED_UINT32_PTR(P) ((uint32_t *)(P))

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]