From 4a4a0b6d1fcb7062874d40c93260877eb7d83f22 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 9 Jun 2022 14:53:01 +0200 Subject: Use QT_CONFIG feature checks for sharedmemory and systemsemaphores Change-Id: I86d0e4c5f279486f5fd6ef086dd913e813d0186d Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qsharedmemory.cpp | 22 +++++++++++----------- src/corelib/kernel/qsharedmemory.h | 6 +++--- src/corelib/kernel/qsharedmemory_android.cpp | 14 +++++++------- src/corelib/kernel/qsharedmemory_p.h | 16 ++++++++-------- src/corelib/kernel/qsharedmemory_posix.cpp | 4 ++-- src/corelib/kernel/qsharedmemory_systemv.cpp | 16 ++++++++-------- src/corelib/kernel/qsharedmemory_unix.cpp | 10 +++++----- src/corelib/kernel/qsharedmemory_win.cpp | 5 ++--- src/corelib/kernel/qsystemsemaphore.cpp | 4 ++-- src/corelib/kernel/qsystemsemaphore.h | 4 ++-- src/corelib/kernel/qsystemsemaphore_android.cpp | 4 ++-- src/corelib/kernel/qsystemsemaphore_p.h | 4 ++-- src/corelib/kernel/qsystemsemaphore_posix.cpp | 4 ++-- src/corelib/kernel/qsystemsemaphore_systemv.cpp | 6 +++--- src/corelib/kernel/qsystemsemaphore_unix.cpp | 4 ++-- src/corelib/kernel/qsystemsemaphore_win.cpp | 4 ++-- 16 files changed, 63 insertions(+), 64 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index a789a58b65..65ebd7aa82 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -26,7 +26,7 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE)) +#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) /*! \internal @@ -76,9 +76,9 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, return QDir::tempPath() + u'/' + result; #endif } -#endif // QT_NO_SHAREDMEMORY && QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) /*! \class QSharedMemory @@ -283,7 +283,7 @@ bool QSharedMemoryPrivate::initKey() { if (!cleanHandle()) return false; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) systemSemaphore.setKey(QString(), 1); systemSemaphore.setKey(key, 1); if (systemSemaphore.error() != QSystemSemaphore::NoError) { @@ -370,7 +370,7 @@ bool QSharedMemory::create(qsizetype size, AccessMode mode) if (!d->initKey()) return false; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) #ifndef Q_OS_WIN // Take ownership and force set initialValue because the semaphore // might have already existed from a previous crash. @@ -379,7 +379,7 @@ bool QSharedMemory::create(qsizetype size, AccessMode mode) #endif QString function = "QSharedMemory::create"_L1; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QSharedMemoryLocker lock(this); if (!d->key.isNull() && !d->tryLocker(&lock, function)) return false; @@ -443,7 +443,7 @@ bool QSharedMemory::attach(AccessMode mode) if (isAttached() || !d->initKey()) return false; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QSharedMemoryLocker lock(this); if (!d->key.isNull() && !d->tryLocker(&lock, "QSharedMemory::attach"_L1)) return false; @@ -483,7 +483,7 @@ bool QSharedMemory::detach() if (!isAttached()) return false; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QSharedMemoryLocker lock(this); if (!d->key.isNull() && !d->tryLocker(&lock, "QSharedMemory::detach"_L1)) return false; @@ -531,7 +531,7 @@ const void *QSharedMemory::data() const return d->memory; } -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) /*! This is a semaphore that locks the shared memory segment for access by this process and returns \c true. If another process has locked the @@ -581,7 +581,7 @@ bool QSharedMemory::unlock() d->error = QSharedMemory::LockError; return false; } -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) /*! \enum QSharedMemory::SharedMemoryError @@ -638,7 +638,7 @@ QString QSharedMemory::errorString() const return d->errorString; } -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index 391cf737fd..b52a67f044 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -15,7 +15,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) class QSharedMemoryPrivate; @@ -78,7 +78,7 @@ public: const void* constData() const; const void *data() const; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) bool lock(); bool unlock(); #endif @@ -93,7 +93,7 @@ private: #endif }; -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsharedmemory_android.cpp b/src/corelib/kernel/qsharedmemory_android.cpp index 8d6d98051a..e642a6fdd9 100644 --- a/src/corelib/kernel/qsharedmemory_android.cpp +++ b/src/corelib/kernel/qsharedmemory_android.cpp @@ -5,12 +5,12 @@ #include "qsharedmemory_p.h" #include -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) QT_BEGIN_NAMESPACE QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(), memory(0), size(0), error(QSharedMemory::NoError), -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) systemSemaphore(QString()), lockedByMe(false), #endif unix_key(0) @@ -29,18 +29,18 @@ key_t QSharedMemoryPrivate::handle() return 0; } -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) -#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE)) +#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName) { Q_UNUSED(fileName); Q_UNIMPLEMENTED(); return 0; } -#endif // QT_NO_SHAREDMEMORY && QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) bool QSharedMemoryPrivate::cleanHandle() { @@ -71,4 +71,4 @@ bool QSharedMemoryPrivate::detach() QT_END_NAMESPACE -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 57dcb2cb93..a9ac2c59ed 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -19,8 +19,8 @@ #include -#ifdef QT_NO_SHAREDMEMORY -# ifndef QT_NO_SYSTEMSEMAPHORE +#if !QT_CONFIG(sharedmemory) +# if QT_CONFIG(systemsemaphore) QT_BEGIN_NAMESPACE @@ -48,7 +48,7 @@ QT_END_NAMESPACE QT_BEGIN_NAMESPACE -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) /*! Helper class */ @@ -78,7 +78,7 @@ public: private: QSharedMemory *q_sm; }; -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) class Q_AUTOTEST_EXPORT QSharedMemoryPrivate #ifndef QT_NO_QOBJECT @@ -98,7 +98,7 @@ public: QString nativeKey; QSharedMemory::SharedMemoryError error; QString errorString; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QSystemSemaphore systemSemaphore; bool lockedByMe; #endif @@ -121,7 +121,7 @@ public: void setErrorString(QLatin1StringView function); -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) bool tryLocker(QSharedMemoryLocker *locker, const QString &function) { if (!locker->lock()) { errorString = QSharedMemory::tr("%1: unable to lock").arg(function); @@ -130,7 +130,7 @@ public: } return true; } -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) private: #ifdef Q_OS_WIN @@ -144,7 +144,7 @@ private: QT_END_NAMESPACE -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) #endif // QSHAREDMEMORY_P_H diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp index c909c290a9..ac316b9d12 100644 --- a/src/corelib/kernel/qsharedmemory_posix.cpp +++ b/src/corelib/kernel/qsharedmemory_posix.cpp @@ -14,7 +14,7 @@ #ifdef QT_POSIX_IPC -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) #include #include #include @@ -195,6 +195,6 @@ bool QSharedMemoryPrivate::detach() QT_END_NAMESPACE -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) #endif // QT_POSIX_IPC diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp index cdeed6a668..de6b40746c 100644 --- a/src/corelib/kernel/qsharedmemory_systemv.cpp +++ b/src/corelib/kernel/qsharedmemory_systemv.cpp @@ -13,18 +13,18 @@ #ifndef QT_POSIX_IPC -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) #include #include #include #include #include #include -#endif //QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) #include "private/qcore_unix_p.h" -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -63,9 +63,9 @@ key_t QSharedMemoryPrivate::handle() return unix_key; } -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) -#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE)) +#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) /*! \internal Creates the unix file if needed. @@ -88,9 +88,9 @@ int QT_PREPEND_NAMESPACE(QSharedMemoryPrivate)::createUnixKeyFile(const QString } return 1; } -#endif // QT_NO_SHAREDMEMORY && QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) bool QSharedMemoryPrivate::cleanHandle() { @@ -221,6 +221,6 @@ bool QSharedMemoryPrivate::detach() QT_END_NAMESPACE -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) #endif // QT_POSIX_IPC diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 211111062f..2c071f3735 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -10,7 +10,7 @@ #include -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) #include #ifndef QT_POSIX_IPC #include @@ -21,11 +21,11 @@ #include #include #include -#endif //QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) #include "private/qcore_unix_p.h" -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) QT_BEGIN_NAMESPACE QSharedMemoryPrivate::QSharedMemoryPrivate() : @@ -33,7 +33,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() : QObjectPrivate(), #endif memory(nullptr), size(0), error(QSharedMemory::NoError), -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) systemSemaphore(QString()), lockedByMe(false), #endif #ifndef QT_POSIX_IPC @@ -77,4 +77,4 @@ void QSharedMemoryPrivate::setErrorString(QLatin1StringView function) QT_END_NAMESPACE -#endif // QT_NO_SHAREDMEMORY +#endif // QT_CONFIG(sharedmemory) diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 99f5ec3548..8c0c295ae0 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -#ifndef QT_NO_SHAREDMEMORY +#if QT_CONFIG(sharedmemory) QSharedMemoryPrivate::QSharedMemoryPrivate() : #ifndef QT_NO_QOBJECT @@ -151,7 +151,6 @@ bool QSharedMemoryPrivate::detach() return cleanHandle(); } -#endif //QT_NO_SHAREDMEMORY - +#endif // QT_CONFIG(sharedmemory) QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp index 95002fbabd..f91b841618 100644 --- a/src/corelib/kernel/qsystemsemaphore.cpp +++ b/src/corelib/kernel/qsystemsemaphore.cpp @@ -7,7 +7,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) /*! \class QSystemSemaphore @@ -323,6 +323,6 @@ QString QSystemSemaphore::errorString() const return d->errorString; } -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsystemsemaphore.h b/src/corelib/kernel/qsystemsemaphore.h index 6a61fa559c..f9d6240cd0 100644 --- a/src/corelib/kernel/qsystemsemaphore.h +++ b/src/corelib/kernel/qsystemsemaphore.h @@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) class QSystemSemaphorePrivate; @@ -53,7 +53,7 @@ private: QScopedPointer d; }; -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) QT_END_NAMESPACE diff --git a/src/corelib/kernel/qsystemsemaphore_android.cpp b/src/corelib/kernel/qsystemsemaphore_android.cpp index f34ce2cd03..1a2a3fff8b 100644 --- a/src/corelib/kernel/qsystemsemaphore_android.cpp +++ b/src/corelib/kernel/qsystemsemaphore_android.cpp @@ -6,7 +6,7 @@ #include -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QT_BEGIN_NAMESPACE @@ -44,4 +44,4 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) QT_END_NAMESPACE -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h index 09fbcd2ed6..38a4e7a540 100644 --- a/src/corelib/kernel/qsystemsemaphore_p.h +++ b/src/corelib/kernel/qsystemsemaphore_p.h @@ -17,7 +17,7 @@ #include "qsystemsemaphore.h" -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) #include "qcoreapplication.h" #include "qsharedmemory_p.h" @@ -78,7 +78,7 @@ public: QT_END_NAMESPACE -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) #endif // QSYSTEMSEMAPHORE_P_H diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp index 8f50d2a9a8..4f3ad192b5 100644 --- a/src/corelib/kernel/qsystemsemaphore_posix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp @@ -12,7 +12,7 @@ #ifdef QT_POSIX_IPC -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) #include #include @@ -147,6 +147,6 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) QT_END_NAMESPACE -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) #endif // QT_POSIX_IPC diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp index ff288c6dea..28992a0fb4 100644 --- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp +++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp @@ -10,7 +10,7 @@ #ifndef QT_POSIX_IPC -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) #include #include @@ -72,7 +72,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) } createdFile = (1 == built); -#if !defined(QT_NO_SHAREDMEMORY) && !defined(QT_POSIX_IPC) && !defined(Q_OS_ANDROID) +#if QT_CONFIG(sharedmemory) && !defined(QT_POSIX_IPC) && !defined(Q_OS_ANDROID) // Get the unix key for the created file unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q'); #endif @@ -185,6 +185,6 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) QT_END_NAMESPACE -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) #endif // QT_POSIX_IPC diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp index d32da9e5b7..8c62434ffa 100644 --- a/src/corelib/kernel/qsystemsemaphore_unix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp @@ -7,7 +7,7 @@ #include #include -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) #include #ifndef QT_POSIX_IPC @@ -70,4 +70,4 @@ void QSystemSemaphorePrivate::setErrorString(const QString &function) QT_END_NAMESPACE -#endif // QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp index db23b9144f..b84cf9f859 100644 --- a/src/corelib/kernel/qsystemsemaphore_win.cpp +++ b/src/corelib/kernel/qsystemsemaphore_win.cpp @@ -11,7 +11,7 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -#ifndef QT_NO_SYSTEMSEMAPHORE +#if QT_CONFIG(systemsemaphore) QSystemSemaphorePrivate::QSystemSemaphorePrivate() : semaphore(0), error(QSystemSemaphore::NoError) @@ -97,6 +97,6 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) return true; } -#endif //QT_NO_SYSTEMSEMAPHORE +#endif // QT_CONFIG(systemsemaphore) QT_END_NAMESPACE -- cgit v1.2.3