diff options
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_unix_p.h | 27 | ||||
-rw-r--r-- | src/corelib/kernel/qtimerinfo_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qtools_p.h | 23 |
4 files changed, 27 insertions, 28 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 1dbd2c8976..3f07523f81 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -12,7 +12,6 @@ #include <QtCore/qoperatingsystemversion.h> #include <QtCore/private/qcore_unix_p.h> #include <QtCore/private/qfiledevice_p.h> -#include <QtCore/private/qtools_p.h> #include <QtCore/qvarlengtharray.h> #ifndef QT_BOOTSTRAPPED # include <QtCore/qstandardpaths.h> @@ -1559,7 +1558,7 @@ bool QFileSystemEngine::setFileTime(int fd, const QDateTime &newDate, QAbstractF if (time == QAbstractFileEngine::AccessTime || time == QAbstractFileEngine::ModificationTime) { const int idx = time == QAbstractFileEngine::AccessTime ? 0 : 1; const std::chrono::milliseconds msecs{newDate.toMSecsSinceEpoch()}; - ts[idx] = QtMiscUtils::durationToTimespec(msecs); + ts[idx] = durationToTimespec(msecs); } if (futimens(fd, ts) == -1) { diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index fe2e639d78..0705ee3bcd 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -20,7 +20,6 @@ #include <QtCore/private/qglobal_p.h> #include "qatomic.h" #include "qbytearray.h" -#include <QtCore/private/qtools_p.h> #ifndef Q_OS_UNIX # error "qcore_unix_p.h included on a non-Unix system" @@ -40,6 +39,7 @@ # include <selectLib.h> #endif +#include <chrono> #include <sys/wait.h> #include <errno.h> #include <fcntl.h> @@ -71,6 +71,29 @@ Q_DECLARE_TYPEINFO(pollfd, Q_PRIMITIVE_TYPE); static constexpr auto OneSecAsNsecs = std::chrono::nanoseconds(std::chrono::seconds{ 1 }).count(); +inline timespec durationToTimespec(std::chrono::nanoseconds timeout) noexcept +{ + using namespace std::chrono; + const seconds secs = duration_cast<seconds>(timeout); + const nanoseconds frac = timeout - secs; + struct timespec ts; + ts.tv_sec = secs.count(); + ts.tv_nsec = frac.count(); + return ts; +} + +template <typename Duration> +inline Duration timespecToChrono(struct timespec *ts) noexcept +{ + using namespace std::chrono; + return duration_cast<Duration>(seconds{ts->tv_sec} + nanoseconds{ts->tv_nsec}); +} + +inline std::chrono::milliseconds timespecToChronoMs(struct timespec *ts) noexcept +{ + return timespecToChrono<std::chrono::milliseconds>(ts); +} + // Internal operator functions for timespecs constexpr inline timespec &normalizedTimespec(timespec &t) { @@ -127,7 +150,7 @@ inline timeval timespecToTimeval(const timespec &ts) inline timespec &operator+=(timespec &t1, std::chrono::milliseconds msecs) { - t1 += QtMiscUtils::durationToTimespec(msecs); + t1 += durationToTimespec(msecs); return t1; } diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 58801b2d60..2c52aaa1ac 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -400,7 +400,7 @@ milliseconds QTimerInfoList::remainingDuration(int timerId) if (now < t->timeout) { // time to wait tm = roundToMillisecond(t->timeout - now); - return QtMiscUtils::timespecToChronoMs(&tm); + return timespecToChronoMs(&tm); } else { return milliseconds{0}; } diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 2c7ad6f0de..db66f54d0a 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -108,29 +108,6 @@ constexpr inline int qt_lencmp(qsizetype lhs, qsizetype rhs) noexcept /* else */ -1 ; } -inline timespec durationToTimespec(std::chrono::nanoseconds timeout) noexcept -{ - using namespace std::chrono; - const seconds secs = duration_cast<seconds>(timeout); - const nanoseconds frac = timeout - secs; - struct timespec ts; - ts.tv_sec = secs.count(); - ts.tv_nsec = frac.count(); - return ts; -} - -template <typename Duration> -inline Duration timespecToChrono(struct timespec *ts) noexcept -{ - using namespace std::chrono; - return duration_cast<Duration>(seconds{ts->tv_sec} + nanoseconds{ts->tv_nsec}); -} - -inline std::chrono::milliseconds timespecToChronoMs(struct timespec *ts) noexcept -{ - return timespecToChrono<std::chrono::milliseconds>(ts); -} - } // namespace QtMiscUtils // We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size. |