From 3d7bd0f32d966f229e1f7e6717ff236280173547 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 29 Jul 2018 10:06:11 +0200 Subject: [PATCH] Cleaned up code Moved current_utc_time out of the central tlUtils header where it does not belong. It a time function, so tlTimer.h is the better place. Plus it does not make sense to make this inline. This just spoils build times on changes. --- src/tl/tl/tlTimer.cc | 24 ++++++++++++++++++++++++ src/tl/tl/tlTimer.h | 7 +++++++ src/tl/tl/tlUtils.h | 27 --------------------------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/tl/tl/tlTimer.cc b/src/tl/tl/tlTimer.cc index c8058f30e..197fbd19a 100644 --- a/src/tl/tl/tlTimer.cc +++ b/src/tl/tl/tlTimer.cc @@ -36,9 +36,33 @@ # include #endif +#if defined(__MACH__) +#include +#include +#endif + namespace tl { +// ------------------------------------------------------------- + +void current_utc_time (struct timespec *ts) +{ + +#if defined(__MACH__) + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + ts->tv_sec = mts.tv_sec; + ts->tv_nsec = mts.tv_nsec; +#else + clock_gettime(CLOCK_REALTIME, ts); +#endif + +} + // ------------------------------------------------------------- // Gets the current time in ms from epoch diff --git a/src/tl/tl/tlTimer.h b/src/tl/tl/tlTimer.h index b25bd6105..2799e34af 100644 --- a/src/tl/tl/tlTimer.h +++ b/src/tl/tl/tlTimer.h @@ -28,12 +28,19 @@ #include #include +#include class QDateTime; namespace tl { +/** + * @brief clock_gettime is not implemented in Mac OS X 10.11 and lower + * From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c + */ +void current_utc_time (struct timespec *ts); + /** * @brief A basic timer class * diff --git a/src/tl/tl/tlUtils.h b/src/tl/tl/tlUtils.h index 498fd4fd1..84bdf5a5f 100644 --- a/src/tl/tl/tlUtils.h +++ b/src/tl/tl/tlUtils.h @@ -27,37 +27,10 @@ #include "tlAssert.h" #include -#include - -#if defined(__MACH__) -#include -#include -#endif namespace tl { -/** -* @brief clock_gettime is not implemented in Mac OS X 10.11 and lower -* From: https://gist.githubusercontent.com/jbenet/1087739/raw/638b37f76cdd9dc46d617443cab27eac297e2ee3/current_utc_time.c -*/ - -inline void current_utc_time(struct timespec *ts) { - -#if defined(__MACH__) - clock_serv_t cclock; - mach_timespec_t mts; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - ts->tv_sec = mts.tv_sec; - ts->tv_nsec = mts.tv_nsec; -#else - clock_gettime(CLOCK_REALTIME, ts); -#endif - -} - /** * @brief A template class mapping a begin .. end iterator pair to the at_end semantics */