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
|
qt_internal_extend_target(Core CONDITION QT_FEATURE_thread AND UNIX
|
||||||
SOURCES
|
SOURCES
|
||||||
thread/qwaitcondition_unix.cpp
|
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
|
qt_internal_extend_target(Core CONDITION APPLE AND QT_FEATURE_thread
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
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)
|
if (code != 0)
|
||||||
qErrnoWarning(code, "%s: %s failure", where, what);
|
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()
|
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()
|
QMutexPrivate::~QMutexPrivate()
|
||||||
{
|
{
|
||||||
|
|
||||||
report_error(sem_destroy(&semaphore), "QMutex", "sem_destroy");
|
qt_report_error(sem_destroy(&semaphore), "QMutex", "sem_destroy");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
||||||
@ -43,7 +43,7 @@ bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
|||||||
do {
|
do {
|
||||||
errorCode = sem_wait(&semaphore);
|
errorCode = sem_wait(&semaphore);
|
||||||
} while (errorCode && errno == EINTR);
|
} while (errorCode && errno == EINTR);
|
||||||
report_error(errorCode, "QMutex::lock()", "sem_wait");
|
qt_report_error(errorCode, "QMutex::lock()", "sem_wait");
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
auto tp = timeout.deadline<std::chrono::system_clock>();
|
auto tp = timeout.deadline<std::chrono::system_clock>();
|
||||||
@ -53,14 +53,14 @@ bool QMutexPrivate::wait(QDeadlineTimer timeout)
|
|||||||
|
|
||||||
if (errorCode && errno == ETIMEDOUT)
|
if (errorCode && errno == ETIMEDOUT)
|
||||||
return false;
|
return false;
|
||||||
report_error(errorCode, "QMutex::lock()", "sem_timedwait");
|
qt_report_error(errorCode, "QMutex::lock()", "sem_timedwait");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMutexPrivate::wakeUp() noexcept
|
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
|
QT_END_NAMESPACE
|
||||||
|
@ -46,7 +46,7 @@ static constexpr clockid_t SteadyClockClockId =
|
|||||||
#endif
|
#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)
|
if (code != 0)
|
||||||
qErrnoWarning(code, "%s: %s failure", where, what);
|
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);
|
pthread_condattr_setclock(&condattr, SteadyClockClockId);
|
||||||
#endif
|
#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)
|
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)");
|
Q_ASSERT_X(wakeups > 0, "QWaitCondition::wait", "internal error (wakeups)");
|
||||||
--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)
|
if (code && code != ETIMEDOUT)
|
||||||
report_error(code, "QWaitCondition::wait()", "cv wait");
|
qt_report_pthread_error(code, "QWaitCondition::wait()", "cv wait");
|
||||||
|
|
||||||
return (code == 0);
|
return (code == 0);
|
||||||
}
|
}
|
||||||
@ -127,32 +128,38 @@ public:
|
|||||||
QWaitCondition::QWaitCondition()
|
QWaitCondition::QWaitCondition()
|
||||||
{
|
{
|
||||||
d = new QWaitConditionPrivate;
|
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");
|
qt_initialize_pthread_cond(&d->cond, "QWaitCondition");
|
||||||
d->waiters = d->wakeups = 0;
|
d->waiters = d->wakeups = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaitCondition::~QWaitCondition()
|
QWaitCondition::~QWaitCondition()
|
||||||
{
|
{
|
||||||
report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
qt_report_pthread_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
|
||||||
report_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
|
qt_report_pthread_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaitCondition::wakeOne()
|
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);
|
d->wakeups = qMin(d->wakeups + 1, d->waiters);
|
||||||
report_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()", "cv signal");
|
qt_report_pthread_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()",
|
||||||
report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()", "mutex unlock");
|
"cv signal");
|
||||||
|
qt_report_pthread_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()",
|
||||||
|
"mutex unlock");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaitCondition::wakeAll()
|
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;
|
d->wakeups = d->waiters;
|
||||||
report_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()", "cv broadcast");
|
qt_report_pthread_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()",
|
||||||
report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock");
|
"cv broadcast");
|
||||||
|
qt_report_pthread_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()",
|
||||||
|
"mutex unlock");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
|
bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
|
||||||
@ -167,7 +174,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
|
|||||||
if (!mutex)
|
if (!mutex)
|
||||||
return false;
|
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;
|
++d->waiters;
|
||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
|
|
||||||
@ -199,7 +206,7 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline
|
|||||||
return false;
|
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;
|
++d->waiters;
|
||||||
|
|
||||||
readWriteLock->unlock();
|
readWriteLock->unlock();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user