[PATCH 1/2] configure: Don't use the __atomic_*_16 functions for testing 128-bit support

Thomas Huth posted 2 patches 4 years, 8 months ago
Maintainers: Yonggang Luo <luoyonggang@gmail.com>, Ed Maste <emaste@freebsd.org>, Li-Wen Hsu <lwhsu@freebsd.org>
[PATCH 1/2] configure: Don't use the __atomic_*_16 functions for testing 128-bit support
Posted by Thomas Huth 4 years, 8 months ago
The test for 128-bit atomics is causing trouble with FreeBSD 12.2 and
--enable-werror:

 cc -Werror -fPIE -DPIE -std=gnu99 -Wall -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -pie -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong
 config-temp/qemu-conf.c:4:7: error: implicit declaration of function '__atomic_load_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   y = __atomic_load_16(&x, 0);
       ^
 config-temp/qemu-conf.c:5:3: error: implicit declaration of function '__atomic_store_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   __atomic_store_16(&x, y, 0);
   ^
 config-temp/qemu-conf.c:5:3: note: did you mean '__atomic_load_16'?
 config-temp/qemu-conf.c:4:7: note: '__atomic_load_16' declared here
   y = __atomic_load_16(&x, 0);
       ^
 config-temp/qemu-conf.c:6:3: error: implicit declaration of function '__atomic_compare_exchange_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
   __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
   ^
 3 errors generated.

Looking for they way we are using atomic functions in QEMU, we are not
using these functions with the _16 suffix anyway. Switch to the same
functions that we use in the include/qemu/atomic.h header.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index f7d022a5db..4526af87b2 100755
--- a/configure
+++ b/configure
@@ -4761,9 +4761,9 @@ if test "$int128" = "yes"; then
 int main(void)
 {
   unsigned __int128 x = 0, y = 0;
-  y = __atomic_load_16(&x, 0);
-  __atomic_store_16(&x, y, 0);
-  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
+  y = __atomic_load(&x, 0);
+  __atomic_store(&x, y, 0);
+  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
   return 0;
 }
 EOF
-- 
2.27.0


Re: [PATCH 1/2] configure: Don't use the __atomic_*_16 functions for testing 128-bit support
Posted by Paolo Bonzini 4 years, 8 months ago
On 17/03/21 12:05, Thomas Huth wrote:
> Looking for they way we are using atomic functions in QEMU, we are not
> using these functions with the _16 suffix anyway. Switch to the same
> functions that we use in the include/qemu/atomic.h header.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>


Re: [PATCH 1/2] configure: Don't use the __atomic_*_16 functions for testing 128-bit support
Posted by Richard Henderson 4 years, 8 months ago
On 3/17/21 5:05 AM, Thomas Huth wrote:
> The test for 128-bit atomics is causing trouble with FreeBSD 12.2 and
> --enable-werror:
> 
>   cc -Werror -fPIE -DPIE -std=gnu99 -Wall -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -fstack-protector-strong -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -pie -Wl,-z,relro -Wl,-z,now -m64 -fstack-protector-strong
>   config-temp/qemu-conf.c:4:7: error: implicit declaration of function '__atomic_load_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
>     y = __atomic_load_16(&x, 0);
>         ^
>   config-temp/qemu-conf.c:5:3: error: implicit declaration of function '__atomic_store_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
>     __atomic_store_16(&x, y, 0);
>     ^
>   config-temp/qemu-conf.c:5:3: note: did you mean '__atomic_load_16'?
>   config-temp/qemu-conf.c:4:7: note: '__atomic_load_16' declared here
>     y = __atomic_load_16(&x, 0);
>         ^
>   config-temp/qemu-conf.c:6:3: error: implicit declaration of function '__atomic_compare_exchange_16' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
>     __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
>     ^
>   3 errors generated.
> 
> Looking for they way we are using atomic functions in QEMU, we are not
> using these functions with the _16 suffix anyway. Switch to the same
> functions that we use in the include/qemu/atomic.h header.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

> ---
>   configure | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index f7d022a5db..4526af87b2 100755
> --- a/configure
> +++ b/configure
> @@ -4761,9 +4761,9 @@ if test "$int128" = "yes"; then
>   int main(void)
>   {
>     unsigned __int128 x = 0, y = 0;
> -  y = __atomic_load_16(&x, 0);
> -  __atomic_store_16(&x, y, 0);
> -  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
> +  y = __atomic_load(&x, 0);
> +  __atomic_store(&x, y, 0);
> +  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
>     return 0;
>   }
>   EOF
>