Resolve symbol conflict between qmutex_unix and qwaitcondition_unix.cpp
In `qmutex_unix.cpp`, renamed `report_error` to `qt_report_error`; and in `qwaitcondition_unix.cpp` renamed `report_error` to `qt_report_pthread_error`. In addition, I removed the temporary exclusion of the qwaitcondition_unix.cpp from unity build. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ia411bf1d8ca77512cf3898acb28b37f343ff94fd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
393e496385
commit
3431aeafc0
@ -674,10 +674,6 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_thread
|
||||
qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
|
||||
SOURCES
|
||||
thread/qwaitcondition_unix.cpp
|
||||
NO_UNITY_BUILD_SOURCES
|
||||
thread/qwaitcondition_unix.cpp
|
||||
# Temporary exclusion until this, https://codereview.qt-project.org/c/qt/qtbase/+/472013,
|
||||
# or this, https://codereview.qt-project.org/c/qt/qtbase/+/471184 addresses the issue.
|
||||
)
|
||||
|
||||
qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static void report_error(int code, const char *where, const char *what)
|
||||
static void qt_report_error(int code, const char *where, const char *what)
|
||||
{
|
||||
if (code != 0)
|
||||
qErrnoWarning(code, "%s: %s failure", where, what);
|
||||
@ -27,13 +27,13 @@ static void report_error(int code, const char *where, const char *what)
|
||||
|
||||
QMutexPrivate::QMutexPrivate()
|
||||
{
|
||||
report_error(sem_init(&semaphore, 0, 0), "QMutex", "sem_init");
|
||||
qt_report_error(sem_init(&semaphore, 0, 0), "QMutex", "sem_init");
|
||||
}
|
||||
|
||||
QMutexPrivate::~QMutexPrivate()
|
||||
{
|
||||
|
||||
report_error(sem_destroy(&semaphore), "QMutex", "sem_destroy");
|
||||
qt_report_error(sem_destroy(&semaphore), "QMutex", "sem_destroy");
|
||||
}
|
||||
|
||||
bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
||||
@ -43,7 +43,7 @@ bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
||||
do {
|
||||
errorCode = sem_wait(&semaphore);
|
||||
} while (errorCode && errno == EINTR);
|
||||
report_error(errorCode, "QMutex::lock()", "sem_wait");
|
||||
qt_report_error(errorCode, "QMutex::lock()", "sem_wait");
|
||||
} else {
|
||||
do {
|
||||
auto tp = timeout.deadline<std::chrono::system_clock>();
|
||||
@ -53,14 +53,14 @@ bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
||||
|
||||
if (errorCode && errno == ETIMEDOUT)
|
||||
return false;
|
||||
report_error(errorCode, "QMutex::lock()", "sem_timedwait");
|
||||
qt_report_error(errorCode, "QMutex::lock()", "sem_timedwait");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QMutexPrivate::wakeUp() noexcept
|
||||
{
|
||||
report_error(sem_post(&semaphore), "QMutex::unlock", "sem_post");
|
||||
qt_report_error(sem_post(&semaphore), "QMutex::unlock", "sem_post");
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -46,7 +46,7 @@ static constexpr clockid_t SteadyClockClockId =
|
||||
#endif
|
||||
;
|
||||
|
||||
static void report_error(int code, const char *where, const char *what)
|
||||
static void qt_report_pthread_error(int code, const char *where, const char *what)
|
||||
{
|
||||
if (code != 0)
|
||||
qErrnoWarning(code, "%s: %s failure", where, what);
|
||||
@ -66,7 +66,7 @@ static void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
|
||||
pthread_condattr_setclock(&condattr, SteadyClockClockId);
|
||||
#endif
|
||||
|
||||
report_error(pthread_cond_init(cond, attrp), where, "cv init");
|
||||
qt_report_pthread_error(pthread_cond_init(cond, attrp), where, "cv init");
|
||||
}
|
||||
|
||||
static void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline)
|
||||
@ -115,10 +115,11 @@ public:
|
||||
Q_ASSERT_X(wakeups > 0, "QWaitCondition::wait", "internal error (wakeups)");
|
||||
--wakeups;
|
||||
}
|
||||
report_error(pthread_mutex_unlock(&mutex), "QWaitCondition::wait()", "mutex unlock");
|
||||
qt_report_pthread_error(pthread_mutex_unlock(&mutex), "QWaitCondition::wait()",
|
||||
"mutex unlock");
|
||||
|
||||
if (code && code != ETIMEDOUT)
|
||||
report_error(code, "QWaitCondition::wait()", "cv wait");
|
||||
qt_report_pthread_error(code, "QWaitCondition::wait()", "cv wait");
|
||||
|
||||
return (code == 0);
|
||||
}
|
||||
@ -127,32 +128,38 @@ public:
|
||||
QWaitCondition::QWaitCondition()
|
||||
{
|
||||
d = new QWaitConditionPrivate;
|
||||
report_error(pthread_mutex_init(&d->mutex, nullptr), "QWaitCondition", "mutex init");
|
||||
qt_report_pthread_error(pthread_mutex_init(&d->mutex, nullptr), "QWaitCondition", "mutex init");
|
||||
qt_initialize_pthread_cond(&d->cond, "QWaitCondition");
|
||||
d->waiters = d->wakeups = 0;
|
||||
}
|
||||
|
||||
QWaitCondition::~QWaitCondition()
|
||||
{
|
||||
report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
||||
report_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
|
||||
qt_report_pthread_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
||||
qt_report_pthread_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QWaitCondition::wakeOne()
|
||||
{
|
||||
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeOne()", "mutex lock");
|
||||
qt_report_pthread_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeOne()",
|
||||
"mutex lock");
|
||||
d->wakeups = qMin(d->wakeups + 1, d->waiters);
|
||||
report_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()", "cv signal");
|
||||
report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()", "mutex unlock");
|
||||
qt_report_pthread_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()",
|
||||
"cv signal");
|
||||
qt_report_pthread_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()",
|
||||
"mutex unlock");
|
||||
}
|
||||
|
||||
void QWaitCondition::wakeAll()
|
||||
{
|
||||
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeAll()", "mutex lock");
|
||||
qt_report_pthread_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeAll()",
|
||||
"mutex lock");
|
||||
d->wakeups = d->waiters;
|
||||
report_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()", "cv broadcast");
|
||||
report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock");
|
||||
qt_report_pthread_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()",
|
||||
"cv broadcast");
|
||||
qt_report_pthread_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()",
|
||||
"mutex unlock");
|
||||
}
|
||||
|
||||
bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
|
||||
@ -167,7 +174,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
|
||||
if (!mutex)
|
||||
return false;
|
||||
|
||||
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
||||
qt_report_pthread_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
||||
++d->waiters;
|
||||
mutex->unlock();
|
||||
|
||||
@ -199,7 +206,7 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline
|
||||
return false;
|
||||
}
|
||||
|
||||
report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
||||
qt_report_pthread_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
|
||||
++d->waiters;
|
||||
|
||||
readWriteLock->unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user