Use high-precision clock time on Windows 8 and up.

original commit: 15982a28189454d5b7b3b065db5aac9816781bde
This commit is contained in:
Bob Burger 2016-09-22 13:36:10 -04:00
parent e65bb0595c
commit 30c6552ec2
3 changed files with 21 additions and 1 deletions

2
LOG
View File

@ -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

View File

@ -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);
}

View File

@ -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