+#if defined HAVE_CLOCK_GETTIME && defined HAVE_DECL_CLOCK_MONOTONIC
+ {
+ /* Use CLOCK_MONOTONIC if available, so as to be unconfused if
+ * the system clock changes. */
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ return ts.tv_sec * TICKSPERSEC +
+ ts.tv_nsec / (1000000000 / TICKSPERSEC);
+ }
+#endif
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_sec * TICKSPERSEC + tv.tv_usec / (1000000 / TICKSPERSEC);
+ }