From: Marc-André Lureau <marcandre.lur...@redhat.com> 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~
And it must be linked with -latomic. Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- meson.build | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index a9ec3974bc67..a3d8af7a501b 100644 --- a/meson.build +++ b/meson.build @@ -1841,13 +1841,17 @@ if has_int128 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); + __atomic_load(&x, &y, 0); + __atomic_store(&x, &y, 0); + __atomic_compare_exchange(&x, &y, &x, 0, 0, 0); return 0; - }''') + }''', args: ['-latomic']) config_host_data.set('CONFIG_ATOMIC128', has_atomic128) + if has_atomic128 + add_global_link_arguments('-latomic', + native: false, language: ['c', 'cpp', 'objc']) + endif if not has_atomic128 has_cmpxchg128 = cc.links(''' -- 2.35.1.273.ge6ebfd0e8cbb