From 75a984933791db8bf162e1c6546b294dea121f0e Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sat, 23 Feb 2013 19:53:27 +0200 Subject: [PATCH 09/16] MINGW: init system calls --- Modules/Setup.config.in | 3 +++ Modules/Setup.dist | 1 - Modules/posixmodule.c | 27 ++++++++++++++++++++++----- configure.ac | 8 ++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Modules/Setup.config.in b/Modules/Setup.config.in index 5ac2404..3bcb0ba 100644 --- a/Modules/Setup.config.in +++ b/Modules/Setup.config.in @@ -3,6 +3,9 @@ # 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@ posixmodule.c + # Threading @USE_THREAD_MODULE@_thread _threadmodule.c diff --git a/Modules/Setup.dist b/Modules/Setup.dist index f45de5c..09c418c 100644 --- a/Modules/Setup.dist +++ b/Modules/Setup.dist @@ -105,7 +105,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 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/posixmodule.c b/Modules/posixmodule.c index 6830684..284c5ee 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -152,6 +152,25 @@ 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_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 +#include +#ifndef _MAX_ENV +#define _MAX_ENV 32767 +#endif #else #if defined(__VMS) /* Everything needed is defined in vms/pyconfig.h */ @@ -278,7 +297,7 @@ extern int lstat(const char *, struct stat *); #endif #endif -#ifdef _MSC_VER +#ifdef MS_WINDOWS #ifdef HAVE_DIRECT_H #include #endif @@ -1061,7 +1080,7 @@ win32_get_reparse_tag(HANDLE reparse_point_handle, ULONG *reparse_tag) */ #include static char **environ; -#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) ) +#elif !defined(MS_WINDOWS) && ( !defined(__WATCOMC__) || defined(__QNX__) ) extern char **environ; #endif /* !_MSC_VER */ @@ -3597,8 +3616,6 @@ posix__getfullpathname(PyObject *self, PyObject *args) return PyBytes_FromString(outbuf); } /* end of posix__getfullpathname */ - - /* A helper function for samepath on windows */ static PyObject * posix__getfinalpathname(PyObject *self, PyObject *args) @@ -11154,7 +11171,7 @@ all_ins(PyObject *d) } -#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) +#if defined(MS_WINDOWS) && !defined(__QNX__) #define INITFUNC PyInit_nt #define MODNAME "nt" diff --git a/configure.ac b/configure.ac index 441c377..f32c549 100644 --- a/configure.ac +++ b/configure.ac @@ -556,6 +556,14 @@ then fi AC_MSG_RESULT($MACHDEP) +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 -- 1.7.12.1