qemu/atomic.h-change-method-for-removing-C-qu.patch
Bruce Rogers 607fbaf071 Accepting request 827680 from home:bfrogers:branches:Virtualization
- Fix compilation errors seen with pre-release gcc 11
  atomic.h-change-method-for-removing-C-qu.patch
  help-compiler-out-by-initializing-array.patch
  s390x-Fix-stringop-truncation-issue-repo.patch

(also tweak needed to previous submission)
(also minor tweak to update_git.sh, which is needed to correctly handle the state of git repo sitting on actual release commit.

OBS-URL: https://build.opensuse.org/request/show/827680
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=560
2020-08-18 20:41:08 +00:00

108 lines
6.2 KiB
Diff

From: Bruce Rogers <brogers@suse.com>
Date: Tue, 18 Aug 2020 11:12:28 -0600
Subject: atomic.h: change method for removing C qualifier
gcc 11 is reporting warnings with the current method used to strip
qualifiers (eg const) from the variables used in some atomic functions.
In this case it's for calls from util/qht.c. Switch to using __auto_type
initialization from a 0 cast to the intended type. It appears that a const
qualifier is automatically stripped from the type when done this way,
which is what we're aiming for here.
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
include/qemu/atomic.h | 52 +++++--------------------------------------
1 file changed, 6 insertions(+), 46 deletions(-)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index ff72db51154ca9aeab8e46cfb548..fa01ac85eb4d82e2e6432559ab2e 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -18,48 +18,6 @@
/* Compiler barrier */
#define barrier() ({ asm volatile("" ::: "memory"); (void)0; })
-/* The variable that receives the old value of an atomically-accessed
- * variable must be non-qualified, because atomic builtins return values
- * through a pointer-type argument as in __atomic_load(&var, &old, MODEL).
- *
- * This macro has to handle types smaller than int manually, because of
- * implicit promotion. int and larger types, as well as pointers, can be
- * converted to a non-qualified type just by applying a binary operator.
- */
-#define typeof_strip_qual(expr) \
- typeof( \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(expr), bool) || \
- __builtin_types_compatible_p(typeof(expr), const bool) || \
- __builtin_types_compatible_p(typeof(expr), volatile bool) || \
- __builtin_types_compatible_p(typeof(expr), const volatile bool), \
- (bool)1, \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(expr), signed char) || \
- __builtin_types_compatible_p(typeof(expr), const signed char) || \
- __builtin_types_compatible_p(typeof(expr), volatile signed char) || \
- __builtin_types_compatible_p(typeof(expr), const volatile signed char), \
- (signed char)1, \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(expr), unsigned char) || \
- __builtin_types_compatible_p(typeof(expr), const unsigned char) || \
- __builtin_types_compatible_p(typeof(expr), volatile unsigned char) || \
- __builtin_types_compatible_p(typeof(expr), const volatile unsigned char), \
- (unsigned char)1, \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(expr), signed short) || \
- __builtin_types_compatible_p(typeof(expr), const signed short) || \
- __builtin_types_compatible_p(typeof(expr), volatile signed short) || \
- __builtin_types_compatible_p(typeof(expr), const volatile signed short), \
- (signed short)1, \
- __builtin_choose_expr( \
- __builtin_types_compatible_p(typeof(expr), unsigned short) || \
- __builtin_types_compatible_p(typeof(expr), const unsigned short) || \
- __builtin_types_compatible_p(typeof(expr), volatile unsigned short) || \
- __builtin_types_compatible_p(typeof(expr), const volatile unsigned short), \
- (unsigned short)1, \
- (expr)+0))))))
-
#ifdef __ATOMIC_RELAXED
/* For C11 atomic ops */
@@ -157,7 +115,7 @@
#define atomic_rcu_read(ptr) \
({ \
QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \
- typeof_strip_qual(*ptr) _val; \
+ __auto_type _val = (typeof(*ptr))0; \
atomic_rcu_read__nocheck(ptr, &_val); \
_val; \
})
@@ -170,7 +128,7 @@
#define atomic_load_acquire(ptr) \
({ \
QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \
- typeof_strip_qual(*ptr) _val; \
+ __auto_type _val = (typeof(*ptr))0; \
__atomic_load(ptr, &_val, __ATOMIC_ACQUIRE); \
_val; \
})
@@ -194,7 +152,8 @@
/* Returns the eventual value, failed or not */
#define atomic_cmpxchg__nocheck(ptr, old, new) ({ \
- typeof_strip_qual(*ptr) _old = (old); \
+ __auto_type _old = (typeof(*ptr))0; \
+ _old = (old); \
(void)__atomic_compare_exchange_n(ptr, &_old, new, false, \
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
_old; \
@@ -461,7 +420,8 @@
#endif
#define atomic_fetch_inc_nonzero(ptr) ({ \
- typeof_strip_qual(*ptr) _oldn = atomic_read(ptr); \
+ __auto_type _oldn = (typeof(*ptr))0; \
+ _oldn = atomic_read(ptr); \
while (_oldn && atomic_cmpxchg(ptr, _oldn, _oldn + 1) != _oldn) { \
_oldn = atomic_read(ptr); \
} \