From b907752a2cc16c5d22b1642178b9643ff31c0faa Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 4 Jun 2024 11:30:22 +0300 Subject: [PATCH] Windows: Fix "__msvc_int128.hpp" inclusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "__msvc_int128.hpp" file is not available in MSVC 17.1.5 Change-Id: Iebc611342ffe5baafb8469205e14afc41b55be5f Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 1b3ae003e657074a9b3cc5a8e5212a40cf02c0fd) Reviewed-by: Nodir Temirkhodjaev --- src/corelib/text/qlocale_tools.cpp | 11 ++++++----- src/corelib/text/qlocale_tools_p.h | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index b68090365b8..6b04bc92cd1 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -807,15 +807,16 @@ QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool return dtoString(d, form, precision, uppercase); } -#if defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#if defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) static inline quint64 toUInt64(qinternaluint128 v) { -#ifdef QT_SUPPORTS_INT128 - return quint64(v); -#elif defined(Q_CC_MSVC) +#if defined(QT_USE_MSVC_INT128) return quint64(v._Word[0]); +#else + return quint64(v); #endif } + QString quint128toBasicLatin(qinternaluint128 number, int base) { // We divide our 128-bit number into parts that we can do text @@ -879,6 +880,6 @@ QString qint128toBasicLatin(qinternalint128 number, int base) result.prepend(u'-'); return result; } -#endif // defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#endif // defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) QT_END_NAMESPACE diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h index 9ae9dc8de74..2cfe25d2997 100644 --- a/src/corelib/text/qlocale_tools_p.h +++ b/src/corelib/text/qlocale_tools_p.h @@ -18,8 +18,9 @@ #include "qlocale_p.h" #include "qstring.h" -#if !defined(QT_SUPPORTS_INT128) && defined(Q_CC_MSVC) && (_MSC_VER >= 1930) +#if !defined(QT_SUPPORTS_INT128) && (defined(Q_CC_MSVC) && (_MSC_VER >= 1930) && __has_include(<__msvc_int128.hpp>)) #include <__msvc_int128.hpp> +#define QT_USE_MSVC_INT128 #endif QT_BEGIN_NAMESPACE @@ -27,7 +28,7 @@ QT_BEGIN_NAMESPACE #if defined(QT_SUPPORTS_INT128) using qinternalint128 = qint128; using qinternaluint128 = quint128; -#elif defined(Q_CC_MSVC) && (_MSC_VER >= 1930) +#elif defined(QT_USE_MSVC_INT128) using qinternalint128 = std::_Signed128; using qinternaluint128 = std::_Unsigned128; #endif @@ -55,7 +56,7 @@ void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, [[nodiscard]] QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool uppercase); -#if defined(QT_SUPPORTS_INT128) || (defined(Q_CC_MSVC) && (_MSC_VER >= 1930)) +#if defined(QT_SUPPORTS_INT128) || defined(QT_USE_MSVC_INT128) [[nodiscard]] Q_CORE_EXPORT QString quint128toBasicLatin(qinternaluint128 number, int base = 10); [[nodiscard]] Q_CORE_EXPORT QString qint128toBasicLatin(qinternalint128 number,