summaryrefslogtreecommitdiff
path: root/numpy/f2py/cfuncs.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2021-01-19 20:52:54 +0200
committerGitHub <noreply@github.com>2021-01-19 20:52:54 +0200
commitcafda248a5856a6424324929c1708ea8048d89d6 (patch)
treeda00be8b146ab63a1721219ead2dbc40f36b3fca /numpy/f2py/cfuncs.py
parent9c63473c30b773dcab7adf699e1bd5dfcbb46e9b (diff)
downloadnumpy-cafda248a5856a6424324929c1708ea8048d89d6.tar.gz
BUG: threads.h existence test requires GLIBC > 2.12. (#18180)
* defined(__STDC_NO_THREADS__) can be trusted only when using glibc > 2.12 * Add __GLIBC__ defined check.
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r--numpy/f2py/cfuncs.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index 26b43e7e6..40496ccf1 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -549,7 +549,12 @@ cppmacros["F2PY_THREAD_LOCAL_DECL"] = """\
#define F2PY_THREAD_LOCAL_DECL __declspec(thread)
#elif defined(__STDC_VERSION__) \\
&& (__STDC_VERSION__ >= 201112L) \\
- && !defined(__STDC_NO_THREADS__)
+ && !defined(__STDC_NO_THREADS__) \\
+ && (!defined(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12))
+/* __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 */
#include <threads.h>
#define F2PY_THREAD_LOCAL_DECL thread_local
#elif defined(__GNUC__) \\