summaryrefslogtreecommitdiffstats
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-27 13:12:08 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-27 13:12:08 (GMT)
commiteb352295fd8ceeaa19a72a4b3f7e7ad47676827c (patch)
treee5a9fb533d83698925f948e7a255315fd538515e /Python/pytime.c
parentcb29f0177c91ebb739b89d8cc4ba223785c94d61 (diff)
downloadcpython-eb352295fd8ceeaa19a72a4b3f7e7ad47676827c.zip
cpython-eb352295fd8ceeaa19a72a4b3f7e7ad47676827c.tar.gz
cpython-eb352295fd8ceeaa19a72a4b3f7e7ad47676827c.tar.bz2
Issue #23451, #22117: Python 3.5 now requires Windows Vista or newer, so
GetTickCount64() is now always available.
Diffstat (limited to 'Python/pytime.c')
-rw-r--r--Python/pytime.c49
1 files changed, 2 insertions, 47 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 52bd958..6bf7030 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -19,10 +19,6 @@
#define MS_TO_NS (MS_TO_US * US_TO_NS)
#define SEC_TO_NS (SEC_TO_MS * MS_TO_NS)
-#ifdef MS_WINDOWS
-static OSVERSIONINFOEX winver;
-#endif
-
static int
pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
{
@@ -542,41 +538,11 @@ pymonotonic_new(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
static _PyTime_t last = 0;
#endif
#if defined(MS_WINDOWS)
- static ULONGLONG (*GetTickCount64) (void) = NULL;
- static ULONGLONG (CALLBACK *Py_GetTickCount64)(void);
- static int has_gettickcount64 = -1;
ULONGLONG result;
assert(info == NULL || raise);
- if (has_gettickcount64 == -1) {
- /* GetTickCount64() was added to Windows Vista */
- has_gettickcount64 = (winver.dwMajorVersion >= 6);
- if (has_gettickcount64) {
- HINSTANCE hKernel32;
- hKernel32 = GetModuleHandleW(L"KERNEL32");
- *(FARPROC*)&Py_GetTickCount64 = GetProcAddress(hKernel32,
- "GetTickCount64");
- assert(Py_GetTickCount64 != NULL);
- }
- }
-
- if (has_gettickcount64) {
- result = Py_GetTickCount64();
- }
- else {
- static DWORD last_ticks = 0;
- static DWORD n_overflow = 0;
- DWORD ticks;
-
- ticks = GetTickCount();
- if (ticks < last_ticks)
- n_overflow++;
- last_ticks = ticks;
-
- result = (ULONGLONG)n_overflow << 32;
- result += ticks;
- }
+ result = GetTickCount64();
*tp = result * MS_TO_NS;
if (*tp / MS_TO_NS != result) {
@@ -591,10 +557,7 @@ pymonotonic_new(_PyTime_t *tp, _Py_clock_info_t *info, int raise)
if (info) {
DWORD timeAdjustment, timeIncrement;
BOOL isTimeAdjustmentDisabled, ok;
- if (has_gettickcount64)
- info->implementation = "GetTickCount64()";
- else
- info->implementation = "GetTickCount()";
+ info->implementation = "GetTickCount64()";
info->monotonic = 1;
ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,
&isTimeAdjustmentDisabled);
@@ -692,14 +655,6 @@ _PyTime_Init(void)
_PyTime_timeval tv;
_PyTime_t t;
-#ifdef MS_WINDOWS
- winver.dwOSVersionInfoSize = sizeof(winver);
- if (!GetVersionEx((OSVERSIONINFO*)&winver)) {
- PyErr_SetFromWindowsErr(0);
- return -1;
- }
-#endif
-
/* ensure that the system clock works */
if (_PyTime_gettimeofday_info(&tv, NULL) < 0)
return -1;