diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 528c4adeee7..bdd27adaf4c 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -572,18 +572,20 @@ """ cppmacros["F2PY_THREAD_LOCAL_DECL"] = """\ #ifndef F2PY_THREAD_LOCAL_DECL -#if defined(_MSC_VER) \\ - || defined(_WIN32) || defined(_WIN64) \\ - || defined(__MINGW32__) || defined(__MINGW64__) +#if defined(_MSC_VER) #define F2PY_THREAD_LOCAL_DECL __declspec(thread) +#elif defined(__MINGW32__) || defined(__MINGW64__) +#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(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12)) \\ + && !defined(__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 - of `threads.h` when using an older release of glibc 2.12 */ + of `threads.h` when using an older release of glibc 2.12 + See gh-19437 for details on OpenBSD */ #include #define F2PY_THREAD_LOCAL_DECL thread_local #elif defined(__GNUC__) \\