* [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0
@ 2021-06-02 8:24 Po-Hsu Lin
2021-06-02 11:50 ` Andrew Jones
0 siblings, 1 reply; 2+ messages in thread
From: Po-Hsu Lin @ 2021-06-02 8:24 UTC (permalink / raw)
To: kvm; +Cc: drjones, po-hsu.lin, pbonzini, thuth
Compilation on Ubuntu Xenial 4.4.0-210-generic i386 with gcc version 5.4.0
20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) will fail with:
lib/linux/compiler.h:37:34: error: implicit declaration of function
‘__builtin_add_overflow_p’ [-Werror=implicit-function-declaration]
From the GCC document[1] it looks like this built-in function was only
introduced since 7.1.0
This can be fixed by simply changing the version check from 5.1.0 to 7.1.0
[1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Integer-Overflow-Builtins.html
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
lib/linux/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/linux/compiler.h b/lib/linux/compiler.h
index 745792a..5d9552a 100644
--- a/lib/linux/compiler.h
+++ b/lib/linux/compiler.h
@@ -30,7 +30,7 @@
__builtin_mul_overflow(a, b, &__d); \
})
#endif
-#elif GCC_VERSION >= 50100
+#elif GCC_VERSION >= 70100
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
#define check_add_overflow(a, b) __builtin_add_overflow_p(a, b, (typeof((a) + (b)))0)
#define check_sub_overflow(a, b) __builtin_add_overflow_p(a, b, (typeof((a) - (b)))0)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0
2021-06-02 8:24 [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0 Po-Hsu Lin
@ 2021-06-02 11:50 ` Andrew Jones
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Jones @ 2021-06-02 11:50 UTC (permalink / raw)
To: Po-Hsu Lin; +Cc: kvm, pbonzini, thuth
On Wed, Jun 02, 2021 at 04:24:43PM +0800, Po-Hsu Lin wrote:
> Compilation on Ubuntu Xenial 4.4.0-210-generic i386 with gcc version 5.4.0
> 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) will fail with:
> lib/linux/compiler.h:37:34: error: implicit declaration of function
> ‘__builtin_add_overflow_p’ [-Werror=implicit-function-declaration]
>
> From the GCC document[1] it looks like this built-in function was only
> introduced since 7.1.0
>
> This can be fixed by simply changing the version check from 5.1.0 to 7.1.0
>
> [1] https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Integer-Overflow-Builtins.html
>
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
> lib/linux/compiler.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/linux/compiler.h b/lib/linux/compiler.h
> index 745792a..5d9552a 100644
> --- a/lib/linux/compiler.h
> +++ b/lib/linux/compiler.h
> @@ -30,7 +30,7 @@
> __builtin_mul_overflow(a, b, &__d); \
> })
> #endif
> -#elif GCC_VERSION >= 50100
> +#elif GCC_VERSION >= 70100
> #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
> #define check_add_overflow(a, b) __builtin_add_overflow_p(a, b, (typeof((a) + (b)))0)
> #define check_sub_overflow(a, b) __builtin_add_overflow_p(a, b, (typeof((a) - (b)))0)
> --
> 2.25.1
>
Reviewed-by: Andrew Jones <drjones@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-02 11:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 8:24 [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0 Po-Hsu Lin
2021-06-02 11:50 ` Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).