1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
From a2e178675d5376e8985c489a6cb3bb463909fb41 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:19 +0530
Subject: [PATCH 009/N] MINGW init system calls
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
---
Modules/Setup | 1 -
Modules/Setup.config.in | 3 +++
Modules/posixmodule.c | 29 +++++++++++++++++++++++++----
configure.ac | 8 ++++++++
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/Modules/Setup b/Modules/Setup
index 02cfb67..6b6926d 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -101,7 +101,6 @@ PYTHONPATH=$(COREPYTHONPATH)
# This only contains the minimal set of modules required to run the
# setup.py script in the root of the Python source tree.
-posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c # posix (UNIX) system calls
errno errnomodule.c # posix (UNIX) errno values
pwd pwdmodule.c # this is needed to find out the user's home dir
# if $HOME is not set
diff --git a/Modules/Setup.config.in b/Modules/Setup.config.in
index 5c1299d..9b364fe 100644
--- a/Modules/Setup.config.in
+++ b/Modules/Setup.config.in
@@ -3,3 +3,6 @@
# The purpose of this file is to conditionally enable certain modules
# based on configure-time options.
+# init system calls(posix/nt/...) for INITFUNC (used by makesetup)
+@INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c
+
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index c984e2e..3f3e1f3 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -310,6 +310,27 @@ corresponding Unix manual entries for more information on calls.");
# define HAVE_CWAIT 1
# define HAVE_FSYNC 1
# define fsync _commit
+# elif defined(__MINGW32__) /* GCC for windows hosts */
+/* getlogin is detected by configure on mingw-w64 */
+# undef HAVE_GETLOGIN
+/*# define HAVE_GETCWD 1 - detected by configure*/
+# define HAVE_GETPPID 1
+# define HAVE_GETLOGIN 1
+# define HAVE_SPAWNV 1
+# define HAVE_WSPAWNV 1
+# define HAVE_WEXECV 1
+/*# define HAVE_EXECV 1 - detected by configure*/
+# define HAVE_PIPE 1
+# define HAVE_POPEN 1
+# define HAVE_SYSTEM 1
+# define HAVE_CWAIT 1
+# define HAVE_FSYNC 1
+# define fsync _commit
+# include <windows.h>
+# include <winioctl.h>
+# ifndef _MAX_ENV
+# define _MAX_ENV 32767
+# endif
# else
/* Unix functions that the configure script doesn't check for */
# ifndef __VXWORKS__
@@ -410,7 +431,7 @@ extern char *ctermid_r(char *);
# endif
#endif
-#ifdef _MSC_VER
+#ifdef MS_WINDOWS
# ifdef HAVE_DIRECT_H
# include <direct.h>
# endif
@@ -432,7 +453,7 @@ extern char *ctermid_r(char *);
# include <shellapi.h> // ShellExecute()
# include <lmcons.h> // UNLEN
# define HAVE_SYMLINK
-#endif /* _MSC_VER */
+#endif /* MS_WINDOWS */
#ifndef MAXPATHLEN
# if defined(PATH_MAX) && PATH_MAX > 1024
@@ -1521,9 +1542,9 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag)
** man environ(7).
*/
#include <crt_externs.h>
-#elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
+#elif !defined(MS_WINDOWS) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
extern char **environ;
-#endif /* !_MSC_VER */
+#endif /* !MS_WINDOWS */
static PyObject *
convertenviron(void)
diff --git a/configure.ac b/configure.ac
index 1f3c8af..ba8736b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -594,6 +594,14 @@ then
AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc)
fi
+AC_MSG_CHECKING([for init system calls])
+AC_SUBST(INITSYS)
+case $host in
+ *-*-mingw*) INITSYS=nt;;
+ *) INITSYS=posix;;
+esac
+AC_MSG_RESULT([$INITSYS])
+
# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
# it may influence the way we can build extensions, so distutils
# needs to check it
--
2.33.0
|