Skip to content

Commit

Permalink
BUG: threads.h existence test requires GLIBC > 2.12. (#18180)
Browse files Browse the repository at this point in the history
* defined(__STDC_NO_THREADS__) can be trusted only when using glibc > 2.12

* Add __GLIBC__ defined check.
  • Loading branch information
pearu authored and charris committed Feb 7, 2021
1 parent be298a0 commit 45a6ec0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion numpy/f2py/cfuncs.py
Expand Up @@ -549,7 +549,12 @@
#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__) \\
Expand Down

0 comments on commit 45a6ec0

Please sign in to comment.