[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/21] meson: fix CONFIG_ATOMIC128 check
|
From: |
marcandre . lureau |
|
Subject: |
[PULL 15/21] meson: fix CONFIG_ATOMIC128 check |
|
Date: |
Tue, 22 Mar 2022 16:25:55 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The current testing code isn't correct and matching QEMU usage:
testfile.c: In function 'main':
testfile.c:5:11: error: incorrect number of arguments to function
'__atomic_load'
5 | y = __atomic_load(&x, 0);
| ^~~~~~~~~~~~~
testfile.c:6:7: error: argument 2 of '__atomic_store' must be a pointer type
6 | __atomic_store(&x, y, 0);
| ^~~~~~~~~~~~~~
testfile.c:7:7: error: argument 3 of '__atomic_compare_exchange' must be a
pointer type
7 | __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
Replace the test with common atomics test for u64 and u128 that matches
better QEMU needs.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
meson.build | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build
index 85f3f84ec6f8..58520aab508f 100644
--- a/meson.build
+++ b/meson.build
@@ -1853,21 +1853,23 @@ config_host_data.set('HAVE_BROKEN_SIZE_MAX', not
cc.compiles('''
return printf("%zu", SIZE_MAX);
}''', args: ['-Werror']))
-# See if 64-bit atomic operations are supported.
-# Note that without __atomic builtins, we can only
-# assume atomic loads/stores max at pointer size.
-config_host_data.set('CONFIG_ATOMIC64', cc.links('''
+atomic_test = '''
#include <stdint.h>
int main(void)
{
- uint64_t x = 0, y = 0;
+ @0@ x = 0, y = 0;
y = __atomic_load_n(&x, __ATOMIC_RELAXED);
__atomic_store_n(&x, y, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED,
__ATOMIC_RELAXED);
__atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
__atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
return 0;
- }'''))
+ }'''
+
+# See if 64-bit atomic operations are supported.
+# Note that without __atomic builtins, we can only
+# assume atomic loads/stores max at pointer size.
+config_host_data.set('CONFIG_ATOMIC64',
cc.links(atomic_test.format('uint64_t')))
has_int128 = cc.links('''
__int128_t a;
@@ -1882,15 +1884,10 @@ has_int128 = cc.links('''
config_host_data.set('CONFIG_INT128', has_int128)
if has_int128
- has_atomic128 = cc.links('''
- int main(void)
- {
- unsigned __int128 x = 0, y = 0;
- y = __atomic_load(&x, 0);
- __atomic_store(&x, y, 0);
- __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
- return 0;
- }''')
+ # "do we have 128-bit atomics which are handled inline and specifically not
+ # via libatomic". The reason we can't use libatomic is documented in the
+ # comment starting "GCC is a house divided" in include/qemu/atomic128.h.
+ has_atomic128 = cc.links(atomic_test.format('unsigned __int128'))
config_host_data.set('CONFIG_ATOMIC128', has_atomic128)
--
2.35.1.273.ge6ebfd0e8cbb
- [PULL 09/21] Move HOST_LONG_BITS to compiler.h, (continued)
- [PULL 09/21] Move HOST_LONG_BITS to compiler.h, marcandre . lureau, 2022/03/22
- [PULL 05/21] Replace GCC_FMT_ATTR with G_GNUC_PRINTF, marcandre . lureau, 2022/03/22
- [PULL 07/21] compiler.h: replace QEMU_SENTINEL with G_GNUC_NULL_TERMINATED, marcandre . lureau, 2022/03/22
- [PULL 06/21] compiler.h: replace QEMU_WARN_UNUSED_RESULT with G_GNUC_WARN_UNUSED_RESULT, marcandre . lureau, 2022/03/22
- [PULL 10/21] scripts/modinfo-collect: remove unused/dead code, marcandre . lureau, 2022/03/22
- [PULL 08/21] Simplify HOST_LONG_BITS, marcandre . lureau, 2022/03/22
- [PULL 11/21] util: remove needless includes, marcandre . lureau, 2022/03/22
- [PULL 12/21] util: remove the net/net.h dependency, marcandre . lureau, 2022/03/22
- [PULL 13/21] qapi: remove needless include, marcandre . lureau, 2022/03/22
- [PULL 14/21] meson: move int128 checks from configure, marcandre . lureau, 2022/03/22
- [PULL 15/21] meson: fix CONFIG_ATOMIC128 check,
marcandre . lureau <=
- [PULL 16/21] qapi: remove needless include, marcandre . lureau, 2022/03/22
- [PULL 17/21] qga: remove bswap.h include, marcandre . lureau, 2022/03/22
- [PULL 18/21] error: use GLib to remember the program name, marcandre . lureau, 2022/03/22
- [PULL 19/21] tests: remove needless include, marcandre . lureau, 2022/03/22
- [PULL 20/21] Remove trailing ; after G_DEFINE_AUTO macro, marcandre . lureau, 2022/03/22
- [PULL 21/21] qapi: remove needless include, marcandre . lureau, 2022/03/22
- Re: [PULL 00/21] Fixes patches, Peter Maydell, 2022/03/22