summaryrefslogtreecommitdiffstats
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-03-02 16:01:10 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2015-03-02 16:01:10 (GMT)
commit3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2 (patch)
treee717f66fa69341710e7a5f35300714c40011d595 /Python/pytime.c
parent2f3d440549345857c7b1a6deb377b5b69052f639 (diff)
downloadcpython-3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2.zip
cpython-3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2.tar.gz
cpython-3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2.tar.bz2
Issue #23451: Update pyconfig.h for Windows to require Vista headers and remove unnecessary version checks.
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 a8460c6..cdaa22e 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -7,10 +7,6 @@
#include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */
#endif
-#ifdef MS_WINDOWS
-static OSVERSIONINFOEX winver;
-#endif
-
static int
pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
{
@@ -124,41 +120,11 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
static _PyTime_timeval last = {0, -1};
#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->tv_sec = result / 1000;
tp->tv_usec = (result % 1000) * 1000;
@@ -166,10 +132,7 @@ pymonotonic(_PyTime_timeval *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);
@@ -409,14 +372,6 @@ _PyTime_Init(void)
{
_PyTime_timeval tv;
-#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;