Use high-precision clock time on Windows 8 and up.
original commit: 15982a28189454d5b7b3b065db5aac9816781bde
This commit is contained in:
parent
e65bb0595c
commit
30c6552ec2
2
LOG
2
LOG
|
@ -320,3 +320,5 @@
|
||||||
the full buffer (but reporting that it did) in the case of errors from
|
the full buffer (but reporting that it did) in the case of errors from
|
||||||
write.
|
write.
|
||||||
examples/csocket.c, examples/socket.ss
|
examples/csocket.c, examples/socket.ss
|
||||||
|
- use high-precision clock time on Windows 8 and up
|
||||||
|
c/stats.c
|
||||||
|
|
15
c/stats.c
15
c/stats.c
|
@ -115,6 +115,10 @@ ptr S_unique_id() {
|
||||||
|
|
||||||
static __int64 hires_cps = 0;
|
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) {
|
static void s_gettime(INT typeno, struct timespec *tp) {
|
||||||
switch (typeno) {
|
switch (typeno) {
|
||||||
case time_process: {
|
case time_process: {
|
||||||
|
@ -189,7 +193,7 @@ static void s_gettime(INT typeno, struct timespec *tp) {
|
||||||
case time_utc: {
|
case time_utc: {
|
||||||
FILETIME ft; __int64 total;
|
FILETIME ft; __int64 total;
|
||||||
|
|
||||||
GetSystemTimeAsFileTime(&ft);
|
s_GetSystemTimeAsFileTime(&ft);
|
||||||
total = ft.dwHighDateTime;
|
total = ft.dwHighDateTime;
|
||||||
total <<= 32;
|
total <<= 32;
|
||||||
total |= ft.dwLowDateTime;
|
total |= ft.dwLowDateTime;
|
||||||
|
@ -459,5 +463,14 @@ ptr S_realtime(void) {
|
||||||
/******** initialization ********/
|
/******** initialization ********/
|
||||||
|
|
||||||
void S_stats_init() {
|
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);
|
s_gettime(time_monotonic, &starting_mono_tp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,11 @@ Online versions of both books can be found at
|
||||||
%-----------------------------------------------------------------------------
|
%-----------------------------------------------------------------------------
|
||||||
\section{Functionality Changes}\label{section:functionality}
|
\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)}
|
\subsection{Printing of non-standard (extended) identifiers (9.4.1)}
|
||||||
|
|
||||||
Chez Scheme extends the syntax of identifiers as described in the
|
Chez Scheme extends the syntax of identifiers as described in the
|
||||||
|
|
Loading…
Reference in New Issue
Block a user