diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2023-02-22 18:34:14 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-02-25 18:14:11 -0800 |
commit | cf059ac9ece88a70eb4f582f3f9cf80186cc69a1 (patch) | |
tree | 9e5004426f87d160c8d197e7c537b13ced913512 | |
parent | caa21ffc65fa5e51a63e68390bd6abd994b5496a (diff) |
QThread/Unix: move qt_nanosleep to qthread_unix.cpp
It's the only place that uses it.
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17465370ac209c2f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
-rw-r--r-- | src/corelib/kernel/qcore_unix_p.h | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qelapsedtimer_unix.cpp | 14 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 14 |
3 files changed, 14 insertions, 15 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 0705ee3bcd..c02910b879 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -373,7 +373,6 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options) // in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp timespec qt_gettime() noexcept; -void qt_nanosleep(timespec amount); QByteArray qt_readlink(const char *path); /* non-static */ diff --git a/src/corelib/kernel/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp index 9f2d75d0b8..f11ebc00a4 100644 --- a/src/corelib/kernel/qelapsedtimer_unix.cpp +++ b/src/corelib/kernel/qelapsedtimer_unix.cpp @@ -139,20 +139,6 @@ struct timespec qt_gettime() noexcept return tv; } -void qt_nanosleep(timespec amount) -{ - // We'd like to use clock_nanosleep. - // - // But clock_nanosleep is from POSIX.1-2001 and both are *not* - // affected by clock changes when using relative sleeps, even for - // CLOCK_REALTIME. - // - // nanosleep is POSIX.1-1993 - - int r; - EINTR_LOOP(r, nanosleep(&amount, &amount)); -} - static qint64 elapsedAndRestart(qint64 sec, qint64 frac, qint64 *nowsec, qint64 *nowfrac) { diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 0bf7c9e27f..b569da53f1 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -491,6 +491,20 @@ void QThread::yieldCurrentThread() #endif // QT_CONFIG(thread) +static void qt_nanosleep(timespec amount) +{ + // We'd like to use clock_nanosleep. + // + // But clock_nanosleep is from POSIX.1-2001 and both are *not* + // affected by clock changes when using relative sleeps, even for + // CLOCK_REALTIME. + // + // nanosleep is POSIX.1-1993 + + int r; + EINTR_LOOP(r, nanosleep(&amount, &amount)); +} + void QThread::sleep(unsigned long secs) { qt_nanosleep(durationToTimespec(std::chrono::seconds{secs})); |