mirror of
https://github.com/mborgerson/xemu.git
synced 2025-12-01 16:10:01 +00:00
qemu/atomic: Add aligned_{int64,uint64}_t types
Use it to avoid some clang-12 -Watomic-alignment errors, forcing some structures to be aligned and as a pointer when we have ensured that the address is aligned. Tested-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@ -271,7 +271,19 @@
|
||||
_oldn; \
|
||||
})
|
||||
|
||||
/* Abstractions to access atomically (i.e. "once") i64/u64 variables */
|
||||
/*
|
||||
* Abstractions to access atomically (i.e. "once") i64/u64 variables.
|
||||
*
|
||||
* The i386 abi is odd in that by default members are only aligned to
|
||||
* 4 bytes, which means that 8-byte types can wind up mis-aligned.
|
||||
* Clang will then warn about this, and emit a call into libatomic.
|
||||
*
|
||||
* Use of these types in structures when they will be used with atomic
|
||||
* operations can avoid this.
|
||||
*/
|
||||
typedef int64_t aligned_int64_t __attribute__((aligned(8)));
|
||||
typedef uint64_t aligned_uint64_t __attribute__((aligned(8)));
|
||||
|
||||
#ifdef CONFIG_ATOMIC64
|
||||
/* Use __nocheck because sizeof(void *) might be < sizeof(u64) */
|
||||
#define qatomic_read_i64(P) \
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
typedef struct Stat64 {
|
||||
#ifdef CONFIG_ATOMIC64
|
||||
uint64_t value;
|
||||
aligned_uint64_t value;
|
||||
#else
|
||||
uint32_t low, high;
|
||||
uint32_t lock;
|
||||
|
||||
Reference in New Issue
Block a user