[kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux