MINGW-packages/mingw-w64-python/0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch
2025-04-18 07:39:35 +02:00

73 lines
2.3 KiB
Diff

From 651a0f883d0b0a9dc940fda40cb065128f748bd8 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:13 +0530
Subject: [PATCH 003/N] Define `MS_WINDOWS` (and others) when compiling with
MINGW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is used throughout the Python code but is not defined
when compiling with Mingw-w64 compilers, so define it.
In MSVC these are defined in PC/pyconfig.h, we have to
define it manually because pyconfig.h is created by
autotools.
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
Co-authored-by: Naveen M K <naveen521kk@gmail.com>
---
Include/pyport.h | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/Include/pyport.h b/Include/pyport.h
index e2bac3b..3d70b8e 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -53,6 +53,44 @@
#endif
+#ifdef __MINGW32__
+/* Translate GCC[mingw*] platform specific defines to those
+ * used in python code.
+ */
+#if !defined(MS_WIN64) && defined(_WIN64)
+# define MS_WIN64
+#endif
+#if !defined(MS_WIN32) && defined(_WIN32)
+# define MS_WIN32
+#endif
+#if !defined(MS_WINDOWS) && defined(MS_WIN32)
+# define MS_WINDOWS
+#endif
+
+#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE)
+#include <winapifamily.h>
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define MS_WINDOWS_DESKTOP
+#endif
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#define MS_WINDOWS_APP
+#endif
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)
+#define MS_WINDOWS_SYSTEM
+#endif
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
+#define MS_WINDOWS_GAMES
+#endif
+
+/* Define to 1 if you support windows console io */
+#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
+#define HAVE_WINDOWS_CONSOLE_IO 1
+#endif
+#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */
+
+#endif /* __MINGW32__*/
+
/**************************************************************************
Symbols and macros to supply platform-independent interfaces to basic
C language & library operations whose spellings vary across platforms.