|
11 | 11 |
|
12 | 12 | #define HEADER_SHIM static inline __attribute__((__always_inline__)) |
13 | 13 |
|
14 | | -// MARK: - math functions for float |
| 14 | +// This header uses most of the libm functions, but we don't want to end up |
| 15 | +// exporting the libm declarations to modules that include NumericsShims, so |
| 16 | +// we don't want to actually #include <math.h>. |
| 17 | +// |
| 18 | +// For most of the functions, we can get around this by using __builtin_func |
| 19 | +// instead of func, since the compiler knows about these operations, but for |
| 20 | +// the non-standard extensions, we need to include our own declarations. This |
| 21 | +// is a little bit risky, in that we might end up missing an attribute that |
| 22 | +// gets added and effects calling conventions, etc, but that's expected to be |
| 23 | +// exceedingly rare. |
| 24 | +// |
| 25 | +// Still, we'll eventually want to find a better solution to this problem, |
| 26 | +// especially if people start using this package on systems that are not |
| 27 | +// Darwin or Ubuntu. |
15 | 28 |
|
| 29 | +// MARK: - math functions for float |
16 | 30 | HEADER_SHIM float libm_cosf(float x) { |
17 | 31 | return __builtin_cosf(x); |
18 | 32 | } |
@@ -131,9 +145,7 @@ HEADER_SHIM float libm_log10f(float x) { |
131 | 145 |
|
132 | 146 | #if !defined _WIN32 |
133 | 147 | HEADER_SHIM float libm_lgammaf(float x, int *signp) { |
134 | | -#if __APPLE__ |
135 | 148 | extern float lgammaf_r(float, int *); |
136 | | -#endif |
137 | 149 | return lgammaf_r(x, signp); |
138 | 150 | } |
139 | 151 | #endif |
@@ -253,9 +265,7 @@ HEADER_SHIM double libm_log10(double x) { |
253 | 265 |
|
254 | 266 | #if !defined _WIN32 |
255 | 267 | HEADER_SHIM double libm_lgamma(double x, int *signp) { |
256 | | -#if __APPLE__ |
257 | 268 | extern double lgamma_r(double, int *); |
258 | | -#endif |
259 | 269 | return lgamma_r(x, signp); |
260 | 270 | } |
261 | 271 | #endif |
|
0 commit comments