diff options
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/meson.build b/meson.build index f71e1a1468..aef724ad3c 100644 --- a/meson.build +++ b/meson.build @@ -1853,21 +1853,57 @@ 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; + __uint128_t b; + int main (void) { + a = a + b; + b = a * b; + a = a * a; + return 0; + }''') + +config_host_data.set('CONFIG_INT128', has_int128) + +if has_int128 + # "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) + + if not has_atomic128 + has_cmpxchg128 = cc.links(''' + int main(void) + { + unsigned __int128 x = 0, y = 0; + __sync_val_compare_and_swap_16(&x, y, x); + return 0; + } + ''') + + config_host_data.set('CONFIG_CMPXCHG128', has_cmpxchg128) + endif +endif config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' #include <sys/auxv.h> |