sal/osl/w32/time.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 378f9d7e70f3702d53480df65841b1baa390c460
Author: László Németh <laszlo.nem...@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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to