#include <time.h> /* clock_gettime(), clock_nanosleep() */
#include <stdlib.h> /* lldiv() */
#include <assert.h>
+#include <errno.h>
#if defined( PTH_INIT_IN_PTH_H ) /* GNU Pth */
static unsigned prec = 0;
static volatile mtime_t cached_time = 0;
-#if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
-# define CLOCK_MONOTONIC CLOCK_REALTIME
+#if defined( HAVE_CLOCK_NANOSLEEP )
+# if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
+# define CLOCK_MONOTONIC CLOCK_REALTIME
+# endif
#endif
/**
#elif defined( WIN32 ) || defined( UNDER_CE )
/* We don't need the real date, just the value of a high precision timer */
static mtime_t freq = I64C(-1);
- mtime_t usec_time;
if( freq == I64C(-1) )
{
{
/* Counter wrapped */
i_wrap_counts++;
- usec_time += I64C(0x100000000) * 1000;
+ res += I64C(0x100000000) * 1000;
}
- i_previous_time = usec_time;
+ i_previous_time = res;
LeaveCriticalSection( &date_lock );
}
#else
return p_date->date;
}
+#ifndef HAVE_GETTIMEOFDAY
+
#ifdef WIN32
+
/*
* Number of micro-seconds between the beginning of the Windows epoch
* (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
tv->tv_usec = (long) (tim % 1000000L);
return (0);
}
-#endif
+#endif
+#endif
/**
* @return NTP 64-bits timestamp in host byte order.