MINGW-packages/mingw-w64-python/0010-pyport.h-Add-support-for-MINGW.patch
2025-10-10 14:31:04 +02:00

65 lines
3.0 KiB
Diff

From 6e8327cc3ab0167278f8ca0c69c5e9309f4275c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
<alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:23 +0530
Subject: [PATCH 010/N] pyport.h: Add support for MINGW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
---
Include/pyport.h | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/Include/pyport.h b/Include/pyport.h
index 3d70b8e..ddff496 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -532,12 +532,12 @@ extern char * _getpty(int *, int, mode_t, int);
*/
/*
- All windows ports, except cygwin, are handled in PC/pyconfig.h.
+ Only MSVC windows ports is handled in PC/pyconfig.h.
- Cygwin is the only other autoconf platform requiring special
+ Cygwin and Mingw is the only other autoconf platform requiring special
linkage handling and it uses __declspec().
*/
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__MINGW32__)
# define HAVE_DECLSPEC_DLL
#endif
@@ -550,21 +550,23 @@ extern char * _getpty(int *, int, mode_t, int);
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
/* module init functions inside the core need no external linkage */
- /* except for Cygwin to handle embedding */
-# if defined(__CYGWIN__)
+ /* except for Cygwin/Mingw to handle embedding */
+# if defined(__CYGWIN__) || defined(__MINGW32__)
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
-# else /* __CYGWIN__ */
+# else /* __CYGWIN__ || __MINGW32__*/
# define PyMODINIT_FUNC PyObject*
-# endif /* __CYGWIN__ */
+# endif /* __CYGWIN__ || __MINGW32__*/
# else /* Py_BUILD_CORE */
/* Building an extension module, or an embedded situation */
/* public Python functions and data are imported */
/* Under Cygwin, auto-import functions to prevent compilation */
/* failures similar to those described at the bottom of 4.1: */
/* http://docs.python.org/extending/windows.html#a-cookbook-approach */
-# if !defined(__CYGWIN__)
+# if defined(__CYGWIN__) || defined(__MINGW32__)
+# define PyAPI_FUNC(RTYPE) RTYPE
+# else
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
-# endif /* !__CYGWIN__ */
+# endif /* __CYGWIN__ || __MINGW32__*/
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
/* module init functions outside the core must be exported */
# if defined(__cplusplus)