@@ -30,6 +30,44 @@ if openmp_dep.found()
30
30
dependencies += openmp_dep
31
31
endif
32
32
33
+ # Thread-local storage detection (borrowed from NumPy)
34
+ optional_variable_attributes = [
35
+ [' thread_local' , ' HAVE_THREAD_LOCAL' ], # C23
36
+ [' _Thread_local' , ' HAVE__THREAD_LOCAL' ], # C11/C17
37
+ [' __thread' , ' HAVE___THREAD' ], # GCC/Clang
38
+ [' __declspec(thread)' , ' HAVE___DECLSPEC_THREAD_' ] # MSVC
39
+ ]
40
+
41
+ if not is_variable (' cdata' )
42
+ cdata = configuration_data ()
43
+ endif
44
+
45
+ foreach optional_attr : optional_variable_attributes
46
+ attr = optional_attr[0 ]
47
+ code = '''
48
+ #pragma GCC diagnostic error "-Wattributes"
49
+ #pragma clang diagnostic error "-Wattributes"
50
+
51
+ int @0@ foo;
52
+
53
+ int main() {
54
+ return 0;
55
+ }
56
+ ''' .format(attr)
57
+
58
+ if c.compiles(code, name : optional_attr[0 ])
59
+ cdata.set10(optional_attr[1 ], true )
60
+ message (' Thread-local storage support found: @0@' .format(attr))
61
+ endif
62
+ endforeach
63
+
64
+ configure_file (
65
+ output : ' quaddtype_config.h' ,
66
+ configuration : cdata
67
+ )
68
+
69
+ build_includes = include_directories (' .' )
70
+
33
71
includes = include_directories (
34
72
[
35
73
incdir_numpy,
@@ -84,5 +122,5 @@ py.extension_module('_quaddtype_main',
84
122
dependencies : dependencies,
85
123
install : true ,
86
124
subdir : ' numpy_quaddtype' ,
87
- include_directories : includes
125
+ include_directories : [ includes, build_includes]
88
126
)
0 commit comments