diff options
author | László Németh <laszlo.nemeth@collabora.com> | 2016-04-01 23:16:27 +0200 |
---|---|---|
committer | László Németh <laszlo.nemeth@collabora.com> | 2016-04-04 13:50:27 +0200 |
commit | 3979afceecb98780549fda60c7f75c8015bb33d8 (patch) | |
tree | 85012a385026b09445caae3bda90e50337c989bb /sal | |
parent | 6b2d75f966140746e4fed4c0dd43a452e0cfdbae (diff) |
osl_getSystemTime: use high precision timer of W32, if available
Change-Id: I7029f37639ead7a8b597ff39d1abcd295fab0551
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/w32/time.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sal/osl/w32/time.c b/sal/osl/w32/time.c index 90d659a8cca0..325c57e9831a 100644 --- a/sal/osl/w32/time.c +++ b/sal/osl/w32/time.c @@ -35,10 +35,28 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) FILETIME CurTime, OffTime; __int64 Value; + typedef BOOL (WINAPI *CheckTokenMembership_PROC)( HANDLE, PSID, PBOOL ); + + static HMODULE hModule = NULL; + static CheckTokenMembership_PROC pCheckTokenMembership = NULL; + OSL_ASSERT(pTimeVal != 0); - GetSystemTime(&SystemTime); - SystemTimeToFileTime(&SystemTime, &CurTime); + if ( !hModule ) + { + hModule = GetModuleHandleA( "Kernel32.dll" ); + if ( hModule ) + pCheckTokenMembership = (CheckTokenMembership_PROC)GetProcAddress( hModule, "GetSystemTimePreciseAsFileTime" ); + } + + // use ~1 microsecond resolution if available + if ( pCheckTokenMembership ) + GetSystemTimePreciseAsFileTime(&CurTime); + else + { + GetSystemTime(&SystemTime); + SystemTimeToFileTime(&SystemTime, &CurTime); + } SystemTime.wYear = 1970; SystemTime.wMonth = 1; |