Skip to content

Commit 96392b5

Browse files
Roumen PetrovFaraz Shahbazker
authored andcommitted
Issue python#17590: Move macros from pyconfig.h to pyport.h for Min GW
1 parent 652ed5b commit 96392b5

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

Include/pyport.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,26 @@ typedef int Py_ssize_clean_t;
161161
#endif
162162
#endif /*def __MINGW32__*/
163163

164+
/* Translate Windows-specific defines to those used in Python code:
165+
* MS_WIN64 - Code specific to the MS Win64 API
166+
* MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
167+
* MS_WINDOWS - Code specific to Windows, but all versions.
168+
169+
MSVC defines _WINxx to differentiate the windows platform types.
170+
Note that for compatibility reasons _WIN32 is defined on Win32
171+
*and* on Win64. For the same reasons, in Python, MS_WIN32 is
172+
defined on Win32 *and* Win64. Win32 only code must therefore be
173+
guarded as follows:
174+
#if defined(MS_WIN32) && !defined(MS_WIN64)
175+
*/
176+
#ifdef _WIN64
177+
# define MS_WIN64
178+
#endif
179+
#ifdef _WIN32
180+
# define MS_WIN32 /* only support win32 and greater. */
181+
# define MS_WINDOWS
182+
#endif
183+
164184
/* Py_LOCAL can be used instead of static to get the fastest possible calling
165185
* convention for functions that are local to a given module.
166186
*

PC/pyconfig.h

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ the following #defines
1313
1414
MS_WIN64 - Code specific to the MS Win64 API
1515
MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
16-
MS_WINDOWS - Code specific to Windows, but all versions.
16+
MS_WIN64, MS_WIN32, or MS_WINDOWS - Defined later in "pyport.h"
1717
Py_ENABLE_SHARED - Code if the Python core is built as a DLL.
1818
1919
Also note that neither "_M_IX86" or "_MSC_VER" should be used for
@@ -65,8 +65,6 @@ WIN32 is still required for the locale module.
6565
#define LONG_BIT 32
6666
#define WORD_BIT 32
6767

68-
#define MS_WIN32 /* only support win32 and greater. */
69-
#define MS_WINDOWS
7068
#ifndef PYTHONPATH
7169
# define PYTHONPATH L".\\DLLs;.\\lib"
7270
#endif
@@ -105,20 +103,14 @@ WIN32 is still required for the locale module.
105103
#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X
106104
#define _Py_STRINGIZE2(X) #X
107105

108-
/* MSVC defines _WINxx to differentiate the windows platform types
109-
110-
Note that for compatibility reasons _WIN32 is defined on Win32
111-
*and* on Win64. For the same reasons, in Python, MS_WIN32 is
112-
defined on Win32 *and* Win64. Win32 only code must therefore be
113-
guarded as follows:
114-
#if defined(MS_WIN32) && !defined(MS_WIN64)
106+
/* set the COMPILER
115107
*/
116108
#ifdef _WIN64
117109
#define MS_WIN64
118110
#endif
119111

120112
/* set the COMPILER */
121-
#ifdef MS_WIN64
113+
#ifdef _WIN64
122114
#if defined(_M_X64) || defined(_M_AMD64)
123115
#if defined(__INTEL_COMPILER)
124116
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
@@ -129,7 +121,7 @@ WIN32 is still required for the locale module.
129121
#else
130122
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
131123
#endif
132-
#endif /* MS_WIN64 */
124+
#endif /* _WIN64 */
133125

134126
/* set the version macros for the windows headers */
135127
/* Python 3.5+ requires Windows Vista or greater */
@@ -161,14 +153,14 @@ WIN32 is still required for the locale module.
161153
#endif
162154

163155
/* Define like size_t, omitting the "unsigned" */
164-
#ifdef MS_WIN64
156+
#ifdef _WIN64
165157
typedef __int64 ssize_t;
166158
#else
167159
typedef _W64 int ssize_t;
168160
#endif
169161
#define HAVE_SSIZE_T 1
170162

171-
#if defined(MS_WIN32) && !defined(MS_WIN64)
163+
#ifndef _WIN64
172164
#if defined(_M_IX86)
173165
#if defined(__INTEL_COMPILER)
174166
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
@@ -182,7 +174,7 @@ typedef _W64 int ssize_t;
182174
#else
183175
#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
184176
#endif
185-
#endif /* MS_WIN32 && !MS_WIN64 */
177+
#endif /* !_WIN64 */
186178

187179
typedef int pid_t;
188180

@@ -281,7 +273,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
281273
# endif /* Py_BUILD_CORE */
282274
#endif /* MS_COREDLL */
283275

284-
#if defined(MS_WIN64)
276+
#if defined(_WIN64)
285277
/* maintain "win32" sys.platform for backward compatibility of Python code,
286278
the Win64 API should be close enough to the Win32 API to make this
287279
preferable */
@@ -298,7 +290,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
298290
then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
299291
should define this. */
300292
# define HAVE_LARGEFILE_SUPPORT
301-
#elif defined(MS_WIN32)
293+
#else
302294
# define PLATFORM "win32"
303295
# define HAVE_LARGEFILE_SUPPORT
304296
# define SIZEOF_VOID_P 4
@@ -319,8 +311,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
319311
#endif
320312

321313

322-
#ifdef MS_WIN32
323-
324314
#define SIZEOF_SHORT 2
325315
#define SIZEOF_INT 4
326316
#define SIZEOF_LONG 4
@@ -342,8 +332,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
342332
#endif /* _MSC_VER > 1300 */
343333
#endif /* _MSC_VER */
344334

345-
#endif
346-
347335
/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
348336
implementation of Python integers. */
349337
#define PY_UINT32_T uint32_t

0 commit comments

Comments
 (0)