2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* Elapsed time package */
11 /* See rx_clock.h for calling conventions */
13 #include <afsconfig.h>
14 #include <afs/param.h>
23 struct clock clock_now
; /* The last elapsed time ready by clock_GetTimer */
25 /* This is set to 1 whenever the time is read, and reset to 0 whenever
26 * clock_NewTime is called. This is to allow the caller to control the
27 * frequency with which the actual time is re-evaluated.
29 #undef clock_haveCurrentTime
30 int clock_haveCurrentTime
= 0;
32 int clock_nUpdates
; /* The actual number of clock updates */
33 static int clockInitialized
= 0;
35 /* Timing tests show that we can compute times at about 4uS per call. */
36 LARGE_INTEGER rxi_clock0
;
37 LARGE_INTEGER rxi_clockFreq
;
39 #undef clock_UpdateTime
40 void clock_UpdateTime(void);
46 if (!QueryPerformanceFrequency(&rxi_clockFreq
)) {
47 OutputDebugString("No High Performance clock, exiting.\n");
56 /* Make clock uninitialized. */
66 clock_UpdateTime(void)
68 LARGE_INTEGER now
, delta
;
71 (void)QueryPerformanceCounter(&now
);
73 delta
.QuadPart
= now
.QuadPart
- rxi_clock0
.QuadPart
;
75 seconds
= (double)delta
.QuadPart
/ (double)rxi_clockFreq
.QuadPart
;
77 clock_now
.sec
= (int)seconds
;
78 clock_now
.usec
= (int)((seconds
- (double)clock_now
.sec
)
80 clock_haveCurrentTime
= 1;
84 #endif /* AFS_NT40_ENV */