|
7 | 7 | #include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */ |
8 | 8 | #endif |
9 | 9 |
|
10 | | -#ifdef MS_WINDOWS |
11 | | -static OSVERSIONINFOEX winver; |
12 | | -#endif |
13 | | - |
14 | 10 | static int |
15 | 11 | pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise) |
16 | 12 | { |
@@ -124,52 +120,19 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise) |
124 | 120 | static _PyTime_timeval last = {0, -1}; |
125 | 121 | #endif |
126 | 122 | #if defined(MS_WINDOWS) |
127 | | - static ULONGLONG (*GetTickCount64) (void) = NULL; |
128 | | - static ULONGLONG (CALLBACK *Py_GetTickCount64)(void); |
129 | | - static int has_gettickcount64 = -1; |
130 | 123 | ULONGLONG result; |
131 | 124 |
|
132 | 125 | assert(info == NULL || raise); |
133 | 126 |
|
134 | | - if (has_gettickcount64 == -1) { |
135 | | - /* GetTickCount64() was added to Windows Vista */ |
136 | | - has_gettickcount64 = (winver.dwMajorVersion >= 6); |
137 | | - if (has_gettickcount64) { |
138 | | - HINSTANCE hKernel32; |
139 | | - hKernel32 = GetModuleHandleW(L"KERNEL32"); |
140 | | - *(FARPROC*)&Py_GetTickCount64 = GetProcAddress(hKernel32, |
141 | | - "GetTickCount64"); |
142 | | - assert(Py_GetTickCount64 != NULL); |
143 | | - } |
144 | | - } |
145 | | - |
146 | | - if (has_gettickcount64) { |
147 | | - result = Py_GetTickCount64(); |
148 | | - } |
149 | | - else { |
150 | | - static DWORD last_ticks = 0; |
151 | | - static DWORD n_overflow = 0; |
152 | | - DWORD ticks; |
153 | | - |
154 | | - ticks = GetTickCount(); |
155 | | - if (ticks < last_ticks) |
156 | | - n_overflow++; |
157 | | - last_ticks = ticks; |
158 | | - |
159 | | - result = (ULONGLONG)n_overflow << 32; |
160 | | - result += ticks; |
161 | | - } |
| 127 | + result = GetTickCount64(); |
162 | 128 |
|
163 | 129 | tp->tv_sec = result / 1000; |
164 | 130 | tp->tv_usec = (result % 1000) * 1000; |
165 | 131 |
|
166 | 132 | if (info) { |
167 | 133 | DWORD timeAdjustment, timeIncrement; |
168 | 134 | BOOL isTimeAdjustmentDisabled, ok; |
169 | | - if (has_gettickcount64) |
170 | | - info->implementation = "GetTickCount64()"; |
171 | | - else |
172 | | - info->implementation = "GetTickCount()"; |
| 135 | + info->implementation = "GetTickCount64()"; |
173 | 136 | info->monotonic = 1; |
174 | 137 | ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement, |
175 | 138 | &isTimeAdjustmentDisabled); |
@@ -409,14 +372,6 @@ _PyTime_Init(void) |
409 | 372 | { |
410 | 373 | _PyTime_timeval tv; |
411 | 374 |
|
412 | | -#ifdef MS_WINDOWS |
413 | | - winver.dwOSVersionInfoSize = sizeof(winver); |
414 | | - if (!GetVersionEx((OSVERSIONINFO*)&winver)) { |
415 | | - PyErr_SetFromWindowsErr(0); |
416 | | - return -1; |
417 | | - } |
418 | | -#endif |
419 | | - |
420 | 375 | /* ensure that the system clock works */ |
421 | 376 | if (_PyTime_gettimeofday_info(&tv, NULL) < 0) |
422 | 377 | return -1; |
|
0 commit comments