Huw Davies huw@codeweavers.com writes:
@@ -764,7 +768,38 @@ void WINAPI GetSystemTimeAsFileTime( FILETIME *time ) { LARGE_INTEGER t;
- NtQuerySystemTime( &t );
+#ifdef HAVE_CLOCK_GETTIME
- struct timespec ts;
- static clockid_t clock_id = CLOCK_MONOTONIC; /* placeholder */
- if (clock_id == CLOCK_MONOTONIC)
- {
+#ifdef CLOCK_REALTIME_COARSE
struct timespec res;/* Use CLOCK_REALTIME_COARSE if it has 1 ms or better resolution */if (!clock_getres( CLOCK_REALTIME_COARSE, &res ) && res.tv_sec == 0 && res.tv_nsec <= 1000000)clock_id = CLOCK_REALTIME_COARSE;else+#endif /* CLOCK_REALTIME_COARSE */
clock_id = CLOCK_REALTIME;- }
- if (!clock_gettime( clock_id, &ts ))
- {
t.QuadPart = ts.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;t.QuadPart += (ts.tv_nsec + 50) / 100;- }
- else
+#endif /* HAVE_CLOCK_GETTIME */
- {
struct timeval now;gettimeofday( &now, 0 );t.QuadPart = now.tv_sec * (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;t.QuadPart += now.tv_usec * 10;- }
Do we really need to duplicate the entire thing?
If the extra call to ntdll is really that expensive, you could probably forward to it instead.