[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/14] include/qemu/host-utils: Remove unused code in the *_overfl
From: |
Thomas Huth |
Subject: |
[PULL 14/14] include/qemu/host-utils: Remove unused code in the *_overflow wrappers |
Date: |
Tue, 5 Jul 2022 12:38:16 +0200 |
According to commit cec07c0b612975 the code in the #else paths was required
for GCC < 5.0 and Clang < 3.8. We don't support such old compilers
at all anymore, so we can remove these lines now. We keep the wrapper
function, though, since they are easier to read and help to make sure that
the parameters have the right types.
Message-Id: <20220701025132.303469-1-thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
include/qemu/host-utils.h | 65 ---------------------------------------
1 file changed, 65 deletions(-)
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index bc743f5e32..29f3a99878 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -376,12 +376,7 @@ static inline uint64_t uabs64(int64_t v)
*/
static inline bool sadd32_overflow(int32_t x, int32_t y, int32_t *ret)
{
-#if __has_builtin(__builtin_add_overflow) || __GNUC__ >= 5
return __builtin_add_overflow(x, y, ret);
-#else
- *ret = x + y;
- return ((*ret ^ x) & ~(x ^ y)) < 0;
-#endif
}
/**
@@ -394,12 +389,7 @@ static inline bool sadd32_overflow(int32_t x, int32_t y,
int32_t *ret)
*/
static inline bool sadd64_overflow(int64_t x, int64_t y, int64_t *ret)
{
-#if __has_builtin(__builtin_add_overflow) || __GNUC__ >= 5
return __builtin_add_overflow(x, y, ret);
-#else
- *ret = x + y;
- return ((*ret ^ x) & ~(x ^ y)) < 0;
-#endif
}
/**
@@ -412,12 +402,7 @@ static inline bool sadd64_overflow(int64_t x, int64_t y,
int64_t *ret)
*/
static inline bool uadd32_overflow(uint32_t x, uint32_t y, uint32_t *ret)
{
-#if __has_builtin(__builtin_add_overflow) || __GNUC__ >= 5
return __builtin_add_overflow(x, y, ret);
-#else
- *ret = x + y;
- return *ret < x;
-#endif
}
/**
@@ -430,12 +415,7 @@ static inline bool uadd32_overflow(uint32_t x, uint32_t y,
uint32_t *ret)
*/
static inline bool uadd64_overflow(uint64_t x, uint64_t y, uint64_t *ret)
{
-#if __has_builtin(__builtin_add_overflow) || __GNUC__ >= 5
return __builtin_add_overflow(x, y, ret);
-#else
- *ret = x + y;
- return *ret < x;
-#endif
}
/**
@@ -449,12 +429,7 @@ static inline bool uadd64_overflow(uint64_t x, uint64_t y,
uint64_t *ret)
*/
static inline bool ssub32_overflow(int32_t x, int32_t y, int32_t *ret)
{
-#if __has_builtin(__builtin_sub_overflow) || __GNUC__ >= 5
return __builtin_sub_overflow(x, y, ret);
-#else
- *ret = x - y;
- return ((*ret ^ x) & (x ^ y)) < 0;
-#endif
}
/**
@@ -468,12 +443,7 @@ static inline bool ssub32_overflow(int32_t x, int32_t y,
int32_t *ret)
*/
static inline bool ssub64_overflow(int64_t x, int64_t y, int64_t *ret)
{
-#if __has_builtin(__builtin_sub_overflow) || __GNUC__ >= 5
return __builtin_sub_overflow(x, y, ret);
-#else
- *ret = x - y;
- return ((*ret ^ x) & (x ^ y)) < 0;
-#endif
}
/**
@@ -487,12 +457,7 @@ static inline bool ssub64_overflow(int64_t x, int64_t y,
int64_t *ret)
*/
static inline bool usub32_overflow(uint32_t x, uint32_t y, uint32_t *ret)
{
-#if __has_builtin(__builtin_sub_overflow) || __GNUC__ >= 5
return __builtin_sub_overflow(x, y, ret);
-#else
- *ret = x - y;
- return x < y;
-#endif
}
/**
@@ -506,12 +471,7 @@ static inline bool usub32_overflow(uint32_t x, uint32_t y,
uint32_t *ret)
*/
static inline bool usub64_overflow(uint64_t x, uint64_t y, uint64_t *ret)
{
-#if __has_builtin(__builtin_sub_overflow) || __GNUC__ >= 5
return __builtin_sub_overflow(x, y, ret);
-#else
- *ret = x - y;
- return x < y;
-#endif
}
/**
@@ -524,13 +484,7 @@ static inline bool usub64_overflow(uint64_t x, uint64_t y,
uint64_t *ret)
*/
static inline bool smul32_overflow(int32_t x, int32_t y, int32_t *ret)
{
-#if __has_builtin(__builtin_mul_overflow) || __GNUC__ >= 5
return __builtin_mul_overflow(x, y, ret);
-#else
- int64_t z = (int64_t)x * y;
- *ret = z;
- return *ret != z;
-#endif
}
/**
@@ -543,14 +497,7 @@ static inline bool smul32_overflow(int32_t x, int32_t y,
int32_t *ret)
*/
static inline bool smul64_overflow(int64_t x, int64_t y, int64_t *ret)
{
-#if __has_builtin(__builtin_mul_overflow) || __GNUC__ >= 5
return __builtin_mul_overflow(x, y, ret);
-#else
- uint64_t hi, lo;
- muls64(&lo, &hi, x, y);
- *ret = lo;
- return hi != ((int64_t)lo >> 63);
-#endif
}
/**
@@ -563,13 +510,7 @@ static inline bool smul64_overflow(int64_t x, int64_t y,
int64_t *ret)
*/
static inline bool umul32_overflow(uint32_t x, uint32_t y, uint32_t *ret)
{
-#if __has_builtin(__builtin_mul_overflow) || __GNUC__ >= 5
return __builtin_mul_overflow(x, y, ret);
-#else
- uint64_t z = (uint64_t)x * y;
- *ret = z;
- return z > UINT32_MAX;
-#endif
}
/**
@@ -582,13 +523,7 @@ static inline bool umul32_overflow(uint32_t x, uint32_t y,
uint32_t *ret)
*/
static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret)
{
-#if __has_builtin(__builtin_mul_overflow) || __GNUC__ >= 5
return __builtin_mul_overflow(x, y, ret);
-#else
- uint64_t hi;
- mulu64(ret, &hi, x, y);
- return hi != 0;
-#endif
}
/*
--
2.31.1
- [PULL 04/14] gitlab: tweak comments in edk2/opensbi jobs, (continued)
- [PULL 04/14] gitlab: tweak comments in edk2/opensbi jobs, Thomas Huth, 2022/07/05
- [PULL 01/14] tests: fix test-cutils leaks, Thomas Huth, 2022/07/05
- [PULL 05/14] gitlab: honour QEMU_CI variable in edk2/opensbi jobs, Thomas Huth, 2022/07/05
- [PULL 07/14] tests: wait max 120 seconds for migration test status changes, Thomas Huth, 2022/07/05
- [PULL 03/14] gitlab: normalize indentation in edk2/opensbi rules, Thomas Huth, 2022/07/05
- [PULL 08/14] tests: wait for migration completion before looking for STOP event, Thomas Huth, 2022/07/05
- [PULL 10/14] tests: use consistent bandwidth/downtime limits in migration tests, Thomas Huth, 2022/07/05
- [PULL 06/14] gitlab-ci: Extend timeout for ubuntu-20.04-s390x-all to 75m, Thomas Huth, 2022/07/05
- [PULL 09/14] tests: increase migration test converge downtime to 30 seconds, Thomas Huth, 2022/07/05
- [PULL 12/14] po: add ukrainian translation, Thomas Huth, 2022/07/05
- [PULL 14/14] include/qemu/host-utils: Remove unused code in the *_overflow wrappers,
Thomas Huth <=
- [PULL 13/14] meson.build: Require a recent version of libpng, Thomas Huth, 2022/07/05
- [PULL 11/14] disas: Remove libvixl disassembler, Thomas Huth, 2022/07/05
- Re: [PULL 00/14] Testing and misc patches, Richard Henderson, 2022/07/05
- [PULL 00/14] Testing and misc patches, Thomas Huth, 2022/07/19
- [PULL 01/14] qga: treat get-guest-fsinfo as "best effort", Thomas Huth, 2022/07/19
- [PULL 05/14] tests/vm: upgrade Ubuntu 18.04 VM to 20.04, Thomas Huth, 2022/07/19
- [PULL 08/14] tests/vm: add 1GB extra memory per core, Thomas Huth, 2022/07/19
- [PULL 02/14] tests/vm: use 'cp' instead of 'ln' for temporary vm images, Thomas Huth, 2022/07/19
- [PULL 07/14] tests/vm: remove duplicate 'centos' VM test, Thomas Huth, 2022/07/19
- [PULL 09/14] tests/vm: Remove docker cross-compile test from CentOS VM, Thomas Huth, 2022/07/19