Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

move into musl dir #162

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ edition = "2018"

[features]
# only used to run our test suite
default = ['stable']
default = ['stable', 'musl']
stable = []
musl = []

# Generate tests which are random inputs and the outputs are calculated with
# musl libc.
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod musl_reference_tests {
}

pub fn generate() {
let files = fs::read_dir("src/math")
let files = fs::read_dir("src/math/musl")
.unwrap()
.map(|f| f.unwrap().path())
.collect::<Vec<_>>();
Expand Down
159 changes: 3 additions & 156 deletions src/math/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,162 +69,9 @@ macro_rules! llvm_intrinsically_optimized {
};
}

// Public modules
mod acos;
mod acosf;
mod asin;
mod asinf;
mod atan;
mod atan2;
mod atan2f;
mod atanf;
mod cbrt;
mod cbrtf;
mod ceil;
mod ceilf;
mod cos;
mod cosf;
mod cosh;
mod coshf;
mod exp;
mod exp2;
mod exp2f;
mod expf;
mod expm1;
mod expm1f;
mod fabs;
mod fabsf;
mod fdim;
mod fdimf;
mod floor;
mod floorf;
mod fma;
mod fmaf;
mod fmod;
mod fmodf;
mod hypot;
mod hypotf;
mod ldexp;
mod ldexpf;
mod log;
mod log10;
mod log10f;
mod log1p;
mod log1pf;
mod log2;
mod log2f;
mod logf;
mod pow;
mod powf;
mod round;
mod roundf;
mod scalbn;
mod scalbnf;
mod sin;
mod sinf;
mod sinh;
mod sinhf;
mod sqrt;
mod sqrtf;
mod tan;
mod tanf;
mod tanh;
mod tanhf;
mod trunc;
mod truncf;

// Use separated imports instead of {}-grouped imports for easier merging.
pub use self::acos::acos;
pub use self::acosf::acosf;
pub use self::asin::asin;
pub use self::asinf::asinf;
pub use self::atan::atan;
pub use self::atan2::atan2;
pub use self::atan2f::atan2f;
pub use self::atanf::atanf;
pub use self::cbrt::cbrt;
pub use self::cbrtf::cbrtf;
pub use self::ceil::ceil;
pub use self::ceilf::ceilf;
pub use self::cos::cos;
pub use self::cosf::cosf;
pub use self::cosh::cosh;
pub use self::coshf::coshf;
pub use self::exp::exp;
pub use self::exp2::exp2;
pub use self::exp2f::exp2f;
pub use self::expf::expf;
pub use self::expm1::expm1;
pub use self::expm1f::expm1f;
pub use self::fabs::fabs;
pub use self::fabsf::fabsf;
pub use self::fdim::fdim;
pub use self::fdimf::fdimf;
pub use self::floor::floor;
pub use self::floorf::floorf;
pub use self::fma::fma;
pub use self::fmaf::fmaf;
pub use self::fmod::fmod;
pub use self::fmodf::fmodf;
pub use self::hypot::hypot;
pub use self::hypotf::hypotf;
pub use self::ldexp::ldexp;
pub use self::ldexpf::ldexpf;
pub use self::log::log;
pub use self::log10::log10;
pub use self::log10f::log10f;
pub use self::log1p::log1p;
pub use self::log1pf::log1pf;
pub use self::log2::log2;
pub use self::log2f::log2f;
pub use self::logf::logf;
pub use self::pow::pow;
pub use self::powf::powf;
pub use self::round::round;
pub use self::roundf::roundf;
pub use self::scalbn::scalbn;
pub use self::scalbnf::scalbnf;
pub use self::sin::sin;
pub use self::sinf::sinf;
pub use self::sinh::sinh;
pub use self::sinhf::sinhf;
pub use self::sqrt::sqrt;
pub use self::sqrtf::sqrtf;
pub use self::tan::tan;
pub use self::tanf::tanf;
pub use self::tanh::tanh;
pub use self::tanhf::tanhf;
pub use self::trunc::trunc;
pub use self::truncf::truncf;

// Private modules
mod expo2;
mod fenv;
mod k_cos;
mod k_cosf;
mod k_expo2;
mod k_expo2f;
mod k_sin;
mod k_sinf;
mod k_tan;
mod k_tanf;
mod rem_pio2;
mod rem_pio2_large;
mod rem_pio2f;

// Private re-imports
use self::expo2::expo2;
use self::k_cos::k_cos;
use self::k_cosf::k_cosf;
use self::k_expo2::k_expo2;
use self::k_expo2f::k_expo2f;
use self::k_sin::k_sin;
use self::k_sinf::k_sinf;
use self::k_tan::k_tan;
use self::k_tanf::k_tanf;
use self::rem_pio2::rem_pio2;
use self::rem_pio2_large::rem_pio2_large;
use self::rem_pio2f::rem_pio2f;
pub mod musl;
#[cfg(feature = "musl")]
pub use self::musl::*;

#[inline]
fn get_high_word(x: f64) -> u32 {
Expand Down
176 changes: 176 additions & 0 deletions src/math/musl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// f64 modules
mod acos;
mod asin;
mod atan;
mod atan2;
mod cbrt;
mod ceil;
mod cos;
mod cosh;
mod exp;
mod expm1;
mod fabs;
mod fdim;
mod floor;
mod fma;
mod fmod;
mod hypot;
mod ldexp;
mod log;
mod log10;
mod log1p;
mod log2;
mod pow;
mod round;
mod scalbn;
mod sin;
mod sinh;
mod sqrt;
mod tan;
mod tanh;
mod trunc;

// f32 modules
mod acosf;
mod asinf;
mod atan2f;
mod atanf;
mod cbrtf;
mod ceilf;
mod cosf;
mod coshf;
mod exp2;
mod exp2f;
mod expf;
mod expm1f;
mod fabsf;
mod fdimf;
mod floorf;
mod fmaf;
mod fmodf;
mod hypotf;
mod ldexpf;
mod log10f;
mod log1pf;
mod log2f;
mod logf;
mod powf;
mod roundf;
mod scalbnf;
mod sinf;
mod sinhf;
mod sqrtf;
mod tanf;
mod tanhf;
mod truncf;

// Public f64 functions
#[rustfmt::skip]
pub use self::{
acos::acos,
asin::asin,
atan::atan,
atan2::atan2,
cbrt::cbrt,
ceil::ceil,
cos::cos,
cosh::cosh,
exp::exp,
exp2::exp2,
expm1::expm1,
fabs::fabs,
fdim::fdim,
floor::floor,
fma::fma,
fmod::fmod,
hypot::hypot,
ldexp::ldexp,
log::log,
log2::log2,
pow::pow,
round::round,
scalbn::scalbn,
sin::sin,
sinh::sinh,
sqrt::sqrt,
tan::tan,
tanh::tanh,
trunc::trunc,
};

// Public f32 functions
#[rustfmt::skip]
pub use self::{
acosf::acosf,
asinf::asinf,
atan2f::atan2f,
atanf::atanf,
cbrtf::cbrtf,
ceilf::ceilf,
cosf::cosf,
coshf::coshf,
exp2f::exp2f,
expf::expf,
expm1f::expm1f,
fabsf::fabsf,
fdimf::fdimf,
floorf::floorf,
fmaf::fmaf,
fmodf::fmodf,
hypotf::hypotf,
ldexpf::ldexpf,
log10::log10,
log10f::log10f,
log1p::log1p,
log1pf::log1pf,
log2f::log2f,
logf::logf,
powf::powf,
roundf::roundf,
scalbnf::scalbnf,
sinf::sinf,
sinhf::sinhf,
sqrtf::sqrtf,
tanf::tanf,
tanhf::tanhf,
truncf::truncf,
};

// Private f64 modules
mod expo2;
mod fenv;
mod k_cos;
mod k_expo2;
mod k_sin;
mod k_tan;
mod rem_pio2;
mod rem_pio2_large;

// Private f32 modules
mod k_cosf;
mod k_expo2f;
mod k_sinf;
mod k_tanf;
mod rem_pio2f;

// Private f64 re-imports
#[rustfmt::skip]
use self::{
expo2::expo2,
k_cos::k_cos,
k_sin::k_sin,
k_tan::k_tan,
rem_pio2::rem_pio2,
rem_pio2_large::rem_pio2_large,
};

// Private f32 re-imports
#[rustfmt::skip]
use self::{
k_cosf::k_cosf,
k_expo2::k_expo2,
k_expo2f::k_expo2f,
k_sinf::k_sinf,
k_tanf::k_tanf,
rem_pio2f::rem_pio2f,
};
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/math/asin.rs → src/math/musl/asin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
*
*/

use super::{fabs, get_high_word, get_low_word, sqrt, with_set_low_word};
use crate::math::{get_high_word, get_low_word, with_set_low_word};
use super::{fabs, sqrt};

const PIO2_HI: f64 = 1.57079632679489655800e+00; /* 0x3FF921FB, 0x54442D18 */
const PIO2_LO: f64 = 6.12323399573676603587e-17; /* 0x3C91A626, 0x33145C07 */
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/math/expo2.rs → src/math/musl/expo2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{combine_words, exp};
use crate::math::combine_words;
use super::exp;

/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */
#[inline]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/math/pow.rs → src/math/musl/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
// compiler will convert from decimal to binary accurately enough
// to produce the hexadecimal values shown.
//
use super::{fabs, get_high_word, scalbn, sqrt, with_set_high_word, with_set_low_word};
use crate::math::{get_high_word, with_set_high_word, with_set_low_word};
use super::{fabs, scalbn, sqrt};

const BP: [f64; 2] = [1.0, 1.5];
const DP_H: [f64; 2] = [0.0, 5.84962487220764160156e-01]; /* 0x3fe2b803_40000000 */
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.