include/qemu/host-utils.h: Simplify the compiler check in mulu128()
PATCH 1/1 include/qemu/host-utils.h: Simplify the compiler check in mulu128()
We currently require at least GCC 7.4 or Clang 6.0 for compiling QEMU. GCC has __builtin_mul_overflow since version 5 already, and Clang 6.0 also provides this built-in function (see its documentation on this page:
https://releases.llvm.org/6.0.0/tools/clang/docs/LanguageExtensions.html ). So we can simplify the #if statement here.
--- include/qemu/host-utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/qemu/host-utils.h +1 -2
@@ -533,8 +533,7 @@ static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret)*/ static inline bool mulu128 (uint64_t *plow,uint64_t *phigh,uint64_t factor) { -#if defined(CONFIG_INT128 ) && \ - (__has_builtin (__builtin_mul_overflow) || __GNUC__ >=5 ) +#if defined(CONFIG_INT128 )bool res;__uint128_t r;__uint128_t f = ((__uint128_t)*phigh <<64 ) | *plow;
Signature · 1 line
2.31.1
Quoted 7 lines · Thomas Huth
We currently require at least GCC 7.4 or Clang 6.0 for compiling QEMU. GCC has
__builtin_mul_overflowsince version 5 already, and Clang 6.0 also provides this built-in function (see its documentation on this page:
https://releases.llvm.org/6.0.0/tools/clang/docs/LanguageExtensions.html ). So we can simplify the #if statement here.Signed-off-by Thomas Huth <[email protected]>
r~
Laurent Vivier
AppliedLe 21/07/2022 à 09:48, Thomas Huth a écrit :
Quoted 16 lines
We currently require at least GCC 7.4 or Clang 6.0 for compiling QEMU. GCC has
__builtin_mul_overflowsince version 5 already, and Clang 6.0 also provides this built-in function (see its documentation on this page:
https://releases.llvm.org/6.0.0/tools/clang/docs/LanguageExtensions.html ). So we can simplify the #if statement here.Signed-off-by Thomas Huth <[email protected]>--- include/qemu/host-utils.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)include/qemu/host-utils.h +0
-0
include/qemu/host-utils.h static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret) · line 539
Quoted 9 lines
include/qemu/host-utils.h +1
-2@@ -533,8 +533,7 @@ static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret)*/ static inline bool mulu128 (uint64_t *plow,uint64_t *phigh,uint64_t factor) { -#if defined(CONFIG_INT128 ) && \ - (__has_builtin (__builtin_mul_overflow) || __GNUC__ >=5 ) +#if defined(CONFIG_INT128 )bool res;__uint128_t r;__uint128_t f = ((__uint128_t)*phigh <<64 ) | *plow;
Applied to my trivial-patches branch.
Thanks,
Laurent