* autoload.cc (GetSystemTimePreciseAsFileTime): Define.

* times.cc (GetSystemTimePreciseAsFileTime): Temporarily declare here
	to workaround missing definition in 32 bit w32api headers.
	(get_system_time): New always inline function to call either
	GetSystemTimePreciseAsFileTime or GetSystemTimeAsFileTime on a per OS
	basis.  Call throughout instead of GetSystemTimeAsFileTime.
	* wincap.h (wincaps::has_precise_system_time): New element.
	* wincap.cc: Implement above element throughout.
This commit is contained in:
Corinna Vinschen
2013-06-14 15:41:17 +00:00
parent 0ff057d5a5
commit 7584fa98d4
5 changed files with 34 additions and 5 deletions

View File

@@ -31,6 +31,16 @@ hires_ms NO_COPY gtod;
hires_ns NO_COPY ntod;
extern "C" { void WINAPI GetSystemTimePreciseAsFileTime (LPFILETIME); }
static inline void __attribute__ ((always_inline))
get_system_time (PLARGE_INTEGER systime)
{
wincap.has_precise_system_time ()
? GetSystemTimePreciseAsFileTime ((LPFILETIME) systime)
: GetSystemTimeAsFileTime ((LPFILETIME) systime);
}
/* Cygwin internal */
static uint64_t __stdcall
__to_clock_t (PLARGE_INTEGER src, int flag)
@@ -64,7 +74,7 @@ times (struct tms *buf)
NtQueryInformationProcess (NtCurrentProcess (), ProcessTimes,
&kut, sizeof kut, NULL);
GetSystemTimeAsFileTime ((LPFILETIME) &ticks);
get_system_time (&ticks);
/* uptime */
ticks.QuadPart -= stodi.BootTime.QuadPart;
@@ -286,7 +296,7 @@ time_as_timestruc_t (timestruc_t * out)
{
LARGE_INTEGER systime;
GetSystemTimeAsFileTime ((LPFILETIME) &systime);
get_system_time (&systime);
to_timestruc_t (&systime, out);
}
@@ -298,7 +308,7 @@ time (time_t * ptr)
time_t res;
LARGE_INTEGER systime;
GetSystemTimeAsFileTime ((LPFILETIME) &systime);
get_system_time (&systime);
res = to_time_t (&systime);
if (ptr)
*ptr = res;
@@ -486,7 +496,7 @@ LONGLONG
hires_ms::nsecs ()
{
LARGE_INTEGER systime;
GetSystemTimeAsFileTime ((LPFILETIME) &systime);
get_system_time (&systime);
/* Add conversion factor for UNIX vs. Windows base time */
return systime.QuadPart - FACTOR;
}