@@ -148,20 +148,32 @@ endforeach |
148 | 148 | # Mandatory functions: if not found, fail the build |
149 | 149 | # Some of these can still be blocklisted if the C99 implementation |
150 | 150 | # is buggy, see numpy/core/src/common/npy_config.h |
151 | | -mandatory_funcs = [ |
| 151 | +mandatory_math_funcs = [ |
152 | 152 | 'sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh', 'fabs', |
153 | 153 | 'floor', 'ceil', 'sqrt', 'log10', 'log', 'exp', 'asin', |
154 | 154 | 'acos', 'atan', 'fmod', 'modf', 'frexp', 'ldexp', |
155 | 155 | 'expm1', 'log1p', 'acosh', 'asinh', 'atanh', |
156 | | - 'rint', 'trunc', 'exp2', |
157 | | - 'copysign', 'nextafter', 'strtoll', 'strtoull', 'cbrt', |
| 156 | + 'rint', 'trunc', 'exp2', 'copysign', 'nextafter', 'cbrt', |
158 | 157 | 'log2', 'pow', 'hypot', 'atan2', |
159 | | - 'csin', 'csinh', 'ccos', 'ccosh', 'ctan', 'ctanh', |
160 | | - 'creal', 'cimag', 'conj' |
161 | 158 | ] |
162 | | -foreach func: mandatory_funcs |
163 | | - if not cc.has_function(func) |
164 | | - error('Function `{func}` not found') |
| 159 | +foreach func: mandatory_math_funcs |
| 160 | + if not cc.has_function(func, prefix: '#include <math.h>', dependencies: m_dep) |
| 161 | + error(f'Function `@func@` not found') |
| 162 | + endif |
| 163 | +endforeach |
| 164 | + |
| 165 | +mandatory_complex_math_funcs = [ |
| 166 | + 'csin', 'csinh', 'ccos', 'ccosh', 'ctan', 'ctanh', 'creal', 'cimag', 'conj' |
| 167 | +] |
| 168 | +foreach func: mandatory_complex_math_funcs |
| 169 | + if not cc.has_function(func, prefix: '#include <complex.h>', dependencies: m_dep) |
| 170 | + error(f'Function `@func@` not found') |
| 171 | + endif |
| 172 | +endforeach |
| 173 | + |
| 174 | +foreach func: ['strtoll', 'strtoull'] |
| 175 | + if not cc.has_function(func, prefix: '#include <stdlib.h>') |
| 176 | + error(f'Function `@func@` not found') |
165 | 177 | endif |
166 | 178 | endforeach |
167 | 179 |
|
@@ -175,13 +187,13 @@ c99_complex_funcs = [ |
175 | 187 | foreach func: c99_complex_funcs |
176 | 188 | func_single = func + 'f' |
177 | 189 | func_longdouble = func + 'l' |
178 | | - if cc.has_function(func) |
| 190 | + if cc.has_function(func, prefix: '#include <complex.h>', dependencies: m_dep) |
179 | 191 | cdata.set10('HAVE_' + func.to_upper(), true) |
180 | 192 | endif |
181 | | - if cc.has_function(func_single) |
| 193 | + if cc.has_function(func_single, prefix: '#include <complex.h>', dependencies: m_dep) |
182 | 194 | cdata.set10('HAVE_' + func_single.to_upper(), true) |
183 | 195 | endif |
184 | | - if cc.has_function(func_longdouble) |
| 196 | + if cc.has_function(func_longdouble, prefix: '#include <complex.h>', dependencies: m_dep) |
185 | 197 | cdata.set10('HAVE_' + func_longdouble.to_upper(), true) |
186 | 198 | endif |
187 | 199 | endforeach |
@@ -190,7 +202,7 @@ endforeach |
190 | 202 | # libnpymath as a C99 compat layer, these may still be relevant. |
191 | 203 | c99_macros = ['isfinite', 'isinf', 'isnan', 'signbit'] |
192 | 204 | foreach macro: c99_macros |
193 | | - if cc.has_function(macro) |
| 205 | + if cc.has_function(macro, prefix: '#include <math.h>', dependencies: m_dep) |
194 | 206 | cdata.set10('NPY_HAVE_DECL_' + macro.to_upper(), true) |
195 | 207 | if not cc.has_header_symbol('Python.h', macro, dependencies: py_dep) |
196 | 208 | # Add in config.h as well, except if it will clash with Python's config.h content |
|