Trevor Gross 36b52c7d1b Introduce musl-math-sys for bindings to musl math symbols
This crate builds math symbols from a musl checkout and provides a Rust
interface. The intent is that we will be able to compare our
implementations against musl on more than just linux (which are the only
currently the only targets we run `*-musl` targets against for
comparison).

Musl libc can't compile on anything other than Linux; however, the
routines in `src/math` are cross platform enough to build on MacOS and
windows-gnu with only minor adjustments. We take advantage of this and
build only needed files using `cc`.

The build script also performs remapping (via defines) so that e.g.
`cos` gets defined as `musl_cos`. This gives us more certainty that we
are actually testing against the intended symbol; without it, it is easy
to unknowingly link to system libraries or even Rust's `libm` itself and
wind up with an ineffective test. There is also a small procedure to
verify remapping worked correctly by checking symbols in object files.
2024-10-28 12:59:38 -05:00

41 lines
924 B
C

/* On platforms that don't support weak symbols, define required aliases
* as wrappers. See comments in `features.h` for more.
*/
#if defined(__APPLE__) || defined(__MINGW32__)
double __lgamma_r(double a, int *b);
float __lgammaf_r(float a, int *b);
long __lgammal_r(long double a, int *b);
double exp10(double a);
float exp10f(float a);
long exp10l(long double a);
double remainder(double a, double b);
float remainderf(float a, float b);
double lgamma_r(double a, int *b) {
return __lgamma_r(a, b);
}
float lgammaf_r(float a, int *b) {
return __lgammaf_r(a, b);
}
long double lgammal_r(long double a, int *b) {
return __lgammal_r(a, b);
}
double pow10(double a) {
return exp10(a);
}
float pow10f(float a) {
return exp10f(a);
}
long double pow10l(long double a) {
return exp10l(a);
}
double drem(double a, double b) {
return remainder(a, b);
}
float dremf(float a, float b) {
return remainderf(a, b);
}
#endif