[Wine-patches] [PATCH 3/4] kernel32: Optimize GetSystemTime.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Вт Апр 7 16:54:17 MSD 2009
---
dlls/kernel32/time.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/time.c b/dlls/kernel32/time.c
index b30314c..95a6b60 100644
--- a/dlls/kernel32/time.c
+++ b/dlls/kernel32/time.c
@@ -19,6 +19,7 @@
*/
#include "config.h"
+#include "wine/port.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
@@ -933,13 +934,27 @@ VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
*/
VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
{
+ static int lock = 0;
+ static SYSTEMTIME old_systime;
+ static LARGE_INTEGER old;
FILETIME ft;
LARGE_INTEGER t;
+ while (interlocked_cmpxchg(&lock, 1, 0));
NtQuerySystemTime(&t);
- ft.dwLowDateTime = t.u.LowPart;
- ft.dwHighDateTime = t.u.HighPart;
- FileTimeToSystemTime(&ft, systime);
+ if (t.QuadPart == old.QuadPart)
+ {
+ *systime = old_systime;
+ }
+ else
+ {
+ ft.dwLowDateTime = t.u.LowPart;
+ ft.dwHighDateTime = t.u.HighPart;
+ FileTimeToSystemTime(&ft, systime);
+ old = t;
+ old_systime = *systime;
+ }
+ interlocked_xchg(&lock, 0);
}
/*********************************************************************
--
1.6.1.3.GIT
Подробная информация о списке рассылки Wine-patches