Commit 3e96f324 authored by Steve Dower's avatar Steve Dower

Issue #23451: Update pyconfig.h for Windows to require Vista headers and...

Issue #23451: Update pyconfig.h for Windows to require Vista headers and remove unnecessary version checks.
parent 2f3d4405
...@@ -1001,6 +1001,12 @@ PyDoc_STRVAR(GetVersion_doc, ...@@ -1001,6 +1001,12 @@ PyDoc_STRVAR(GetVersion_doc,
\n\ \n\
Return the version number of the current operating system."); Return the version number of the current operating system.");
/* Disable deprecation warnings about GetVersionEx as the result is
being passed straight through to the caller, who is responsible for
using it correctly. */
#pragma warning(push)
#pragma warning(disable:4996)
static PyObject * static PyObject *
winapi_GetVersion(PyObject* self, PyObject* args) winapi_GetVersion(PyObject* self, PyObject* args)
{ {
...@@ -1010,6 +1016,8 @@ winapi_GetVersion(PyObject* self, PyObject* args) ...@@ -1010,6 +1016,8 @@ winapi_GetVersion(PyObject* self, PyObject* args)
return PyLong_FromUnsignedLong(GetVersion()); return PyLong_FromUnsignedLong(GetVersion());
} }
#pragma warning(pop)
static PyObject * static PyObject *
winapi_OpenProcess(PyObject *self, PyObject *args) winapi_OpenProcess(PyObject *self, PyObject *args)
{ {
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
#else /* MS_WINDOWS */ #else /* MS_WINDOWS */
# include <winsock2.h> # include <winsock2.h>
/* Windows 'supports' CMSG_LEN, but does not follow the POSIX standard
* interface at all, so there is no point including the code that
* attempts to use it.
*/
# ifdef PySocket_BUILDING_SOCKET
# undef CMSG_LEN
# endif
# include <ws2tcpip.h> # include <ws2tcpip.h>
/* VC6 is shipped with old platform headers, and does not have MSTcpIP.h /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
* Separate SDKs have all the functions we want, but older ones don't have * Separate SDKs have all the functions we want, but older ones don't have
......
...@@ -519,10 +519,6 @@ unicode_result_unchanged(PyObject *unicode) ...@@ -519,10 +519,6 @@ unicode_result_unchanged(PyObject *unicode)
return _PyUnicode_Copy(unicode); return _PyUnicode_Copy(unicode);
} }
#ifdef HAVE_MBCS
static OSVERSIONINFOEX winver;
#endif
/* --- Bloom Filters ----------------------------------------------------- */ /* --- Bloom Filters ----------------------------------------------------- */
/* stuff to implement simple "bloom filters" for Unicode characters. /* stuff to implement simple "bloom filters" for Unicode characters.
...@@ -7112,13 +7108,7 @@ static DWORD ...@@ -7112,13 +7108,7 @@ static DWORD
encode_code_page_flags(UINT code_page, const char *errors) encode_code_page_flags(UINT code_page, const char *errors)
{ {
if (code_page == CP_UTF8) { if (code_page == CP_UTF8) {
if (winver.dwMajorVersion >= 6)
/* CP_UTF8 supports WC_ERR_INVALID_CHARS on Windows Vista
and later */
return WC_ERR_INVALID_CHARS; return WC_ERR_INVALID_CHARS;
else
/* CP_UTF8 only supports flags=0 on Windows older than Vista */
return 0;
} }
else if (code_page == CP_UTF7) { else if (code_page == CP_UTF7) {
/* CP_UTF7 only supports flags=0 */ /* CP_UTF7 only supports flags=0 */
...@@ -14976,13 +14966,6 @@ int _PyUnicode_Init(void) ...@@ -14976,13 +14966,6 @@ int _PyUnicode_Init(void)
if (PyType_Ready(&PyFormatterIter_Type) < 0) if (PyType_Ready(&PyFormatterIter_Type) < 0)
Py_FatalError("Can't initialize formatter iter type"); Py_FatalError("Can't initialize formatter iter type");
#ifdef HAVE_MBCS
winver.dwOSVersionInfoSize = sizeof(winver);
if (!GetVersionEx((OSVERSIONINFO*)&winver)) {
PyErr_SetFromWindowsErr(0);
return -1;
}
#endif
return 0; return 0;
} }
......
...@@ -156,9 +156,9 @@ WIN32 is still required for the locale module. ...@@ -156,9 +156,9 @@ WIN32 is still required for the locale module.
#endif /* MS_WIN64 */ #endif /* MS_WIN64 */
/* set the version macros for the windows headers */ /* set the version macros for the windows headers */
/* Python 3.4+ requires Windows XP or greater */ /* Python 3.5+ requires Windows Vista or greater */
#define Py_WINVER 0x0501 /* _WIN32_WINNT_WINXP */ #define Py_WINVER 0x0600 /* _WIN32_WINNT_VISTA */
#define Py_NTDDI NTDDI_WINXP #define Py_NTDDI NTDDI_VISTA
/* We only set these values when building Python - we don't want to force /* We only set these values when building Python - we don't want to force
these values on extensions, as that will affect the prototypes and these values on extensions, as that will affect the prototypes and
......
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
#include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */ #include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */
#endif #endif
#ifdef MS_WINDOWS
static OSVERSIONINFOEX winver;
#endif
static int static int
pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise) 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) ...@@ -124,41 +120,11 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
static _PyTime_timeval last = {0, -1}; static _PyTime_timeval last = {0, -1};
#endif #endif
#if defined(MS_WINDOWS) #if defined(MS_WINDOWS)
static ULONGLONG (*GetTickCount64) (void) = NULL;
static ULONGLONG (CALLBACK *Py_GetTickCount64)(void);
static int has_gettickcount64 = -1;
ULONGLONG result; ULONGLONG result;
assert(info == NULL || raise); assert(info == NULL || raise);
if (has_gettickcount64 == -1) { result = GetTickCount64();
/* 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;
}
tp->tv_sec = result / 1000; tp->tv_sec = result / 1000;
tp->tv_usec = (result % 1000) * 1000; tp->tv_usec = (result % 1000) * 1000;
...@@ -166,10 +132,7 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise) ...@@ -166,10 +132,7 @@ pymonotonic(_PyTime_timeval *tp, _Py_clock_info_t *info, int raise)
if (info) { if (info) {
DWORD timeAdjustment, timeIncrement; DWORD timeAdjustment, timeIncrement;
BOOL isTimeAdjustmentDisabled, ok; BOOL isTimeAdjustmentDisabled, ok;
if (has_gettickcount64)
info->implementation = "GetTickCount64()"; info->implementation = "GetTickCount64()";
else
info->implementation = "GetTickCount()";
info->monotonic = 1; info->monotonic = 1;
ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement, ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,
&isTimeAdjustmentDisabled); &isTimeAdjustmentDisabled);
...@@ -409,14 +372,6 @@ _PyTime_Init(void) ...@@ -409,14 +372,6 @@ _PyTime_Init(void)
{ {
_PyTime_timeval tv; _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 */ /* ensure that the system clock works */
if (_PyTime_gettimeofday_info(&tv, NULL) < 0) if (_PyTime_gettimeofday_info(&tv, NULL) < 0)
return -1; return -1;
......
...@@ -772,6 +772,12 @@ static PyStructSequence_Desc windows_version_desc = { ...@@ -772,6 +772,12 @@ static PyStructSequence_Desc windows_version_desc = {
via indexing, the rest are name only */ via indexing, the rest are name only */
}; };
/* Disable deprecation warnings about GetVersionEx as the result is
being passed straight through to the caller, who is responsible for
using it correctly. */
#pragma warning(push)
#pragma warning(disable:4996)
static PyObject * static PyObject *
sys_getwindowsversion(PyObject *self) sys_getwindowsversion(PyObject *self)
{ {
...@@ -803,6 +809,8 @@ sys_getwindowsversion(PyObject *self) ...@@ -803,6 +809,8 @@ sys_getwindowsversion(PyObject *self)
return version; return version;
} }
#pragma warning(pop)
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment