summaryrefslogtreecommitdiffstats
path: root/src/corelib/ipc/qtipccommon.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Mark src/corelib/ipc as security:significantMatthias Rauter2025-07-041-0/+1
| | | | | | | | Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-135188 Change-Id: I8865fe8ffbc22e30218441ec64157d9bafccdd35 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: introduce a user-defined literal operatorGiuseppe D'Angelo2025-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although char16_t string literals implicitly convert to QStringView, there are corner-cases where one may want to explicitly create a QStringView out of them. A couple of examples I've found is where these string literals decay into pointers: // range is a std::initializer_list<const char16_t *> for (QStringView v : { u"foo", u"bar" }) { ... } // ternary will decay arguments void print(QStringView); print(check ? u"hi" : u"there"); When this happens the resulting code gets pessimized and polluted by runtime calls to qustrlen in order to build the QStringView objects [1]. We can restore optimal codegen by directly dealing with QStringView objects instead. Adding explicit conversions may make the code cumbersome to read, so I'm introducing a UDL for QStringView, matching the one for QString (and std::string_view). [1] for instance: https://gcc.godbolt.org/z/eY7xvEje3 Apply the new operator to a couple of places. [ChangeLog][QtCore][QStringView] Is it now possible to create QStringView objects by using the u""_sv user-defined literal. Fixes: QTBUG-123851 Change-Id: I8af7d2e211b356d284de160a222eab9e91d09500 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Create qdoc macros for C++ class docs 2.1: qHash()Marc Mutz2024-11-271-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a family of qdoc macros to document the various qHash() overloads we have. This patch does not change the \relates of the qHash() functions, they remain as inconsistent as they have been. Created QTBUG-129815 to clean things up. Since this author expects the \relates to change in the future, there are different \qhash commands, and all except \qhashbuiltin take the class name as an argument, for use in a centrally-choreographed fix for QTBUG-129815. As drive-by's, fix: - missing documentation about Key having to support qHash() in the associative Qt containers - drop noexcept and default arguments from \fn lines that needed to have their argument names changed - move the QStringView overload from qhash.cpp to qstringview.cpp (as it \relates to the former) Fixes: QTBUG-129574 Pick-to: 6.8 6.5 Change-Id: I8e8c2edc27422cbe5823f56baf3a24d7f7050836 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
* QNativeIpcKey: normalize docs for qHash()Marc Mutz2024-11-201-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | The C++ standard forces¹ us to overload the hidden friend qHash() implementation instead of defaulting `seed` to zero. That doesn't mean we need to reflect that technicality in the docs, esp. if it forces us to deviate from the standard phrasing of qHash() functions to say something about the default value of `seed` (which would, for a defaulted argument, be shown in the docs). Present the qHash() function in the canonical form to QDoc. This is a (forwards and backwards) BC way to solve the issue. Going forward, the correct fix should be to have qHash() functions call a private hash(seed) member function instead, to fulfill the pointless requirement of [1]. ¹ [dcl.fct.default]/4, last sentence Amends c2310f8e03cf30222cea59b3c556d060e1710015. Pick-to: 6.8 Task-number: QTBUG-129574 Change-Id: I7890a0df092c9780601fc4c25e23d70d92db47e1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Create qdoc macros for C++ class docs 1.3: member-swap(), non-standard phrasingMarc Mutz2024-11-081-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | We have some patterns for how to document certain functions, but we also vary the sentences a lot, and you have to look up one documentation piece and copy it, essentially. If we ever want to change them, we end up with shotgun surgery. So apply DRY to the documentation and start a collection of macros to help with repetitive C++ class documentation tasks. The first macro is for member-swap(), and this third patch is for documentation that used a non-standard phrasing for documenting member-swap(). By using the macro, the documentation automatically conforms to what the documentation team picks as the \memberswap expansion going forward. As a drive-by, fix doc block indentation to the Qt standard of 4 spaces (only in changed lines), and add a few blank lines where they were missing before. Fixes: QTBUG-129573 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: If007602d7690572fcbb848a8d0235416c908cfd2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QNativeIpcKey: use new comparison helper macrosTatiana Borisova2024-04-171-0/+2
| | | | | | | | | | Replace public friend operators operator==(), operator!=() of QNativeIpcKey to friend methods comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Task-number: QTBUG-120304 Change-Id: If18d86fb18e44f8d2210cba7ca93e4ac478a2a48 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* IPC: Move the legacy key to the QNativeIpcKeyThiago Macieira2023-09-171-13/+46
| | | | | | | | | | | | | | | | | This is needed to support passing it to other processes so they can enable legacy, compatibility mode. Right now, there's no such code, but I am 90% certain we'll need it soon in 6.6.x, if not for compatibility changes in the future. There's a bug in passing a QNativeIpcKey to another process that causes QSharedMemory to use the wrong QSystemSemaphore for control (a feature that should never have existed in the first place, but we're 15 years too late on that). I have not yet investigated a fix for this, but it will likely involve knowing the original legacy key. Pick-to: 6.6 6.6.0 Change-Id: Idd5e1bb52be047d7b4fffffd1750b547013cb336 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* IPC: disallow unknown queries in QNativeIpcKey string formThiago Macieira2023-09-171-1/+2
| | | | | | | | | So we can add them in the future but cause older versions of Qt to reject them if they don't know what they are. Pick-to: 6.6 6.6.0 Change-Id: I512648fd617741199e67fffd1782b85935bb832a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* IPC: Remove the "small" object optimization in QNativeIpcKeyThiago Macieira2023-09-171-26/+11
| | | | | | | | | | | | | | | | The original design was supposed to be small, at a single pointer, but that never made it through, with the "QString key" member. So the anonymous union for typeAndFlags overlapping with the extension pointer was just unnecessary headache. So separate the two. This means QNativeIpcKey's size increases from 4 pointers to 40 bytes on 64-bit systems and to 24 bytes on 32-bit systems (so we have 6 unused bytes on both architectures). Fixes: QTBUG-116821 Pick-to: 6.6 6.6.0 Change-Id: I512648fd617741199e67fffd1782b7d5ba5ddd12 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* IPC: make the two platformSafeKey functions return QNativeIpcKeyThiago Macieira2023-09-171-37/+45
| | | | | | | | | | | | | | | | | There's no need to return QString, only to create the QNativeIpcKey elsewhere, when nothing uses this intermediary QString (those two functions aren't used in unit tests any more, since the two "IPC: add native key support" commits (2c286561bbc9e4e408d34e5bf43db8ad9acc0e84 and 3ae052d3bb5d7af0badf32575a5aa042cffd8243). Since they aren't used in the tests, we can remove the Q_AUTOTEST_EXPORT macro too and the unnecessary default argument. I'll need the ability to return QNativeIpcKey to store the original, legacy key inside of it. Pick-to: 6.6 6.6.0 Change-Id: Idd5e1bb52be047d7b4fffffd17506c05e4f61f79 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Add documentation for added QNativeIpcKey overloadKai Köhne2023-09-101-0/+6
| | | | | | | | | | Document new implicit constructor introduced in the commit 08605f0d78485 Pick-to: 6.6 Fixes: QTBUG-116870 Change-Id: I518f0a043d7738698ae568ce0b51db3f2c28574f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
* Fix key truncation logic for Windows QSystemSemaphore::platformSafeKeyJøger Hansegård2023-08-121-1/+3
| | | | | | | | | The QSystemSemaphore::platformSafeKey was intended to truncate oversized keys on Windows, but didn't. The fix is to make sure MAX_PATH is defined when compiling on Windows. Change-Id: I03f3bee901203d901bda05a841451c8a2d2f3924 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNativeIpcKey: add qHash() functionDennis Oberst2023-07-251-0/+16
| | | | | | | | Equality comparable types should define a qHash() function. Pick-to: 6.6 Change-Id: I1677fbefa3d09d49a292d369b808793f884c32e9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Add \relates command to two global swap() functionsTopi Reinio2023-06-231-3/+10
| | | | | | | | | And fix incorrect copy-paste error in QBasicTimer's swap() description, 'string' -> 'timer'. Pick-to: 6.6 Change-Id: I28f5e4d6c8e3b8698ab9b4587d503b06c5628b78 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* IPC: QNativeIpcKey: enable the slow pathThiago Macieira2023-05-181-16/+34
| | | | | | | | | | | | | I had designed this to be fast for the common, new case of using QNativeIpcKey objects with a key, a type and maybe in the future we'd need a flag or two. Turns out that the very first thing I'll need is a QString, so enable this code path. This isn't currently exercised because it's not possible to enter it, yet. It'll come in the next commit. Change-Id: Idd5e1bb52be047d7b4fffffd17506af2f2de3060 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* IPC: QNativeIpcKey: use actual QUrl to format and parse the string formThiago Macieira2023-05-181-32/+10
| | | | | | | | | Instead of pretending to be QUrl and doing a poor job at it. I'm not going to implement QUrlQuery parsing and I'll need one option now to store the original, legacy key. Change-Id: Idd5e1bb52be047d7b4fffffd175068c6a82c039b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Silence a warning caused by Concatenation of char16_t and QByteArrayAmir Masoud Abdol2023-03-011-1/+1
| | | | | | Pick-to: 6.5 Change-Id: I34a8ff5587dfa538594b1374cfc819012ce924c1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Fix documentation warnings for Qt CoreTopi Reinio2023-02-061-2/+2
| | | | | | | | | | | | | | These linking issues were not caught by documentation testing in the CI. * android-content-uri-limitations.qdocinc: Fix external link title * Fix links to 'Native IPC Keys' * Fix \sa links to 'Inter-Process Communication' * Replace \sa links to non-existent function nativeKeyType() * Drop explicit link to undocumented class QBasicAtomicInteger Change-Id: I041a8cd2301cc2e77b88c085e74e9178e507a7a1 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* IPC: add support for multiple backends to QSharedMemoryThiago Macieira2023-01-221-27/+0
| | | | | | | | Simultaneously. Change-Id: If4c23ea3719947d790d4fffd17152760989b9bc6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* IPC: add a function to check runtime supportThiago Macieira2023-01-221-0/+27
| | | | | | | | | | | | | | Apple sandboxes restrict use of the System V / XSI IPC mechanisms. It's currently the only restriction we check for. Attempting to use them will result in SIGSYS delivered to the application, so we shouldn't try. Linux system call filtration can do the same. In fact, systemd's SystemCallFilter= options do default to SIGSYS too and it has an @ipc group that could be used to block SysV. However, the same group blocks the creation of pipes, so it's not in much use. Change-Id: I12a088d1ae424825abd3fffd171d79f7cd5b2b9d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* IPC: add QtIpcCommon::platformSafeKey()Thiago Macieira2023-01-221-2/+61
| | | | | | | | | | | | | | | | | | | | | | | This is the new implementation of how to make platform-safe native keys, for which no past compatibility is required nor promised. Unlike when we started in Qt 4.4, it doesn't look there are many restrictions in names anyway. Important differences are: * POSIX RT: no restrictions, we prepend the necessary '/' * System V/XSI: no restrictions, it's just a file path anyway; we pass absolute paths unchanged; otherwise we prepend RuntimeLocation * Windows: no restrictions, but we do recognize Global\ and Local\ kernel objects without munging them The use of the RuntimeLocation may cause a warning on Unix systems (other than Apple ones and Android) if $XDG_RUNTIME_DIR isn't set. We do enforce the Apple 30-character limit here, otherwise you get ENAMETOOLONG. Change-Id: I12a088d1ae424825abd3fffd171d3a0e09e06361 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* IPC: use QNativeIpcKey for QtIpcCommon::legacyPlatformSafeKey()Thiago Macieira2023-01-221-16/+26
| | | | | | | | | | | | | The implementation only has #if now for Apple compatibility; otherwise, we're relying on the QNativeIpcKey::Type parameter, because I intend to allow Unix systems to support both POSIX realtime and System V / XSI shared memory and semaphores. Most of the uses of QtIpcCommon::isIpcSupported() will be constant expressions because they don't depend on the ipcType. Change-Id: I12a088d1ae424825abd3fffd171d38dfb6b5de74 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* IPC: Long live QNativeIpcKey keyThiago Macieira2023-01-221-0/+396
| | | | | | | | | Common to both QSharedMemory and QSystemSemaphore, this will hold the native key and will replace the concept of non-native key in those classes. Change-Id: Id8d5e3999fe94b03acc1fffd171c03197aea6016 Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* IPC: move makePlatformSafeKey to qtipccommon.cppThiago Macieira2023-01-221-0/+89
This removes the second portion of the #if mess of shared code between QSharedMemory and QSystemSemaphore for SystemV. Change-Id: Id8d5e3999fe94b03acc1fffd171c073c2873206e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>