[Libreoffice-commits] core.git: Branch 'feature/fixes20' - sal/osl
László Németh
laszlo.nemeth at collabora.com
Mon Apr 11 11:31:51 UTC 2016
sal/osl/w32/time.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
New commits:
commit 378f9d7e70f3702d53480df65841b1baa390c460
Author: László Németh <laszlo.nemeth at collabora.com>
Date: Fri Apr 1 23:16:27 2016 +0200
osl_getSystemTime: use high precision timer of W32, if available
Change-Id: I7029f37639ead7a8b597ff39d1abcd295fab0551
diff --git a/sal/osl/w32/time.c b/sal/osl/w32/time.c
index 90d659a..325c57e 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;
More information about the Libreoffice-commits
mailing list