+ _sec = t / 1000;
+ _nsec = ( t - ( _sec * 1000 ) ) * 1000 * 1000;
+#elif defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS)
+ struct timespec ts;
+#if defined(_POSIX_MONOTONIC_CLOCK)
+ static clockid_t clockid = CLOCK_MONOTONIC;
+ static bool firstTime = true;
+ if (firstTime) {
+ firstTime = false;
+ // For the first time test if the monotonic clock is available.
+ // If so use this if not use the realtime clock.
+ if (-1 == clock_gettime(clockid, &ts) && errno == EINVAL)
+ clockid = CLOCK_REALTIME;
+ }
+ clock_gettime(clockid, &ts);
+#else
+ clock_gettime(CLOCK_REALTIME, &ts);
+#endif
+ _sec = ts.tv_sec;
+ _nsec = ts.tv_nsec;