From 6a5dccabce2865a53767e641fd7a9e3d639e31e1 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 24 Jan 2022 11:41:25 +0000 Subject: [PATCH 1/3] MAINT: Restructure includes slightly --- numpy/f2py/cfuncs.py | 2 -- numpy/f2py/rules.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index bdd27adaf4c6..fb568f6d2794 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -51,8 +51,6 @@ includes0['string.h'] = '#include ' includes0['setjmp.h'] = '#include ' -includes['Python.h'] = '#include ' -needs['arrayobject.h'] = ['Python.h'] includes['arrayobject.h'] = '''#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API #include "arrayobject.h"''' diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index 78810a0a74a9..c8df9e32b2c6 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -124,6 +124,9 @@ #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ +/* Unconditionally included */ +#include + """ + gentitle("See f2py2e/cfuncs.py: includes") + """ #includes# #includes0# From 2eda78bd78679dc7c310ae0098e3ae41a69ca6e1 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 24 Jan 2022 11:49:47 +0000 Subject: [PATCH 2/3] MAINT: Use npy_os in f2py --- numpy/f2py/cfuncs.py | 4 ++-- numpy/f2py/rules.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index fb568f6d2794..1a9e12dfb507 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -64,7 +64,7 @@ typedefs['unsigned_long'] = 'typedef unsigned long unsigned_long;' typedefs['signed_char'] = 'typedef signed char signed_char;' typedefs['long_long'] = """\ -#ifdef _WIN32 +#if defined(NPY_OS_WIN32) typedef __int64 long_long; #else typedef long long long_long; @@ -72,7 +72,7 @@ #endif """ typedefs['unsigned_long_long'] = """\ -#ifdef _WIN32 +#if defined(NPY_OS_WIN32) typedef __uint64 long_long; #else typedef unsigned long long unsigned_long_long; diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index c8df9e32b2c6..eaa559528513 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -126,6 +126,7 @@ /* Unconditionally included */ #include +#include """ + gentitle("See f2py2e/cfuncs.py: includes") + """ #includes# From 5ffe257a19c5125ad981a5de018e5d492797d2e4 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Mon, 7 Mar 2022 00:04:47 +0000 Subject: [PATCH 3/3] MAINT: Use more NPY_OS --- numpy/core/include/numpy/npy_os.h | 4 ++++ numpy/f2py/cfuncs.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/numpy/core/include/numpy/npy_os.h b/numpy/core/include/numpy/npy_os.h index efa0e4012f91..6d335f75159b 100644 --- a/numpy/core/include/numpy/npy_os.h +++ b/numpy/core/include/numpy/npy_os.h @@ -21,6 +21,10 @@ #define NPY_OS_CYGWIN #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #define NPY_OS_WIN32 +#elif defined(_WIN64) || defined(__WIN64__) || defined(WIN64) + #define NPY_OS_WIN64 +#elif defined(__MINGW32__) || defined(__MINGW64__) + #define NPY_OS_MINGW #elif defined(__APPLE__) #define NPY_OS_DARWIN #else diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 1a9e12dfb507..f69933543918 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -572,13 +572,13 @@ #ifndef F2PY_THREAD_LOCAL_DECL #if defined(_MSC_VER) #define F2PY_THREAD_LOCAL_DECL __declspec(thread) -#elif defined(__MINGW32__) || defined(__MINGW64__) +#elif defined(NPY_OS_MINGW) #define F2PY_THREAD_LOCAL_DECL __thread #elif defined(__STDC_VERSION__) \\ && (__STDC_VERSION__ >= 201112L) \\ && !defined(__STDC_NO_THREADS__) \\ && (!defined(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12)) \\ - && !defined(__OpenBSD__) + && !defined(NPY_OS_OPENBSD) /* __STDC_NO_THREADS__ was first defined in a maintenance release of glibc 2.12, see https://lists.gnu.org/archive/html/commit-hurd/2012-07/msg00180.html, so `!defined(__STDC_NO_THREADS__)` may give false positive for the existence