diff options
author | Janne Koskinen <janne.p.koskinen@qt.io> | 2018-10-24 14:57:44 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2018-11-07 10:32:44 +0000 |
commit | efc7e02911f2244c693fe8336f7b4b1c0ea3bc09 (patch) | |
tree | 20db217bf24d02cf61f383d12a6b8fe8b815e3c0 /src/corelib/global | |
parent | b3ae87fe765fe6ad005760d6370f2674873fead7 (diff) |
INTEGRITY: Fix missing uint/int 128 support for 64-bit ARM
Add 64bit specializations for mul_overflow.
Change-Id: I8bba69233dd71b94346983a100cf4d69bfc686f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qnumeric_p.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 9c8514f5a3..e318c3759b 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -64,6 +64,10 @@ #include <float.h> #endif +# if defined(Q_OS_INTEGRITY) && defined(Q_PROCESSOR_ARM_64) +#include <arm64_ghs.h> +#endif + #if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || defined(Q_CC_INTEL)) # include <math.h> # ifdef isnan @@ -323,6 +327,38 @@ mul_overflow(T v1, T v2, T *r) return lr > std::numeric_limits<T>::max() || lr < std::numeric_limits<T>::min(); } +# if defined(Q_OS_INTEGRITY) && defined(Q_PROCESSOR_ARM_64) +template <> inline bool mul_overflow(quint64 v1, quint64 v2, quint64 *r) +{ + *r = v1 * v2; + return __MULUH64(v1, v2); +} +template <> inline bool mul_overflow(qint64 v1, qint64 v2, qint64 *r) +{ + qint64 high = __MULSH64(v1, v2); + if (high == 0) { + *r = v1 * v2; + return *r < 0; + } + if (high == -1) { + *r = v1 * v2; + return *r >= 0; + } + return true; +} + +template <> inline bool mul_overflow(uint64_t v1, uint64_t v2, uint64_t *r) +{ + return mul_overflow<quint64>(v1,v2,reinterpret_cast<quint64*>(r)); +} + +template <> inline bool mul_overflow(int64_t v1, int64_t v2, int64_t *r) +{ + return mul_overflow<qint64>(v1,v2,reinterpret_cast<qint64*>(r)); +} + +#endif + # if defined(Q_CC_MSVC) && defined(Q_PROCESSOR_X86) // We can use intrinsics for the unsigned operations with MSVC template <> inline bool add_overflow(unsigned v1, unsigned v2, unsigned *r) |