All of lore.kernel.org
 help / color / mirror / Atom feed
From: Po-Hsu Lin <po-hsu.lin@canonical.com>
To: kvm@vger.kernel.org
Cc: drjones@redhat.com, po-hsu.lin@canonical.com,
	pbonzini@redhat.com, thuth@redhat.com
Subject: [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0
Date: Wed,  2 Jun 2021 16:24:43 +0800	[thread overview]
Message-ID: <20210602082443.20252-1-po-hsu.lin@canonical.com> (raw)

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


             reply	other threads:[~2021-06-02  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  8:24 Po-Hsu Lin [this message]
2021-06-02 11:50 ` [kvm-unit-tests PATCH] compiler: use __builtin_add_overflow_p for gcc >= 7.1.0 Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210602082443.20252-1-po-hsu.lin@canonical.com \
    --to=po-hsu.lin@canonical.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.