* [PATCH v2 0/8] configure: Change to -std=gnu11
@ 2021-06-14 23:31 Richard Henderson
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
` (9 more replies)
0 siblings, 10 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
Now that we assume gcc 7.5 as a minimum, we have the option of
changing to a newer C standard. The two major new features that
I think apply are _Generic and _Static_assert.
While Paolo created a remarkably functional replacement for _Generic
using builtins, the error messages that you get out of the keyword
are *vastly* more intelligable, and the syntax is easier to read.
While I'd like to prefer _Static_assert over QEMU_BUILD_BUG_ON
going forward, and would like to convert existing uses, that is
a much bigger job. Especially since the test condition is inverted.
In the meantime, can drop the configure detection.
Changes for v2:
* Remove QEMU_LOCK_FUNC and QEMU_UNLOCK_FUNC as unused.
r~
Richard Henderson (8):
configure: Use -std=gnu11
softfloat: Use _Generic instead of QEMU_GENERIC
util: Use real functions for thread-posix QemuRecMutex
util: Pass file+line to qemu_rec_mutex_unlock_impl
util: Use unique type for QemuRecMutex in thread-posix.h
include/qemu/lockable: Use _Generic instead of QEMU_GENERIC
qemu/compiler: Remove QEMU_GENERIC
configure: Remove probe for _Static_assert
configure | 22 +--------
meson.build | 2 +-
include/qemu/compiler.h | 51 ---------------------
include/qemu/lockable.h | 90 +++++++++++++++++--------------------
include/qemu/thread-posix.h | 14 +++---
include/qemu/thread-win32.h | 6 ---
include/qemu/thread.h | 15 ++++++-
fpu/softfloat.c | 16 ++++---
util/qemu-thread-posix.c | 24 +++++++++-
util/qemu-thread-win32.c | 2 +-
10 files changed, 98 insertions(+), 144 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 1/8] configure: Use -std=gnu11
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 7:43 ` Thomas Huth
` (2 more replies)
2021-06-14 23:31 ` [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC Richard Henderson
` (8 subsequent siblings)
9 siblings, 3 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
Now that the minimum gcc version is 7.5, we can use C11.
This will allow lots of cleanups to the code, currently
hidden behind macros in include/qemu/compiler.h.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
configure | 4 ++--
meson.build | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 8dcb9965b2..0489864667 100755
--- a/configure
+++ b/configure
@@ -159,7 +159,7 @@ update_cxxflags() {
# options which some versions of GCC's C++ compiler complain about
# because they only make sense for C programs.
QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
- CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
+ CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
for arg in $QEMU_CFLAGS; do
case $arg in
-Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
@@ -538,7 +538,7 @@ QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
# Flags that are needed during configure but later taken care of by Meson
-CONFIGURE_CFLAGS="-std=gnu99 -Wall"
+CONFIGURE_CFLAGS="-std=gnu11 -Wall"
CONFIGURE_LDFLAGS=
diff --git a/meson.build b/meson.build
index a2311eda6e..d8a92666fb 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
project('qemu', ['c'], meson_version: '>=0.55.0',
- default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_colorout=auto'] +
+ default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto'] +
(meson.version().version_compare('>=0.56.0') ? [ 'b_staticpic=false' ] : []),
version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 7:48 ` Thomas Huth
2021-06-15 10:18 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex Richard Henderson
` (7 subsequent siblings)
9 siblings, 2 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 4d0160fe9c..6e769f990c 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -686,11 +686,13 @@ static float128 float128_pack_raw(const FloatParts128 *p)
#include "softfloat-specialize.c.inc"
#define PARTS_GENERIC_64_128(NAME, P) \
- QEMU_GENERIC(P, (FloatParts128 *, parts128_##NAME), parts64_##NAME)
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
+ FloatParts128 *: parts128_##NAME)
#define PARTS_GENERIC_64_128_256(NAME, P) \
- QEMU_GENERIC(P, (FloatParts256 *, parts256_##NAME), \
- (FloatParts128 *, parts128_##NAME), parts64_##NAME)
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
+ FloatParts128 *: parts128_##NAME, \
+ FloatParts256 *: parts256_##NAME)
#define parts_default_nan(P, S) PARTS_GENERIC_64_128(default_nan, P)(P, S)
#define parts_silence_nan(P, S) PARTS_GENERIC_64_128(silence_nan, P)(P, S)
@@ -892,11 +894,13 @@ static void parts128_log2(FloatParts128 *a, float_status *s, const FloatFmt *f);
*/
#define FRAC_GENERIC_64_128(NAME, P) \
- QEMU_GENERIC(P, (FloatParts128 *, frac128_##NAME), frac64_##NAME)
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
+ FloatParts128 *: frac128_##NAME)
#define FRAC_GENERIC_64_128_256(NAME, P) \
- QEMU_GENERIC(P, (FloatParts256 *, frac256_##NAME), \
- (FloatParts128 *, frac128_##NAME), frac64_##NAME)
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
+ FloatParts128 *: frac128_##NAME, \
+ FloatParts256 *: frac256_##NAME)
static bool frac64_add(FloatParts64 *r, FloatParts64 *a, FloatParts64 *b)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
2021-06-14 23:31 ` [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 7:50 ` Thomas Huth
2021-06-15 10:54 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl Richard Henderson
` (6 subsequent siblings)
9 siblings, 2 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
Move the declarations from thread-win32.h into thread.h
and remove the macro redirection from thread-posix.h.
This will be required by following cleanups.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/thread-posix.h | 4 ----
include/qemu/thread-win32.h | 6 ------
include/qemu/thread.h | 9 ++++++---
util/qemu-thread-posix.c | 20 ++++++++++++++++++++
4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
index c903525062..cf8bc90468 100644
--- a/include/qemu/thread-posix.h
+++ b/include/qemu/thread-posix.h
@@ -5,10 +5,6 @@
#include <semaphore.h>
typedef QemuMutex QemuRecMutex;
-#define qemu_rec_mutex_destroy qemu_mutex_destroy
-#define qemu_rec_mutex_lock_impl qemu_mutex_lock_impl
-#define qemu_rec_mutex_trylock_impl qemu_mutex_trylock_impl
-#define qemu_rec_mutex_unlock qemu_mutex_unlock
struct QemuMutex {
pthread_mutex_t lock;
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
index d0a1a9597e..d95af4498f 100644
--- a/include/qemu/thread-win32.h
+++ b/include/qemu/thread-win32.h
@@ -18,12 +18,6 @@ struct QemuRecMutex {
bool initialized;
};
-void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
-void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line);
-int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file,
- int line);
-void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
-
struct QemuCond {
CONDITION_VARIABLE var;
bool initialized;
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 5435763184..2c0d85f3bc 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -28,6 +28,12 @@ int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int line);
void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int line);
void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int line);
+void qemu_rec_mutex_init(QemuRecMutex *mutex);
+void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
+void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line);
+int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line);
+void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
+
typedef void (*QemuMutexLockFunc)(QemuMutex *m, const char *f, int l);
typedef int (*QemuMutexTrylockFunc)(QemuMutex *m, const char *f, int l);
typedef void (*QemuRecMutexLockFunc)(QemuRecMutex *m, const char *f, int l);
@@ -129,9 +135,6 @@ static inline int (qemu_rec_mutex_trylock)(QemuRecMutex *mutex)
return qemu_rec_mutex_trylock(mutex);
}
-/* Prototypes for other functions are in thread-posix.h/thread-win32.h. */
-void qemu_rec_mutex_init(QemuRecMutex *mutex);
-
void qemu_cond_init(QemuCond *cond);
void qemu_cond_destroy(QemuCond *cond);
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index dcff5e7c5d..8e2b6653f5 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -124,6 +124,26 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex)
mutex->initialized = true;
}
+void qemu_rec_mutex_destroy(QemuRecMutex *mutex)
+{
+ qemu_mutex_destroy(mutex);
+}
+
+void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line)
+{
+ qemu_mutex_lock_impl(mutex, file, line);
+}
+
+int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
+{
+ return qemu_mutex_trylock_impl(mutex, file, line);
+}
+
+void qemu_rec_mutex_unlock(QemuRecMutex *mutex)
+{
+ qemu_mutex_unlock(mutex);
+}
+
void qemu_cond_init(QemuCond *cond)
{
int err;
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (2 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 10:56 ` Alex Bennée
2021-06-15 13:51 ` Philippe Mathieu-Daudé
2021-06-14 23:31 ` [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Richard Henderson
` (5 subsequent siblings)
9 siblings, 2 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
Create macros for file+line expansion in qemu_rec_mutex_unlock
like we have for qemu_mutex_unlock.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/thread.h | 10 +++++++++-
util/qemu-thread-posix.c | 4 ++--
util/qemu-thread-win32.c | 2 +-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 2c0d85f3bc..460568d67d 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -32,7 +32,7 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex);
void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line);
int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line);
-void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
+void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line);
typedef void (*QemuMutexLockFunc)(QemuMutex *m, const char *f, int l);
typedef int (*QemuMutexTrylockFunc)(QemuMutex *m, const char *f, int l);
@@ -110,6 +110,9 @@ extern QemuCondTimedWaitFunc qemu_cond_timedwait_func;
#define qemu_mutex_unlock(mutex) \
qemu_mutex_unlock_impl(mutex, __FILE__, __LINE__)
+#define qemu_rec_mutex_unlock(mutex) \
+ qemu_rec_mutex_unlock_impl(mutex, __FILE__, __LINE__)
+
static inline void (qemu_mutex_lock)(QemuMutex *mutex)
{
qemu_mutex_lock(mutex);
@@ -135,6 +138,11 @@ static inline int (qemu_rec_mutex_trylock)(QemuRecMutex *mutex)
return qemu_rec_mutex_trylock(mutex);
}
+static inline void (qemu_rec_mutex_unlock)(QemuRecMutex *mutex)
+{
+ qemu_rec_mutex_unlock(mutex);
+}
+
void qemu_cond_init(QemuCond *cond);
void qemu_cond_destroy(QemuCond *cond);
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 8e2b6653f5..d990826ed8 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -139,9 +139,9 @@ int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
return qemu_mutex_trylock_impl(mutex, file, line);
}
-void qemu_rec_mutex_unlock(QemuRecMutex *mutex)
+void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line)
{
- qemu_mutex_unlock(mutex);
+ qemu_mutex_unlock_impl(mutex, file, line);
}
void qemu_cond_init(QemuCond *cond)
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index cb5aa2018c..52eb19f351 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -105,7 +105,7 @@ int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
return !TryEnterCriticalSection(&mutex->lock);
}
-void qemu_rec_mutex_unlock(QemuRecMutex *mutex)
+void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line)
{
assert(mutex->initialized);
LeaveCriticalSection(&mutex->lock);
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (3 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 7:56 ` Thomas Huth
2021-06-15 10:57 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC Richard Henderson
` (4 subsequent siblings)
9 siblings, 2 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
We will shortly convert lockable.h to _Generic, and we cannot
have two compatible types in the same expansion. Wrap QemuMutex
in a struct, and unwrap in qemu-thread-posix.c.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/thread-posix.h | 10 ++++++++--
util/qemu-thread-posix.c | 12 ++++++------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
index cf8bc90468..b792e6ef37 100644
--- a/include/qemu/thread-posix.h
+++ b/include/qemu/thread-posix.h
@@ -4,8 +4,6 @@
#include <pthread.h>
#include <semaphore.h>
-typedef QemuMutex QemuRecMutex;
-
struct QemuMutex {
pthread_mutex_t lock;
#ifdef CONFIG_DEBUG_MUTEX
@@ -15,6 +13,14 @@ struct QemuMutex {
bool initialized;
};
+/*
+ * QemuRecMutex cannot be a typedef of QemuMutex lest we have two
+ * compatible cases in _Generic. See qemu/lockable.h.
+ */
+typedef struct QemuRecMutex {
+ QemuMutex m;
+} QemuRecMutex;
+
struct QemuCond {
pthread_cond_t cond;
bool initialized;
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index d990826ed8..fd9d714038 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -116,32 +116,32 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex)
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- err = pthread_mutex_init(&mutex->lock, &attr);
+ err = pthread_mutex_init(&mutex->m.lock, &attr);
pthread_mutexattr_destroy(&attr);
if (err) {
error_exit(err, __func__);
}
- mutex->initialized = true;
+ mutex->m.initialized = true;
}
void qemu_rec_mutex_destroy(QemuRecMutex *mutex)
{
- qemu_mutex_destroy(mutex);
+ qemu_mutex_destroy(&mutex->m);
}
void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line)
{
- qemu_mutex_lock_impl(mutex, file, line);
+ qemu_mutex_lock_impl(&mutex->m, file, line);
}
int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
{
- return qemu_mutex_trylock_impl(mutex, file, line);
+ return qemu_mutex_trylock_impl(&mutex->m, file, line);
}
void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line)
{
- qemu_mutex_unlock_impl(mutex, file, line);
+ qemu_mutex_unlock_impl(&mutex->m, file, line);
}
void qemu_cond_init(QemuCond *cond)
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (4 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 11:25 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC Richard Henderson
` (3 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
This is both more and less complicated than our expansion
using __builtin_choose_expr and __builtin_types_compatible_p.
The expansion through QEMU_MAKE_LOCKABLE_ doesn't work because
we're not emumerating all of the types within the same _Generic,
which results in errors about unhandled cases. We must also
handle void* explicitly, so that the NULL constant can be used.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/lockable.h | 90 +++++++++++++++++++----------------------
1 file changed, 41 insertions(+), 49 deletions(-)
diff --git a/include/qemu/lockable.h b/include/qemu/lockable.h
index b620023141..86db7cb04c 100644
--- a/include/qemu/lockable.h
+++ b/include/qemu/lockable.h
@@ -24,79 +24,71 @@ struct QemuLockable {
QemuLockUnlockFunc *unlock;
};
-/* This function gives an error if an invalid, non-NULL pointer type is passed
- * to QEMU_MAKE_LOCKABLE. For optimized builds, we can rely on dead-code elimination
- * from the compiler, and give the errors already at link time.
- */
-#if defined(__OPTIMIZE__) && !defined(__SANITIZE_ADDRESS__)
-void unknown_lock_type(void *);
-#else
-static inline void unknown_lock_type(void *unused)
-{
- abort();
-}
-#endif
-
static inline __attribute__((__always_inline__)) QemuLockable *
qemu_make_lockable(void *x, QemuLockable *lockable)
{
- /* We cannot test this in a macro, otherwise we get compiler
+ /*
+ * We cannot test this in a macro, otherwise we get compiler
* warnings like "the address of 'm' will always evaluate as 'true'".
*/
return x ? lockable : NULL;
}
-/* Auxiliary macros to simplify QEMU_MAKE_LOCABLE. */
-#define QEMU_LOCK_FUNC(x) ((QemuLockUnlockFunc *) \
- QEMU_GENERIC(x, \
- (QemuMutex *, qemu_mutex_lock), \
- (QemuRecMutex *, qemu_rec_mutex_lock), \
- (CoMutex *, qemu_co_mutex_lock), \
- (QemuSpin *, qemu_spin_lock), \
- unknown_lock_type))
+static inline __attribute__((__always_inline__)) QemuLockable *
+qemu_null_lockable(void *x)
+{
+ if (x != NULL) {
+ qemu_build_not_reached();
+ }
+ return NULL;
+}
-#define QEMU_UNLOCK_FUNC(x) ((QemuLockUnlockFunc *) \
- QEMU_GENERIC(x, \
- (QemuMutex *, qemu_mutex_unlock), \
- (QemuRecMutex *, qemu_rec_mutex_unlock), \
- (CoMutex *, qemu_co_mutex_unlock), \
- (QemuSpin *, qemu_spin_unlock), \
- unknown_lock_type))
-
-/* In C, compound literals have the lifetime of an automatic variable.
+/*
+ * In C, compound literals have the lifetime of an automatic variable.
* In C++ it would be different, but then C++ wouldn't need QemuLockable
* either...
*/
-#define QEMU_MAKE_LOCKABLE_(x) (&(QemuLockable) { \
- .object = (x), \
- .lock = QEMU_LOCK_FUNC(x), \
- .unlock = QEMU_UNLOCK_FUNC(x), \
+#define QML_OBJ_(x, name) (&(QemuLockable) { \
+ .object = (x), \
+ .lock = (QemuLockUnlockFunc *) qemu_ ## name ## _lock, \
+ .unlock = (QemuLockUnlockFunc *) qemu_ ## name ## _unlock \
})
-/* QEMU_MAKE_LOCKABLE - Make a polymorphic QemuLockable
+/**
+ * QEMU_MAKE_LOCKABLE - Make a polymorphic QemuLockable
*
- * @x: a lock object (currently one of QemuMutex, QemuRecMutex, CoMutex, QemuSpin).
+ * @x: a lock object (currently one of QemuMutex, QemuRecMutex,
+ * CoMutex, QemuSpin).
*
* Returns a QemuLockable object that can be passed around
* to a function that can operate with locks of any kind, or
* NULL if @x is %NULL.
- */
-#define QEMU_MAKE_LOCKABLE(x) \
- QEMU_GENERIC(x, \
- (QemuLockable *, (x)), \
- qemu_make_lockable((x), QEMU_MAKE_LOCKABLE_(x)))
-
-/* QEMU_MAKE_LOCKABLE_NONNULL - Make a polymorphic QemuLockable
*
- * @x: a lock object (currently one of QemuMutex, QemuRecMutex, CoMutex, QemuSpin).
+ * Note the special case for void *, so that we may pass "NULL".
+ */
+#define QEMU_MAKE_LOCKABLE(x) \
+ _Generic((x), QemuLockable *: (x), \
+ void *: qemu_null_lockable(x), \
+ QemuMutex *: qemu_make_lockable(x, QML_OBJ_(x, mutex)), \
+ QemuRecMutex *: qemu_make_lockable(x, QML_OBJ_(x, rec_mutex)), \
+ CoMutex *: qemu_make_lockable(x, QML_OBJ_(x, co_mutex)), \
+ QemuSpin *: qemu_make_lockable(x, QML_OBJ_(x, spin)))
+
+/**
+ * QEMU_MAKE_LOCKABLE_NONNULL - Make a polymorphic QemuLockable
+ *
+ * @x: a lock object (currently one of QemuMutex, QemuRecMutex,
+ * CoMutex, QemuSpin).
*
* Returns a QemuLockable object that can be passed around
* to a function that can operate with locks of any kind.
*/
-#define QEMU_MAKE_LOCKABLE_NONNULL(x) \
- QEMU_GENERIC(x, \
- (QemuLockable *, (x)), \
- QEMU_MAKE_LOCKABLE_(x))
+#define QEMU_MAKE_LOCKABLE_NONNULL(x) \
+ _Generic((x), QemuLockable *: (x), \
+ QemuMutex *: QML_OBJ_(x, mutex), \
+ QemuRecMutex *: QML_OBJ_(x, rec_mutex), \
+ CoMutex *: QML_OBJ_(x, co_mutex), \
+ QemuSpin *: QML_OBJ_(x, spin))
static inline void qemu_lockable_lock(QemuLockable *x)
{
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (5 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 11:26 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 8/8] configure: Remove probe for _Static_assert Richard Henderson
` (2 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
All previous users now use C11 _Generic.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/compiler.h | 40 ----------------------------------------
1 file changed, 40 deletions(-)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 091c45248b..5766d61589 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -173,46 +173,6 @@
#define QEMU_ALWAYS_INLINE
#endif
-/* Implement C11 _Generic via GCC builtins. Example:
- *
- * QEMU_GENERIC(x, (float, sinf), (long double, sinl), sin) (x)
- *
- * The first argument is the discriminator. The last is the default value.
- * The middle ones are tuples in "(type, expansion)" format.
- */
-
-/* First, find out the number of generic cases. */
-#define QEMU_GENERIC(x, ...) \
- QEMU_GENERIC_(typeof(x), __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-
-/* There will be extra arguments, but they are not used. */
-#define QEMU_GENERIC_(x, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, count, ...) \
- QEMU_GENERIC##count(x, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
-
-/* Two more helper macros, this time to extract items from a parenthesized
- * list.
- */
-#define QEMU_FIRST_(a, b) a
-#define QEMU_SECOND_(a, b) b
-
-/* ... and a final one for the common part of the "recursion". */
-#define QEMU_GENERIC_IF(x, type_then, else_) \
- __builtin_choose_expr(__builtin_types_compatible_p(x, \
- QEMU_FIRST_ type_then), \
- QEMU_SECOND_ type_then, else_)
-
-/* CPP poor man's "recursion". */
-#define QEMU_GENERIC1(x, a0, ...) (a0)
-#define QEMU_GENERIC2(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC1(x, __VA_ARGS__))
-#define QEMU_GENERIC3(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC2(x, __VA_ARGS__))
-#define QEMU_GENERIC4(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC3(x, __VA_ARGS__))
-#define QEMU_GENERIC5(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC4(x, __VA_ARGS__))
-#define QEMU_GENERIC6(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC5(x, __VA_ARGS__))
-#define QEMU_GENERIC7(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC6(x, __VA_ARGS__))
-#define QEMU_GENERIC8(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC7(x, __VA_ARGS__))
-#define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, __VA_ARGS__))
-#define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x, __VA_ARGS__))
-
/**
* qemu_build_not_reached()
*
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH v2 8/8] configure: Remove probe for _Static_assert
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (6 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC Richard Henderson
@ 2021-06-14 23:31 ` Richard Henderson
2021-06-15 7:58 ` Thomas Huth
2021-06-15 10:29 ` Alex Bennée
2021-06-14 23:42 ` [PATCH v2 0/8] configure: Change to -std=gnu11 no-reply
2021-06-16 13:04 ` Paolo Bonzini
9 siblings, 2 replies; 26+ messages in thread
From: Richard Henderson @ 2021-06-14 23:31 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, thuth, ehabkost
_Static_assert is part of C11, which is now required.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
configure | 18 ------------------
include/qemu/compiler.h | 11 -----------
2 files changed, 29 deletions(-)
diff --git a/configure b/configure
index 0489864667..debd50c085 100755
--- a/configure
+++ b/configure
@@ -5090,20 +5090,6 @@ if compile_prog "" "" ; then
have_sysmacros=yes
fi
-##########################################
-# check for _Static_assert()
-
-have_static_assert=no
-cat > $TMPC << EOF
-_Static_assert(1, "success");
-int main(void) {
- return 0;
-}
-EOF
-if compile_prog "" "" ; then
- have_static_assert=yes
-fi
-
##########################################
# check for utmpx.h, it is missing e.g. on OpenBSD
@@ -6035,10 +6021,6 @@ if test "$have_sysmacros" = "yes" ; then
echo "CONFIG_SYSMACROS=y" >> $config_host_mak
fi
-if test "$have_static_assert" = "yes" ; then
- echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
-fi
-
if test "$have_utmpx" = "yes" ; then
echo "HAVE_UTMPX=y" >> $config_host_mak
fi
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 5766d61589..3baa5e3790 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -72,18 +72,7 @@
int:(x) ? -1 : 1; \
}
-/* QEMU_BUILD_BUG_MSG() emits the message given if _Static_assert is
- * supported; otherwise, it will be omitted from the compiler error
- * message (but as it remains present in the source code, it can still
- * be useful when debugging). */
-#if defined(CONFIG_STATIC_ASSERT)
#define QEMU_BUILD_BUG_MSG(x, msg) _Static_assert(!(x), msg)
-#elif defined(__COUNTER__)
-#define QEMU_BUILD_BUG_MSG(x, msg) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
- glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
-#else
-#define QEMU_BUILD_BUG_MSG(x, msg)
-#endif
#define QEMU_BUILD_BUG_ON(x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)
--
2.25.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH v2 0/8] configure: Change to -std=gnu11
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (7 preceding siblings ...)
2021-06-14 23:31 ` [PATCH v2 8/8] configure: Remove probe for _Static_assert Richard Henderson
@ 2021-06-14 23:42 ` no-reply
2021-06-16 13:04 ` Paolo Bonzini
9 siblings, 0 replies; 26+ messages in thread
From: no-reply @ 2021-06-14 23:42 UTC (permalink / raw)
To: richard.henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Patchew URL: https://patchew.org/QEMU/20210614233143.1221879-1-richard.henderson@linaro.org/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20210614233143.1221879-1-richard.henderson@linaro.org
Subject: [PATCH v2 0/8] configure: Change to -std=gnu11
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/20210614233143.1221879-1-richard.henderson@linaro.org -> patchew/20210614233143.1221879-1-richard.henderson@linaro.org
Switched to a new branch 'test'
1a974ee configure: Remove probe for _Static_assert
8a8c552 qemu/compiler: Remove QEMU_GENERIC
d52ca80 include/qemu/lockable: Use _Generic instead of QEMU_GENERIC
d751cc8 util: Use unique type for QemuRecMutex in thread-posix.h
aafe079 util: Pass file+line to qemu_rec_mutex_unlock_impl
069b4e3 util: Use real functions for thread-posix QemuRecMutex
df9952e softfloat: Use _Generic instead of QEMU_GENERIC
067736a configure: Use -std=gnu11
=== OUTPUT BEGIN ===
1/8 Checking commit 067736abd82a (configure: Use -std=gnu11)
2/8 Checking commit df9952ebdce3 (softfloat: Use _Generic instead of QEMU_GENERIC)
ERROR: spaces required around that '*' (ctx:WxO)
#22: FILE: fpu/softfloat.c:689:
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#22: FILE: fpu/softfloat.c:689:
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#23: FILE: fpu/softfloat.c:690:
+ FloatParts128 *: parts128_##NAME)
^
ERROR: spaces required around that ':' (ctx:OxW)
#23: FILE: fpu/softfloat.c:690:
+ FloatParts128 *: parts128_##NAME)
^
ERROR: spaces required around that '*' (ctx:WxO)
#28: FILE: fpu/softfloat.c:693:
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#28: FILE: fpu/softfloat.c:693:
+ _Generic((P), FloatParts64 *: parts64_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#29: FILE: fpu/softfloat.c:694:
+ FloatParts128 *: parts128_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#29: FILE: fpu/softfloat.c:694:
+ FloatParts128 *: parts128_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#30: FILE: fpu/softfloat.c:695:
+ FloatParts256 *: parts256_##NAME)
^
ERROR: spaces required around that ':' (ctx:OxW)
#30: FILE: fpu/softfloat.c:695:
+ FloatParts256 *: parts256_##NAME)
^
ERROR: spaces required around that '*' (ctx:WxO)
#39: FILE: fpu/softfloat.c:897:
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#39: FILE: fpu/softfloat.c:897:
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#40: FILE: fpu/softfloat.c:898:
+ FloatParts128 *: frac128_##NAME)
^
ERROR: spaces required around that ':' (ctx:OxW)
#40: FILE: fpu/softfloat.c:898:
+ FloatParts128 *: frac128_##NAME)
^
ERROR: spaces required around that '*' (ctx:WxO)
#45: FILE: fpu/softfloat.c:901:
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#45: FILE: fpu/softfloat.c:901:
+ _Generic((P), FloatParts64 *: frac64_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#46: FILE: fpu/softfloat.c:902:
+ FloatParts128 *: frac128_##NAME, \
^
ERROR: spaces required around that ':' (ctx:OxW)
#46: FILE: fpu/softfloat.c:902:
+ FloatParts128 *: frac128_##NAME, \
^
ERROR: spaces required around that '*' (ctx:WxO)
#47: FILE: fpu/softfloat.c:903:
+ FloatParts256 *: frac256_##NAME)
^
ERROR: spaces required around that ':' (ctx:OxW)
#47: FILE: fpu/softfloat.c:903:
+ FloatParts256 *: frac256_##NAME)
^
total: 20 errors, 0 warnings, 32 lines checked
Patch 2/8 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/8 Checking commit 069b4e39c6b3 (util: Use real functions for thread-posix QemuRecMutex)
WARNING: line over 80 characters
#63: FILE: include/qemu/thread.h:34:
+int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line);
total: 0 errors, 1 warnings, 69 lines checked
Patch 3/8 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/8 Checking commit aafe07917c3a (util: Pass file+line to qemu_rec_mutex_unlock_impl)
WARNING: line over 80 characters
#27: FILE: include/qemu/thread.h:35:
+void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line);
total: 0 errors, 1 warnings, 47 lines checked
Patch 4/8 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/8 Checking commit d751cc87cfad (util: Use unique type for QemuRecMutex in thread-posix.h)
6/8 Checking commit d52ca8068133 (include/qemu/lockable: Use _Generic instead of QEMU_GENERIC)
ERROR: spaces required around that '*' (ctx:WxO)
#117: FILE: include/qemu/lockable.h:70:
+ _Generic((x), QemuLockable *: (x), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#117: FILE: include/qemu/lockable.h:70:
+ _Generic((x), QemuLockable *: (x), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#118: FILE: include/qemu/lockable.h:71:
+ void *: qemu_null_lockable(x), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#118: FILE: include/qemu/lockable.h:71:
+ void *: qemu_null_lockable(x), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#119: FILE: include/qemu/lockable.h:72:
+ QemuMutex *: qemu_make_lockable(x, QML_OBJ_(x, mutex)), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#119: FILE: include/qemu/lockable.h:72:
+ QemuMutex *: qemu_make_lockable(x, QML_OBJ_(x, mutex)), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#120: FILE: include/qemu/lockable.h:73:
+ QemuRecMutex *: qemu_make_lockable(x, QML_OBJ_(x, rec_mutex)), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#120: FILE: include/qemu/lockable.h:73:
+ QemuRecMutex *: qemu_make_lockable(x, QML_OBJ_(x, rec_mutex)), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#121: FILE: include/qemu/lockable.h:74:
+ CoMutex *: qemu_make_lockable(x, QML_OBJ_(x, co_mutex)), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#121: FILE: include/qemu/lockable.h:74:
+ CoMutex *: qemu_make_lockable(x, QML_OBJ_(x, co_mutex)), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#122: FILE: include/qemu/lockable.h:75:
+ QemuSpin *: qemu_make_lockable(x, QML_OBJ_(x, spin)))
^
ERROR: spaces required around that ':' (ctx:OxW)
#122: FILE: include/qemu/lockable.h:75:
+ QemuSpin *: qemu_make_lockable(x, QML_OBJ_(x, spin)))
^
ERROR: spaces required around that '*' (ctx:WxO)
#138: FILE: include/qemu/lockable.h:87:
+ _Generic((x), QemuLockable *: (x), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#138: FILE: include/qemu/lockable.h:87:
+ _Generic((x), QemuLockable *: (x), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#139: FILE: include/qemu/lockable.h:88:
+ QemuMutex *: QML_OBJ_(x, mutex), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#139: FILE: include/qemu/lockable.h:88:
+ QemuMutex *: QML_OBJ_(x, mutex), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#140: FILE: include/qemu/lockable.h:89:
+ QemuRecMutex *: QML_OBJ_(x, rec_mutex), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#140: FILE: include/qemu/lockable.h:89:
+ QemuRecMutex *: QML_OBJ_(x, rec_mutex), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#141: FILE: include/qemu/lockable.h:90:
+ CoMutex *: QML_OBJ_(x, co_mutex), \
^
ERROR: spaces required around that ':' (ctx:OxW)
#141: FILE: include/qemu/lockable.h:90:
+ CoMutex *: QML_OBJ_(x, co_mutex), \
^
ERROR: spaces required around that '*' (ctx:WxO)
#142: FILE: include/qemu/lockable.h:91:
+ QemuSpin *: QML_OBJ_(x, spin))
^
ERROR: spaces required around that ':' (ctx:OxW)
#142: FILE: include/qemu/lockable.h:91:
+ QemuSpin *: QML_OBJ_(x, spin))
^
total: 22 errors, 0 warnings, 120 lines checked
Patch 6/8 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/8 Checking commit 8a8c55217a6f (qemu/compiler: Remove QEMU_GENERIC)
8/8 Checking commit 1a974eea8590 (configure: Remove probe for _Static_assert)
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20210614233143.1221879-1-richard.henderson@linaro.org/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 1/8] configure: Use -std=gnu11
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
@ 2021-06-15 7:43 ` Thomas Huth
2021-06-15 10:10 ` Alex Bennée
2021-06-15 13:49 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2021-06-15 7:43 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, ehabkost
On 15/06/2021 01.31, Richard Henderson wrote:
> Now that the minimum gcc version is 7.5, we can use C11.
> This will allow lots of cleanups to the code, currently
> hidden behind macros in include/qemu/compiler.h.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> configure | 4 ++--
> meson.build | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 8dcb9965b2..0489864667 100755
> --- a/configure
> +++ b/configure
> @@ -159,7 +159,7 @@ update_cxxflags() {
> # options which some versions of GCC's C++ compiler complain about
> # because they only make sense for C programs.
> QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
> - CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
> + CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
> for arg in $QEMU_CFLAGS; do
> case $arg in
> -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
> @@ -538,7 +538,7 @@ QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
> QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
>
> # Flags that are needed during configure but later taken care of by Meson
> -CONFIGURE_CFLAGS="-std=gnu99 -Wall"
> +CONFIGURE_CFLAGS="-std=gnu11 -Wall"
> CONFIGURE_LDFLAGS=
>
>
> diff --git a/meson.build b/meson.build
> index a2311eda6e..d8a92666fb 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1,5 +1,5 @@
> project('qemu', ['c'], meson_version: '>=0.55.0',
> - default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_colorout=auto'] +
> + default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto'] +
> (meson.version().version_compare('>=0.56.0') ? [ 'b_staticpic=false' ] : []),
> version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC
2021-06-14 23:31 ` [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC Richard Henderson
@ 2021-06-15 7:48 ` Thomas Huth
2021-06-15 10:18 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2021-06-15 7:48 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, ehabkost
On 15/06/2021 01.31, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> fpu/softfloat.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index 4d0160fe9c..6e769f990c 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -686,11 +686,13 @@ static float128 float128_pack_raw(const FloatParts128 *p)
> #include "softfloat-specialize.c.inc"
>
> #define PARTS_GENERIC_64_128(NAME, P) \
> - QEMU_GENERIC(P, (FloatParts128 *, parts128_##NAME), parts64_##NAME)
> + _Generic((P), FloatParts64 *: parts64_##NAME, \
> + FloatParts128 *: parts128_##NAME)
>
> #define PARTS_GENERIC_64_128_256(NAME, P) \
> - QEMU_GENERIC(P, (FloatParts256 *, parts256_##NAME), \
> - (FloatParts128 *, parts128_##NAME), parts64_##NAME)
> + _Generic((P), FloatParts64 *: parts64_##NAME, \
> + FloatParts128 *: parts128_##NAME, \
> + FloatParts256 *: parts256_##NAME)
>
> #define parts_default_nan(P, S) PARTS_GENERIC_64_128(default_nan, P)(P, S)
> #define parts_silence_nan(P, S) PARTS_GENERIC_64_128(silence_nan, P)(P, S)
> @@ -892,11 +894,13 @@ static void parts128_log2(FloatParts128 *a, float_status *s, const FloatFmt *f);
> */
>
> #define FRAC_GENERIC_64_128(NAME, P) \
> - QEMU_GENERIC(P, (FloatParts128 *, frac128_##NAME), frac64_##NAME)
> + _Generic((P), FloatParts64 *: frac64_##NAME, \
> + FloatParts128 *: frac128_##NAME)
>
> #define FRAC_GENERIC_64_128_256(NAME, P) \
> - QEMU_GENERIC(P, (FloatParts256 *, frac256_##NAME), \
> - (FloatParts128 *, frac128_##NAME), frac64_##NAME)
> + _Generic((P), FloatParts64 *: frac64_##NAME, \
> + FloatParts128 *: frac128_##NAME, \
> + FloatParts256 *: frac256_##NAME)
>
> static bool frac64_add(FloatParts64 *r, FloatParts64 *a, FloatParts64 *b)
> {
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex
2021-06-14 23:31 ` [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex Richard Henderson
@ 2021-06-15 7:50 ` Thomas Huth
2021-06-15 10:54 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2021-06-15 7:50 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, ehabkost
On 15/06/2021 01.31, Richard Henderson wrote:
> Move the declarations from thread-win32.h into thread.h
> and remove the macro redirection from thread-posix.h.
> This will be required by following cleanups.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/thread-posix.h | 4 ----
> include/qemu/thread-win32.h | 6 ------
> include/qemu/thread.h | 9 ++++++---
> util/qemu-thread-posix.c | 20 ++++++++++++++++++++
> 4 files changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
> index c903525062..cf8bc90468 100644
> --- a/include/qemu/thread-posix.h
> +++ b/include/qemu/thread-posix.h
> @@ -5,10 +5,6 @@
> #include <semaphore.h>
>
> typedef QemuMutex QemuRecMutex;
> -#define qemu_rec_mutex_destroy qemu_mutex_destroy
> -#define qemu_rec_mutex_lock_impl qemu_mutex_lock_impl
> -#define qemu_rec_mutex_trylock_impl qemu_mutex_trylock_impl
> -#define qemu_rec_mutex_unlock qemu_mutex_unlock
>
> struct QemuMutex {
> pthread_mutex_t lock;
> diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
> index d0a1a9597e..d95af4498f 100644
> --- a/include/qemu/thread-win32.h
> +++ b/include/qemu/thread-win32.h
> @@ -18,12 +18,6 @@ struct QemuRecMutex {
> bool initialized;
> };
>
> -void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
> -void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line);
> -int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file,
> - int line);
> -void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
> -
> struct QemuCond {
> CONDITION_VARIABLE var;
> bool initialized;
> diff --git a/include/qemu/thread.h b/include/qemu/thread.h
> index 5435763184..2c0d85f3bc 100644
> --- a/include/qemu/thread.h
> +++ b/include/qemu/thread.h
> @@ -28,6 +28,12 @@ int qemu_mutex_trylock_impl(QemuMutex *mutex, const char *file, const int line);
> void qemu_mutex_lock_impl(QemuMutex *mutex, const char *file, const int line);
> void qemu_mutex_unlock_impl(QemuMutex *mutex, const char *file, const int line);
>
> +void qemu_rec_mutex_init(QemuRecMutex *mutex);
> +void qemu_rec_mutex_destroy(QemuRecMutex *mutex);
> +void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line);
> +int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line);
> +void qemu_rec_mutex_unlock(QemuRecMutex *mutex);
> +
> typedef void (*QemuMutexLockFunc)(QemuMutex *m, const char *f, int l);
> typedef int (*QemuMutexTrylockFunc)(QemuMutex *m, const char *f, int l);
> typedef void (*QemuRecMutexLockFunc)(QemuRecMutex *m, const char *f, int l);
> @@ -129,9 +135,6 @@ static inline int (qemu_rec_mutex_trylock)(QemuRecMutex *mutex)
> return qemu_rec_mutex_trylock(mutex);
> }
>
> -/* Prototypes for other functions are in thread-posix.h/thread-win32.h. */
> -void qemu_rec_mutex_init(QemuRecMutex *mutex);
> -
> void qemu_cond_init(QemuCond *cond);
> void qemu_cond_destroy(QemuCond *cond);
>
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index dcff5e7c5d..8e2b6653f5 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -124,6 +124,26 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex)
> mutex->initialized = true;
> }
>
> +void qemu_rec_mutex_destroy(QemuRecMutex *mutex)
> +{
> + qemu_mutex_destroy(mutex);
> +}
> +
> +void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line)
> +{
> + qemu_mutex_lock_impl(mutex, file, line);
> +}
> +
> +int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
> +{
> + return qemu_mutex_trylock_impl(mutex, file, line);
> +}
> +
> +void qemu_rec_mutex_unlock(QemuRecMutex *mutex)
> +{
> + qemu_mutex_unlock(mutex);
> +}
> +
> void qemu_cond_init(QemuCond *cond)
> {
> int err;
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h
2021-06-14 23:31 ` [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Richard Henderson
@ 2021-06-15 7:56 ` Thomas Huth
2021-06-15 10:57 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2021-06-15 7:56 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, ehabkost
On 15/06/2021 01.31, Richard Henderson wrote:
> We will shortly convert lockable.h to _Generic, and we cannot
> have two compatible types in the same expansion. Wrap QemuMutex
> in a struct, and unwrap in qemu-thread-posix.c.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/thread-posix.h | 10 ++++++++--
> util/qemu-thread-posix.c | 12 ++++++------
> 2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
> index cf8bc90468..b792e6ef37 100644
> --- a/include/qemu/thread-posix.h
> +++ b/include/qemu/thread-posix.h
> @@ -4,8 +4,6 @@
> #include <pthread.h>
> #include <semaphore.h>
>
> -typedef QemuMutex QemuRecMutex;
> -
> struct QemuMutex {
> pthread_mutex_t lock;
> #ifdef CONFIG_DEBUG_MUTEX
> @@ -15,6 +13,14 @@ struct QemuMutex {
> bool initialized;
> };
>
> +/*
> + * QemuRecMutex cannot be a typedef of QemuMutex lest we have two
> + * compatible cases in _Generic. See qemu/lockable.h.
> + */
> +typedef struct QemuRecMutex {
> + QemuMutex m;
> +} QemuRecMutex;
> +
> struct QemuCond {
> pthread_cond_t cond;
> bool initialized;
> diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
> index d990826ed8..fd9d714038 100644
> --- a/util/qemu-thread-posix.c
> +++ b/util/qemu-thread-posix.c
> @@ -116,32 +116,32 @@ void qemu_rec_mutex_init(QemuRecMutex *mutex)
>
> pthread_mutexattr_init(&attr);
> pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
> - err = pthread_mutex_init(&mutex->lock, &attr);
> + err = pthread_mutex_init(&mutex->m.lock, &attr);
> pthread_mutexattr_destroy(&attr);
> if (err) {
> error_exit(err, __func__);
> }
> - mutex->initialized = true;
> + mutex->m.initialized = true;
> }
>
> void qemu_rec_mutex_destroy(QemuRecMutex *mutex)
> {
> - qemu_mutex_destroy(mutex);
> + qemu_mutex_destroy(&mutex->m);
> }
>
> void qemu_rec_mutex_lock_impl(QemuRecMutex *mutex, const char *file, int line)
> {
> - qemu_mutex_lock_impl(mutex, file, line);
> + qemu_mutex_lock_impl(&mutex->m, file, line);
> }
>
> int qemu_rec_mutex_trylock_impl(QemuRecMutex *mutex, const char *file, int line)
> {
> - return qemu_mutex_trylock_impl(mutex, file, line);
> + return qemu_mutex_trylock_impl(&mutex->m, file, line);
> }
>
> void qemu_rec_mutex_unlock_impl(QemuRecMutex *mutex, const char *file, int line)
> {
> - qemu_mutex_unlock_impl(mutex, file, line);
> + qemu_mutex_unlock_impl(&mutex->m, file, line);
> }
>
> void qemu_cond_init(QemuCond *cond)
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 8/8] configure: Remove probe for _Static_assert
2021-06-14 23:31 ` [PATCH v2 8/8] configure: Remove probe for _Static_assert Richard Henderson
@ 2021-06-15 7:58 ` Thomas Huth
2021-06-15 10:29 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Thomas Huth @ 2021-06-15 7:58 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, ehabkost
On 15/06/2021 01.31, Richard Henderson wrote:
> _Static_assert is part of C11, which is now required.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> configure | 18 ------------------
> include/qemu/compiler.h | 11 -----------
> 2 files changed, 29 deletions(-)
>
> diff --git a/configure b/configure
> index 0489864667..debd50c085 100755
> --- a/configure
> +++ b/configure
> @@ -5090,20 +5090,6 @@ if compile_prog "" "" ; then
> have_sysmacros=yes
> fi
>
> -##########################################
> -# check for _Static_assert()
> -
> -have_static_assert=no
> -cat > $TMPC << EOF
> -_Static_assert(1, "success");
> -int main(void) {
> - return 0;
> -}
> -EOF
> -if compile_prog "" "" ; then
> - have_static_assert=yes
> -fi
> -
> ##########################################
> # check for utmpx.h, it is missing e.g. on OpenBSD
>
> @@ -6035,10 +6021,6 @@ if test "$have_sysmacros" = "yes" ; then
> echo "CONFIG_SYSMACROS=y" >> $config_host_mak
> fi
>
> -if test "$have_static_assert" = "yes" ; then
> - echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
> -fi
> -
> if test "$have_utmpx" = "yes" ; then
> echo "HAVE_UTMPX=y" >> $config_host_mak
> fi
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index 5766d61589..3baa5e3790 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -72,18 +72,7 @@
> int:(x) ? -1 : 1; \
> }
>
> -/* QEMU_BUILD_BUG_MSG() emits the message given if _Static_assert is
> - * supported; otherwise, it will be omitted from the compiler error
> - * message (but as it remains present in the source code, it can still
> - * be useful when debugging). */
> -#if defined(CONFIG_STATIC_ASSERT)
> #define QEMU_BUILD_BUG_MSG(x, msg) _Static_assert(!(x), msg)
> -#elif defined(__COUNTER__)
> -#define QEMU_BUILD_BUG_MSG(x, msg) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
> - glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
> -#else
> -#define QEMU_BUILD_BUG_MSG(x, msg)
> -#endif
>
> #define QEMU_BUILD_BUG_ON(x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 1/8] configure: Use -std=gnu11
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
2021-06-15 7:43 ` Thomas Huth
@ 2021-06-15 10:10 ` Alex Bennée
2021-06-15 13:49 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:10 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> Now that the minimum gcc version is 7.5, we can use C11.
> This will allow lots of cleanups to the code, currently
> hidden behind macros in include/qemu/compiler.h.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC
2021-06-14 23:31 ` [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC Richard Henderson
2021-06-15 7:48 ` Thomas Huth
@ 2021-06-15 10:18 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:18 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 8/8] configure: Remove probe for _Static_assert
2021-06-14 23:31 ` [PATCH v2 8/8] configure: Remove probe for _Static_assert Richard Henderson
2021-06-15 7:58 ` Thomas Huth
@ 2021-06-15 10:29 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:29 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> _Static_assert is part of C11, which is now required.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex
2021-06-14 23:31 ` [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex Richard Henderson
2021-06-15 7:50 ` Thomas Huth
@ 2021-06-15 10:54 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:54 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> Move the declarations from thread-win32.h into thread.h
> and remove the macro redirection from thread-posix.h.
> This will be required by following cleanups.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl
2021-06-14 23:31 ` [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl Richard Henderson
@ 2021-06-15 10:56 ` Alex Bennée
2021-06-15 13:51 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:56 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> Create macros for file+line expansion in qemu_rec_mutex_unlock
> like we have for qemu_mutex_unlock.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h
2021-06-14 23:31 ` [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Richard Henderson
2021-06-15 7:56 ` Thomas Huth
@ 2021-06-15 10:57 ` Alex Bennée
1 sibling, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 10:57 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> We will shortly convert lockable.h to _Generic, and we cannot
> have two compatible types in the same expansion. Wrap QemuMutex
> in a struct, and unwrap in qemu-thread-posix.c.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC
2021-06-14 23:31 ` [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC Richard Henderson
@ 2021-06-15 11:25 ` Alex Bennée
0 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 11:25 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> This is both more and less complicated than our expansion
> using __builtin_choose_expr and __builtin_types_compatible_p.
>
> The expansion through QEMU_MAKE_LOCKABLE_ doesn't work because
> we're not emumerating all of the types within the same _Generic,
> which results in errors about unhandled cases. We must also
> handle void* explicitly, so that the NULL constant can be used.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
and I checked that sync-profile was still working so:
Tested-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC
2021-06-14 23:31 ` [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC Richard Henderson
@ 2021-06-15 11:26 ` Alex Bennée
0 siblings, 0 replies; 26+ messages in thread
From: Alex Bennée @ 2021-06-15 11:26 UTC (permalink / raw)
To: Richard Henderson; +Cc: pbonzini, thuth, qemu-devel, ehabkost
Richard Henderson <richard.henderson@linaro.org> writes:
> All previous users now use C11 _Generic.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 1/8] configure: Use -std=gnu11
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
2021-06-15 7:43 ` Thomas Huth
2021-06-15 10:10 ` Alex Bennée
@ 2021-06-15 13:49 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-15 13:49 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, thuth, ehabkost
On 6/15/21 1:31 AM, Richard Henderson wrote:
> Now that the minimum gcc version is 7.5, we can use C11.
> This will allow lots of cleanups to the code, currently
> hidden behind macros in include/qemu/compiler.h.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> configure | 4 ++--
> meson.build | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl
2021-06-14 23:31 ` [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl Richard Henderson
2021-06-15 10:56 ` Alex Bennée
@ 2021-06-15 13:51 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 26+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-15 13:51 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: pbonzini, thuth, ehabkost
On 6/15/21 1:31 AM, Richard Henderson wrote:
> Create macros for file+line expansion in qemu_rec_mutex_unlock
> like we have for qemu_mutex_unlock.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> include/qemu/thread.h | 10 +++++++++-
> util/qemu-thread-posix.c | 4 ++--
> util/qemu-thread-win32.c | 2 +-
> 3 files changed, 12 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v2 0/8] configure: Change to -std=gnu11
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
` (8 preceding siblings ...)
2021-06-14 23:42 ` [PATCH v2 0/8] configure: Change to -std=gnu11 no-reply
@ 2021-06-16 13:04 ` Paolo Bonzini
9 siblings, 0 replies; 26+ messages in thread
From: Paolo Bonzini @ 2021-06-16 13:04 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: thuth, ehabkost
On 15/06/21 01:31, Richard Henderson wrote:
> Now that we assume gcc 7.5 as a minimum, we have the option of
> changing to a newer C standard. The two major new features that
> I think apply are _Generic and _Static_assert.
>
> While Paolo created a remarkably functional replacement for _Generic
> using builtins, the error messages that you get out of the keyword
> are *vastly* more intelligable, and the syntax is easier to read.
>
> While I'd like to prefer _Static_assert over QEMU_BUILD_BUG_ON
> going forward, and would like to convert existing uses, that is
> a much bigger job. Especially since the test condition is inverted.
> In the meantime, can drop the configure detection.
>
> Changes for v2:
> * Remove QEMU_LOCK_FUNC and QEMU_UNLOCK_FUNC as unused.
>
>
> r~
>
>
> Richard Henderson (8):
> configure: Use -std=gnu11
> softfloat: Use _Generic instead of QEMU_GENERIC
> util: Use real functions for thread-posix QemuRecMutex
> util: Pass file+line to qemu_rec_mutex_unlock_impl
> util: Use unique type for QemuRecMutex in thread-posix.h
> include/qemu/lockable: Use _Generic instead of QEMU_GENERIC
> qemu/compiler: Remove QEMU_GENERIC
> configure: Remove probe for _Static_assert
>
> configure | 22 +--------
> meson.build | 2 +-
> include/qemu/compiler.h | 51 ---------------------
> include/qemu/lockable.h | 90 +++++++++++++++++--------------------
> include/qemu/thread-posix.h | 14 +++---
> include/qemu/thread-win32.h | 6 ---
> include/qemu/thread.h | 15 ++++++-
> fpu/softfloat.c | 16 ++++---
> util/qemu-thread-posix.c | 24 +++++++++-
> util/qemu-thread-win32.c | 2 +-
> 10 files changed, 98 insertions(+), 144 deletions(-)
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2021-06-16 13:07 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 23:31 [PATCH v2 0/8] configure: Change to -std=gnu11 Richard Henderson
2021-06-14 23:31 ` [PATCH v2 1/8] configure: Use -std=gnu11 Richard Henderson
2021-06-15 7:43 ` Thomas Huth
2021-06-15 10:10 ` Alex Bennée
2021-06-15 13:49 ` Philippe Mathieu-Daudé
2021-06-14 23:31 ` [PATCH v2 2/8] softfloat: Use _Generic instead of QEMU_GENERIC Richard Henderson
2021-06-15 7:48 ` Thomas Huth
2021-06-15 10:18 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 3/8] util: Use real functions for thread-posix QemuRecMutex Richard Henderson
2021-06-15 7:50 ` Thomas Huth
2021-06-15 10:54 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 4/8] util: Pass file+line to qemu_rec_mutex_unlock_impl Richard Henderson
2021-06-15 10:56 ` Alex Bennée
2021-06-15 13:51 ` Philippe Mathieu-Daudé
2021-06-14 23:31 ` [PATCH v2 5/8] util: Use unique type for QemuRecMutex in thread-posix.h Richard Henderson
2021-06-15 7:56 ` Thomas Huth
2021-06-15 10:57 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 6/8] include/qemu/lockable: Use _Generic instead of QEMU_GENERIC Richard Henderson
2021-06-15 11:25 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 7/8] qemu/compiler: Remove QEMU_GENERIC Richard Henderson
2021-06-15 11:26 ` Alex Bennée
2021-06-14 23:31 ` [PATCH v2 8/8] configure: Remove probe for _Static_assert Richard Henderson
2021-06-15 7:58 ` Thomas Huth
2021-06-15 10:29 ` Alex Bennée
2021-06-14 23:42 ` [PATCH v2 0/8] configure: Change to -std=gnu11 no-reply
2021-06-16 13:04 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.