summaryrefslogtreecommitdiff
path: root/numpy/f2py/cfuncs.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2020-06-07 23:36:38 +0300
committerPauli Virtanen <pav@iki.fi>2020-06-08 00:26:48 +0300
commit108067039712b82eaed8b17d8ebd6906fe4ba0fb (patch)
treee11496711bce1d7dd496631beee5fdc5193c87bd /numpy/f2py/cfuncs.py
parent8aee0e76ce2a6ddf8bbf81cc9d5c839a95fb06c9 (diff)
downloadnumpy-108067039712b82eaed8b17d8ebd6906fe4ba0fb.tar.gz
MAINT: f2py: move thread-local declaration definition to common macro
Move compiler thread-local declaration detection to a common macro. Also support C11 thread_local declaration, if available.
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r--numpy/f2py/cfuncs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py
index f1ac214d4..ccbc9b0fb 100644
--- a/numpy/f2py/cfuncs.py
+++ b/numpy/f2py/cfuncs.py
@@ -543,6 +543,21 @@ cppmacros['OLDPYNUM'] = """\
#error You need to install NumPy version 0.13 or higher. See https://scipy.org/install.html
#endif
"""
+cppmacros["F2PY_THREAD_LOCAL_DECL"] = """\
+#ifndef F2PY_THREAD_LOCAL_DECL
+#if defined(_MSC_VER)
+#define F2PY_THREAD_LOCAL_DECL __declspec(thread)
+#elif defined(__STDC_VERSION__) \\
+ && (__STDC_VERSION__ >= 201112L) \\
+ && !defined(__STDC_NO_THREADS__)
+#include <threads.h>
+#define F2PY_THREAD_LOCAL_DECL thread_local
+#elif defined(__GNUC__) \\
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 4)))
+#define F2PY_THREAD_LOCAL_DECL __thread
+#endif
+#endif
+"""
################# C functions ###############
cfuncs['calcarrindex'] = """\