|
|
e0018b |
From 3b5fb8b6428dfaab39bab58d67412427f514c1f4 Mon Sep 17 00:00:00 2001
|
|
|
e0018b |
From: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
e0018b |
Date: Sat, 26 Feb 2022 17:09:55 +0530
|
|
|
e0018b |
Subject: [PATCH 142/217] util/size.h: Fix build error for GCC < 10
|
|
|
e0018b |
|
|
|
e0018b |
Building with GCC 8.4.1 results in following build error for 'util/size.c':
|
|
|
e0018b |
|
|
|
e0018b |
../util/size.h:57:16: error: missing binary operator before token "("
|
|
|
e0018b |
__has_builtin(__builtin_mul_overflow) && \
|
|
|
e0018b |
|
|
|
e0018b |
This is caused due to missing '__has_builtin' preprocessor operator in GCC
|
|
|
e0018b |
versions < 10.0.0. The patch updates the check for CLANG's availability of
|
|
|
e0018b |
__builtin_{mul,add}_overflow to prevent preprocessor from evaluating the
|
|
|
e0018b |
expression "___has_builtin(__builtin_mul_overflow) &&
|
|
|
e0018b |
__has_builtin(__builtin_add_overflow)".
|
|
|
e0018b |
|
|
|
e0018b |
Link: https://lore.kernel.org/r/20220226113955.526036-1-vaibhav@linux.ibm.com
|
|
|
e0018b |
Fixes:10653a171bc0("util/size.h: fix build for older compilers")
|
|
|
e0018b |
Reported-by: Tarun Sahu <tsahu@linux.ibm.com>
|
|
|
e0018b |
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
|
|
|
e0018b |
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
|
|
|
e0018b |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
|
e0018b |
---
|
|
|
e0018b |
util/size.h | 5 +++--
|
|
|
e0018b |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
e0018b |
|
|
|
e0018b |
diff --git a/util/size.h b/util/size.h
|
|
|
e0018b |
index 1cb0669..02baa77 100644
|
|
|
e0018b |
--- a/util/size.h
|
|
|
e0018b |
+++ b/util/size.h
|
|
|
e0018b |
@@ -53,11 +53,12 @@ static inline bool is_power_of_2(unsigned long long v)
|
|
|
e0018b |
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
|
|
|
e0018b |
#endif
|
|
|
e0018b |
|
|
|
e0018b |
-#if __clang__ && \
|
|
|
e0018b |
- __has_builtin(__builtin_mul_overflow) && \
|
|
|
e0018b |
+#if __clang__
|
|
|
e0018b |
+#if __has_builtin(__builtin_mul_overflow) && \
|
|
|
e0018b |
__has_builtin(__builtin_add_overflow)
|
|
|
e0018b |
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
|
|
|
e0018b |
#endif
|
|
|
e0018b |
+#endif
|
|
|
e0018b |
|
|
|
e0018b |
#if COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW
|
|
|
e0018b |
|
|
|
e0018b |
--
|
|
|
e0018b |
2.27.0
|
|
|
e0018b |
|