summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
Commit message (Collapse)AuthorAgeFilesLines
* Make version_tagging the full-functional featureAlexey Edelev30 hours2-1/+4
| | | | | | | | | | This feature allows to explicitly disable the version tagging for Qt libraries and have the precise feature-based guarding in C++ code. Task-number: QTBUG-124346 Change-Id: If109adb2f6a998c58825a2449cfb936ea278b2ad Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qtconfigmacros.h: add missing include: we use QT_VERSION_CHECKThiago Macieira6 days1-0/+1
| | | | | | | | | | Amends 3a6c8e02b6d1b0574da52b0087092d0c74aa92c1, which introduced this check. Fixes: QTBUG-124869 Change-Id: I262c3499666e4f4fbcfbfffd17cacbb6025150da Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* compare helpers: use is_OP etc instead of OP 0Marc Mutz6 days1-14/+14
| | | | | | | | | | | | Older GCCs are otherwise going crazy with -Wzero-as-nullptr-constant. The is_OP() functions are specifically protected against this warning. Amends fe12650e9d85ea0ed4a73f85cdbef0ddf3b67ae3. Pick-to: 6.7 Change-Id: I4895e42be382c8549c1902db6f237d29f78bbe7e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* qtconf: Add comment to clarify code handling env varsFabian Kosmale8 days1-0/+4
| | | | | | | | | | The string handling is not immediately clear, unless one already knows what it is supposed to do. Change-Id: Icd5746513d760d478f03c8aded3669b06b692a87 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QVariant: fix C++20 build with older MSVC 2022Marc Mutz11 days1-0/+4
| | | | | | | | | | | | | | | | | | | | | | | ... which claim full C++20 conformance (__cplusplus >= 202002), but still lack https://wg21.link/P0846. Fix by extending the existing workaround for lack of P0846 support to these compilers. Known to fail: _MSC_VER 1936 Known to pass: _MSC_VER 1939 We might need to check 1938 and 1937, but the workaround should only show up as an additional get/get_if overload and not disturb normal operation, so it's not critical to get the boundary version exactly right. Amends eb9c8042cfa71f16cda27cdeb052d84a6cc117d7. Pick-to: 6.7 Task-number: QTQAINFRA-6204 Change-Id: Ia3e0072d606efb7efd6ce0f75239850c7cd925bb Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Avoid including qversiontagging.h in QtCore module headerAlexey Edelev12 days1-0/+4
| | | | | | | | The header is already included in qglobal.h Task-number: QTBUG-124346 Change-Id: Id713cdecd4c3221edc32402cb874ab0d98a86f82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MSVC: improve QASV(const char(&str)[N]) compilation timeIvan Solovev12 days1-0/+2
| | | | | | | | | | | | | | | | | | | | | | | The lengthHelperContainer() implementation for sizeof(Char) == 1 case is using qstrnlen() for the non-constexpr case. qstrnlen() is an inline function which is effectively a nullptr check and a memchr() call. For some reason, on MSVC this combination resulted in very slow compilation for the user projects, where each call to QObject::setObjectName() was hitting this codepath. Fix it by replacing the qstrnlen() call with strnlen_s() for MSVC. It seems that for now all versions of MSVC are affected. However, introduce a new Q_COMPILER_SLOW_QSTRNLEN_COMPILATION definition, which will allow us to check for the compiler version later on. For now this definition is set for all MSVC versions unconditionally. Fixes: QTBUG-124376 Pick-to: 6.7 6.7.1 Change-Id: Id769bef1e950ffa756acf7af39d362fd8b112019 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QLogging: enable %{backtrace} support via <stacktrace>Giuseppe D'Angelo2024-04-182-8/+90
| | | | | | | | | | | | | | | | | | | C++23 gave us a standardized way to gather backtraces, so we can use it to add cross-platform support for %{backtrace}. Guard the feature via a compile test; at the moment, this is enabled it on MSVC only. GCC has experimental support (requires linking against libstdc++exp), so it will still fail the test. [ChangeLog][QtCore][QDebug] Support for the %{backtrace} expansion has been extended to the platforms supporting C++23's <stacktrace> header (such as MSVC 2022 >= 17.4). Change-Id: I04d58a193384a61e4f8e6fef78286d4bad98a025 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add preliminary support for Qt for visionOSTor Arne Vestbø2024-04-185-3/+22
| | | | | | | | | | | | | | | | | | | | | | Qt already runs on Vision Pro as "Designed for iPad", using Qt for iOS. This change enables building Qt for visionOS directly, which opens the door to visionOS specific APIs and use-cases such as volumes and immersive spaces. The platform removes some APIs we depend on, notably UIScreen, so some code paths have been disabled or mocked to get something up and running. As our current window management approach on UIKit platforms depends on UIWindow and UIScreen there is currently no way to bring up QWindows. This will improve once we refactor our window management to use window scenes. To configure for visionOS, pass -platform macx-visionos-clang, and optionally add -sdk xrsimulator to build for the simulator. Change-Id: I4eda55fc3fd06e12d30a188928487cf68940ee07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QKeyCombination: use new comparison helper macrosTatiana Borisova2024-04-172-11/+10
| | | | | | | | | | Replace public friend operators operator==(), operator!=() of QKeyCombination to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE macro. Task-number: QTBUG-120304 Change-Id: I679f3fa5fcc4c675a763cc5a5fe0e0880439a64f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QCompilerDetection: move qsystemdetection.h to inside the include guardAhmad Samir2024-04-171-2/+1
| | | | | | | Pick-to: 6.7 6.6 Task-number: QTBUG-124120 Change-Id: Ia3ca4392945a793289fb9c75f50fba1bca1c691c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live [[nodiscard]] QFile::openGiuseppe D'Angelo2024-04-172-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having already caught some bugs in real code because of unchecked calls to QFile::open, this commit marks QFile::open (and open() in other file-I/O classes) as [[nodiscard]]. Since it's going to raise warnings, the plan is to keep the existing behavior up to and including the next LTS. Then the warnings will switch on by default. All of this is protected by system of macros to opt-in or opt-out the behavioral change at any time. A possible counter-argument for doing this is that QFile::open is also used for opening files in the the resource system, and that opening "cannot fail". It clearly can, if the resource is moved away or renamed; code should at a minimum use a Q_ASSERT in debug builds. Another counter-argument is the opening of file handles or descriptors; but again, that opening may fail in case the handle has been closed or if the flags are incompatible. --- Why not marking *every* open() override? Because some are not meant to be called directly -- for instance sockets are supposed to be open via calls to `connectToHost` or similar. One notable exception is QIODevice::open() itself. Although rarely called directly by user code (which just calls open() on a specific subclass, which likely has an override), it may be called: 1) By code that just takes a `QIODevice *` and does something with it. That code is arguably more rare than code using QFile directly. Still, being "generic" code, they have an extra responsibility when making sure to handle a possible opening failure. 2) By QIODevice subclasses, which are even more rare. However, they usually ignore the return from QIODevice::open() as it's unconditionally true. (QIODevice::open() doesn't use the protected virtual pattern.) I'll try and tackle QIODevice in a future commit. [ChangeLog][QtCore][QFileDevice] The open() functions of file-related I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked with the "nodiscard" attribute, in order to prevent a category of bugs where the return value of open() is not checked and the file is then used. In order to avoid warnings in existing code, the marking can be opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically enable nodiscard on these functions starting from Qt 6.10. Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: log using emscripten_log() by defaultMorten Sørvig2024-04-171-2/+7
| | | | | | | | | | | | | | | | | | Log using emscripten_log by default, unless QT_FORCE_STDERR_LOGGING has been set. It is now possible to log at different levels: qDebug() -> Info qWarning() -> Warning qCritical() -> Error #ifdef out functions which are now no longer in use on Q_OS_WASM Change-Id: I0485e5c070069998a8dfc6759c02bc3b7d6a8a4b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* PRNGLocker: disable copy and moveRym Bouabid2024-04-121-1/+2
| | | | | | | | | | | | | | | Axivion (SV61) points out based on Qt-RuleOfThree the lack of copy and move constructors and operators. We don't need them, so tell the compiler not to create them. As a drive-by change mark the constructor as explicit and not discardable. Task-number: QTBUG-122619 Pick-to: 6.7 6.5 Change-Id: I466f5cedea427608b434b71fda0d1e50619b9b20 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qt_int_sqrt: update doc of where it is usedThiago Macieira2024-04-101-2/+2
| | | | | Change-Id: If1bf59ecbe014b569ba1fffd17c458ae3af0175f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QTypeInfo: remove docs about how Qt's autodetection worksGiuseppe D'Angelo2024-04-091-9/+2
| | | | | | | | | | | | I don't think we should document *exactly* how we autodetect primitive/relocatable types: we've been changing the detection across Qt versions because sometimes we realized that it was wrong. Moreover, no one else but us should be using the traits in question (in other words: QTypeInfo itself isn't public API). Pick-to: 6.7 6.5 6.2 Change-Id: Ie6e763f152e7dc0f6ce58869dbbd529240d2a546 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTypeInfo: do some doc tidiesGiuseppe D'Angelo2024-04-091-6/+6
| | | | | Change-Id: I9893bca7c7fe872e97718b73c4aa08d95d2f74d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTypeInfo: add some code comments regarding a redundant checkGiuseppe D'Angelo2024-04-081-0/+7
| | | | | Change-Id: Ic92f44c8df63bd71f313b672125481d710dc8c66 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add AA_DontUsePopupWindowsOliver Eftevaag2024-04-052-1/+6
| | | | | | | | | | | | | | | | | | | We want QQuickPopup to open a top-level window in qt quick, by default. But also allow users to opt out, and revert back to the old behavior. It makes sense to have an application wide setting for this, in order to allow application developer to opt out of the new default behavior, without having to change a property for every instance of Popup. While QCoreApplicationPrivate::attribs bearly has any available bits, it appear that bit 30 is available, since AA_DisableWindowContextHelpButton was commented out. Task-number: QTBUG-121363 Change-Id: I6b2759d89b46aa5d08222c2611eaffe855cc425c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QTypeInfo: Add a missing includeMartin Storsjö2024-04-041-0/+1
| | | | | | | | | | | | | | | | | | This header uses std::is_trivial_v, which requires including the <type_traits> header. When building with PCH enabled (which is the default), this dependency does get satisfied via the PCH, so no issue is visible. This fixes building with recent version of libc++ when configured with _LIBCPP_REMOVE_TRANSITIVE_INCLUDES (which removes unnecessary transitive dependencies between the libc++ headers, a configuration which may become the default in the future), with PCH disabled. Pick-to: 6.7 6.5 6.2 Change-Id: I5e3ae20e366ed3028b1156cee05bcf2908d6e845 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix Qt::AA_DontUseNativeMenuWindows being unsettable on 32 bit systemsMitch Curtis2024-04-041-2/+1
| | | | | | | | | | | | | | | | f1bb9cfbf65ab56b67b5a52fa736071e0e534261 added this value, but it was only when a test in qtdeclarative tried to use it that it was discovered that it couldn't be set on 32 bit operating systems (armv7, AKA imx7) due to overflow as a result of the bit shifting that is done. Fix it by using an old, deprecated value. If any old codebase using that older flag tries to build against a newer Qt with this change, it shouldn't affect it, as setting the flag does nothing in Widgets, and native menus didn't exist in earlier versions. Task-number: QTBUG-69558 Change-Id: I520154d02e9ccf007ebd73807685212a19fbee1b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLogging: exclude QInternalMessageLogContext from backtracesGiuseppe D'Angelo2024-04-031-0/+2
| | | | | | | | | "Just in case" -- as the comment says, QInternalMessageLogContext's constructor is usually inlined, but we can't be sure if it has been. Change-Id: I4da2f0875d9fd9f7bd6d79447b4761fda329c7fd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for using an inline namespaces for -qtnamespaceFriedemann Kleint2024-04-031-0/+16
| | | | | | | | | | | | | | | Inline namespaces serve the purpose for which the original -qtnamespace option was added and allow for macro simplification (no need for any using directives). This makes it possible to use namespaced builds of Qt also for Qt for Python and similar use cases which have issues with the additional namespace. [ChangeLog][QtCore] It is now possible to use an inline namespace for -qtnamespace (option -qtinlinenamespace). Task-number: PYSIDE-2590 Change-Id: Ia0cecf041321933a2e02d1fd8ae0e9cda699cd1e Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Logging: capture the backtrace closer to the user's entry pointThiago Macieira2024-03-272-33/+92
| | | | | | | | | | | | | | | Instead of deep inside the processing of the message pattern tokens. This reduces the number of uninlineable functions in release builds to 2. Experimentation shows that even in debug mode our overhead to backtrace() is just 2, despite the debugger's backtrace showing 3 frames -- the debugger is using QtCore's debug symbols and does know about the inlined function. As a nice side-effect, we capture the backtrace only once per message, not once per %{backtrace} token in the QT_MESSAGE_PATTERN. Change-Id: I01ec3c774d9943adb903fffd17b7d6de09167620 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Logging: introduce QInternalMessageLogContext to hold current contextThiago Macieira2024-03-273-41/+47
| | | | | | | | | | | | | | QMessageLogContext is a primitive type that may be extended in the future with more fields (it has been at version 2 since commit 6d166c88220ee09821b65fb2b711fa77a5312971, though that did not extend the struct's size). This introduces a QInternalMessageLogContext which is used in before all our calls to qt_message_output(). Currently there's no difference and no way to tell that the internal version is used. Change-Id: I01ec3c774d9943adb903fffd17b7d5abc0052207 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* qErrnoWarning: downgrade from critical to warningDavid Faure2024-03-271-2/+2
| | | | | | | | | | | | | | | | | | The name says it's a warning, it's pretty unexpected that it should lead to a critical message. One case where this is a problem is QTBUG-48488 where merely printing with "Microsoft Print To PDF" and canceling the file dialog leads to "QWin32PrintEngine::begin: StartDoc failed" as a *critical* message. Some Windows applications have a message handler that shows a msgbox in case of a critical message, and getting such a msgbox after canceling the file dialog seems very wrong. Task-number: QTBUG-48488 Pick-to: 6.7 Change-Id: I1c842340dd2faf2be6e64e0522f9e2b33547d3cf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "QTypeInfo: add detection for Clang's __is_trivially_relocatable"Tor Arne Vestbø2024-03-221-7/+1
| | | | | | | | | This reverts commit f4bac3ca173be9f219099c04e76d6d62c4d0e19e. It broke builds with Xcode 15 Change-Id: Iee232658ede3dfb09d65f3f6a95410c069941421 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTypeInfo: add detection for Clang's __is_trivially_relocatableGiuseppe D'Angelo2024-03-221-1/+7
| | | | | | | | | | Types marked with [[clang::trivial_abi]] are considered to be trivially relocatable for Clang. This is ABI compatible, since in Qt 6 we can change the value of QTypeInfo::IsRelocatable "after the fact" -- it simply means that code that doesn't get recompiled is pessimized. Change-Id: I32e52bfb212c7919b2ebcf7832ede4404358330f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qtversionchecks.h: hide Q_OBJECT macro in C-style comment from automocMarc Mutz2024-03-211-1/+1
| | | | | | | | | | | | | | | | | | Due to https://gitlab.kitware.com/cmake/cmake/-/issues/25770, the presence of the Q_OBJECT macro here triggers automoc rule generation, followed by moc's "No relevant classes found. No output generated." warning. Comment the macro out until the issue is fixed, leaving a comment to avoid a helpful soul commenting the macro back in again. Amends 32a1151245034e4d5d3162df21518e38b6f81fcd. Task-number: QTBUG-123229 Pick-to: 6.7 Change-Id: I5387128f8fcd2793f0d4b9ff73a551999fea84b0 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* qfloat16: further disable the -Wfloat-conversion warningThiago Macieira2024-03-181-1/+3
| | | | | | | | | | It shows up in our headersclean mode. Fixes: QTBUG-123374 Pick-to: 6.6 6.7 Change-Id: I6818d78a57394e37857bfffd17bcf9e350dc493c Reviewed-by: Simo Fält <simo.falt@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Documentation: Clarify palette/font/stylesheet inheritance/propagationAxel Spoerl2024-03-181-3/+3
| | | | | | | | | | | | | | | | Palette and font changes made by a style sheet are propagated to existing widgets and their children at change time. Palette and font changes made by setPalette() and setFont() are inherited by all existing and future children of the widget to which the call was made. Clarify this in the documentation. Fixes: QTBUG-122588 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ic40d96fc1e5e4507f84a33138303b7193948d3fe Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Add AA_DontUseNativeMenuWindowsMitch Curtis2024-03-152-0/+7
| | | | | | | | | | | | | | | Also add some categorized logging output to make it easier to check if native menus are being created. [ChangeLog][Qt Core] Added AA_DontUseNativeMenuWindows application attribute. Menu popup windows (e.g. context menus, combo box menus, and non-native menubar menus) created while this attribute is set to true will not be represented as native top level windows, unless required by the implementation. Task-number: QTBUG-69558 Change-Id: Iba11b89c67d942ce6c5a28a7c57a86e63c020618 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QOperatingSystemVersion: use partial ordering for relational operatorsIvan Solovev2024-03-132-14/+32
| | | | | | | | | | | | | | | | | | | | | | QOperatingSystemVersion intentionally does not define operator==() and operator!=() since ae072cd9c4a575e0ed3f073c6ab395ccdf7c2b37. It means that we cannot use comparison helper macros. Still, we can manually define four relational operators or operator<=>() in C++20 mode, and give the class a partial ordering. We choose partial ordering, because versions of different OS types are incomparable. Implement the operators in terms of helper function compareThreeWay(), which potentially allows to use this class in some templated code. As a drive-by: make the static compare() function noexcept, because it really is. Fixes: QTBUG-120360 Change-Id: Id4c9ce740e42baa719ca0ee84146d087b21675c6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bootstrap: remove QTemporaryFileThiago Macieira2024-03-131-1/+1
| | | | | | | | | Done by harmonizing the use on the QT_CONFIG(temporaryfile) macro and fixing one test that was missing. We can't remove the older macro because it is marked PBULIC) but we don't need to use it ourselves. Change-Id: I01ec3c774d9943adb903fffd17b7eb4dd1a4e63f Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Long live QT_ENABLE_STRICT_MODE_UP_TOGiuseppe D'Angelo2024-03-132-0/+76
| | | | | | | | | | | | | | | | | | | We already have fine-grained macros to individually disable APIs that we consider "suboptimal" or "dangerous". This commit adds a shortcut for the user to set all such macros in one go. QT_ENABLE_STRICT_MODE_UP_TO is versioned, just like QT_DISABLE_DEPRECATED_UP_TO; the idea is that users should set it to the minimum Qt version they want to support. Also, if QT_DISABLE_DEPRECATED_UP_TO is not set, then QT_ENABLE_STRICT_MODE_UP_TO will set it as well, to the same value. [ChangeLog][QtCore][QtGlobal] Added the QT_ENABLE_STRICT_MODE_UP_TO macro. Change-Id: I5466465986104e047a6a86369928be9294f24ab7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QT_NO_AS_CONST: rename and add docsGiuseppe D'Angelo2024-03-132-2/+16
| | | | | | | | | | Give it a name in line with the function name: qAsConst -> QT_NO_QASCONST, as already done for qExchange. We can do this because we never documented the macro itself. So, while at it: also document the macro. Change-Id: I6eb0834df438e4f4e818ef2cf8e702ed156dc253 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QT_NO_QEXCHANGE: doc fixGiuseppe D'Angelo2024-03-131-0/+1
| | | | | | | | A \relates was missing. Change-Id: I30c8a721b2d1e38ac87bebac37aef5a350dfe683 Pick-to: 6.7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Bootstrap: remove QVariantThiago Macieira2024-03-131-0/+1
| | | | | | | | | I added QT_NO_VARIANT to qconfig-bootstrapped.h to be clearer on what the #ifs are, but there's no testing of that feature outside of QT_BOOTSTRAPPED. Change-Id: I01ec3c774d9943adb903fffd17b7e8ac4340fb89 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* convertDoubleTo: add FP16 supportThiago Macieira2024-03-121-0/+33
| | | | | | | | | | | | | | Currently unused. I've tested that GCC 13 and Clang 17 do compile this and do output reasonable assembly, with and without AVX512FP16 (I also tested AVX10.1 with GCC 14). Clang is unable to allocate a "v" (vector) register when T is qfloat16, so I could only implement the conversion using _Float16. Strictly speaking, Clang >= 16 always knows about _Float16, but I didn't want to have a different detection from qtypes.h. Change-Id: I6818d78a57394e37857bfffd17bae860f8055324 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* convertDoubleTo<FP>: add support for x86 intrinsicsThiago Macieira2024-03-121-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The x86 SSE instructions do what we want and set a flag in the MXCSR to indicate whether we should return false, so we can improve the codegen. GCC generates for QStringView::toFloat(): call _ZNK11QStringView8toDoubleEPb movl $8064, 12(%rsp) movl $1, %eax #APP # 330 "/home/tjmaciei/src/qt/qt6/qtbase/src/corelib/global/qnumeric_p.h" 1 vldmxcsr 12(%rsp) vcvtsd2ss %xmm0, %xmm0, %xmm0 vstmxcsr 12(%rsp) # 0 "" 2 #NO_APP movl 12(%rsp), %edx testb $24, %dl je .L2120 ... handling of the under/overflow ... The MXCSR instructions do need to read and write from memory, but the stack is usually already in L1 and CPUs have special optimizations for it. There are two alternative implementations to the implementation chosen: first, we could confirm there was no underflow or overflow using an expression like: (v == 0) == (*value == 0) && qt_is_finite(v) == qt_is_finite(*value); But that is still very costly, with 4 UCOMISx instructions and several memory loads. Second, we could use the VFPCLASSSD and VFPCLASSSS (yes, 4 "S") instructions to confirm whether a finite input became zero or non- finite, but a) that's only available with AVX512, so of little practical use today and b) it has a 3-cycle latency. Like the comparisons above, we'd need 4 of them. Change-Id: I01ec3c774d9943adb903fffd17b8b9cb2ce805ce Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QT_NO_QEXCHANGE: add docsGiuseppe D'Angelo2024-03-091-0/+11
| | | | | | Pick-to: 6.7 6.6 Change-Id: Ibb54de391a580814c9392b262966e2e2947364d9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGlobalStatic: suppress -Wtsan warningGiuseppe D'Angelo2024-03-081-0/+8
| | | | | | | | | | | | | | | QGS employs a call to std::atomic_thread_fence. Unfortunately TSAN does not support it, and GCC >= 11 raises a warning. This breaks the build when building under -Werror. Suppress the warning using the usual pragmas. There's a catch: qglobalstatic.h is built into a PCH, and GCC <= 13 will still generate a warning because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 . Change-Id: I770f39b7563b66f483851444cd580bcafc5f288a Pick-to: 6.7 6.6 6.5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: fix warning "class Qt::TimerId' specified with '\enum'"Thiago Macieira2024-03-061-1/+1
| | | | | | | Amends 4bc0834bc182335984431c6a1525782efc34368c. Change-Id: I6818d78a57394e37857bfffd17ba0f3897b2a5f5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Move qAbort from qglobal.cpp to qassert.cppThiago Macieira2024-03-062-74/+67
| | | | | | | | | | | It makes more sense there, as all the other functions in that file are about early termination. This allows us to remove qglobal.cpp from the bootstrap library, because qglobal.cpp now only has the callback tables. Amends 8f13af5d7b9b659208a8a93e6581d30b434dae1f. Change-Id: I01ec3c774d9943adb903fffd17b7ea92404bdbd3 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add include for QT_CONFIGJuha Vuolle2024-03-061-0/+1
| | | | | | | | To not rely on transitive includes. Pick-to: 6.7 Change-Id: I116483f94bba4a6edb0a78941da676b1a3e6e1bd Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Add QT_CONFIG(signaling_NaN) around the signaling_NaN limit functionJuha Vuolle2024-03-061-0/+2
| | | | | | | | | | Amends: 398a51686eda225f222d9df7ce56898c18ecdaa1 Found in API-review. Pick-to: 6.7 Change-Id: Ia9be5bc5bdcf7aa2960e9c88f961bf8168435a70 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Remove unnecessary #undef about q{Debug,Info,Warning,Critical,Fatal}Thiago Macieira2024-03-041-8/+0
| | | | | | | | | | | | | | | | | | The ones in qlogging.cpp were copied to it from qglobal.cpp in commit 23688d8942895507f4bc1517dd3c161134f4f9d0. They existed in qglobal.cpp like in qdebug.cpp since the beginning of the public history. The one in qdebug.cpp already made no sense in Qt 4 times, because qdebug.cpp was a documentation-only source (no actual C++ code). The #undefs from qglobal.cpp hadn't been necessary since commit d394ca7f27197cfbfc28eb9a08eb0db261dd9d3d, the global functions qDebug(), qWarning(), qCritical(), etc. were replaced by member functions in QMessageLogger whose names did not match the macros. Pick-to: 6.7 Change-Id: I50e2158aeade4256ad1dfffd17b1c62f23eca4db Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Move QLocaleData::convertDoubleToFloat to qnumeric_p.hThiago Macieira2024-03-041-4/+41
| | | | | | | So others can use it too. Change-Id: I01ec3c774d9943adb903fffd17b86236d06a948c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Compiler detection - __attribute__((fallthrough)) for clangTim Blechmann2024-03-041-2/+2
| | | | | | | | | Clang supports `__attribute__((fallthrough))`. While C++ sources use [[attribute]], the C codepath still requires a fallback. Pick-to: 6.7 Change-Id: Iaa93d2debc21fdd34e414ddb024b95942ae9191f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Timers: add Qt::TimerId enum classAhmad Samir2024-03-032-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | Which will be used to represent timer IDs. Thanks to Marc for the idea to use "a strongly typed int". QTimer got a new id() method that returns Qt::TimerId (can't overload timerId()). Various classes in qtbase have a member named timerId(), but a new method is needed anyway in QTimer so id() it is (this is the reason QChronoTimer only has id() and no timerId()). Besides timer.timerId() has an extra "timer". This commit fixes the inconsistency between QObject using `0` timer id to indicate "failed to start", while QTimer::timerId() returned `-1` to indicate "timer is inactive". QTimer::id(), being a new method and all, now returns Qt::TimerId::Invalid, which has value `0`, so that the values match between the two classes. Extend the unittests to ensure QTimer::timerId()'s behavior is preserved. [ChangeLog][Core][QObject] Added Qt::TimerId enum class, that is used to represent timer IDs. Change-Id: I0e8564c1461884106d8a797cc980a669035d480a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>