diff --git a/LOG b/LOG index e6082bfe94..eb70f2ed1f 100644 --- a/LOG +++ b/LOG @@ -320,3 +320,5 @@ the full buffer (but reporting that it did) in the case of errors from write. examples/csocket.c, examples/socket.ss +- use high-precision clock time on Windows 8 and up + c/stats.c diff --git a/c/stats.c b/c/stats.c index cd57e58bab..27b06118b5 100644 --- a/c/stats.c +++ b/c/stats.c @@ -115,6 +115,10 @@ ptr S_unique_id() { static __int64 hires_cps = 0; +typedef void (WINAPI *GetSystemTimeAsFileTime_t)(LPFILETIME lpSystemTimeAsFileTime); + +static GetSystemTimeAsFileTime_t s_GetSystemTimeAsFileTime = GetSystemTimeAsFileTime; + static void s_gettime(INT typeno, struct timespec *tp) { switch (typeno) { case time_process: { @@ -189,7 +193,7 @@ static void s_gettime(INT typeno, struct timespec *tp) { case time_utc: { FILETIME ft; __int64 total; - GetSystemTimeAsFileTime(&ft); + s_GetSystemTimeAsFileTime(&ft); total = ft.dwHighDateTime; total <<= 32; total |= ft.dwLowDateTime; @@ -459,5 +463,14 @@ ptr S_realtime(void) { /******** initialization ********/ void S_stats_init() { + /* Use GetSystemTimePreciseAsFileTime when available (Windows 8 and later). */ + HMODULE h = LoadLibrary("kernel32.dll"); + if (h != NULL) { + GetSystemTimeAsFileTime_t proc = (GetSystemTimeAsFileTime_t)GetProcAddress(h, "GetSystemTimePreciseAsFileTime"); + if (proc != NULL) + s_GetSystemTimeAsFileTime = proc; + else + FreeLibrary(h); + } s_gettime(time_monotonic, &starting_mono_tp); } diff --git a/release_notes/release_notes.stex b/release_notes/release_notes.stex index 4eac0abee7..17c84a44b5 100644 --- a/release_notes/release_notes.stex +++ b/release_notes/release_notes.stex @@ -58,6 +58,11 @@ Online versions of both books can be found at %----------------------------------------------------------------------------- \section{Functionality Changes}\label{section:functionality} +\subsection{High-precision clock time in Windows 8 and up (9.4.1)} + +When running on Windows 8 and up, Chez Scheme uses the high-precision +clock time function for the current date and time. + \subsection{Printing of non-standard (extended) identifiers (9.4.1)} Chez Scheme extends the syntax of identifiers as described in the