From 8755986beb5d7782e5701c98b401dd31777fd40c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 9 May 2019 07:27:10 -0700 Subject: [PATCH] Move non-public functions to `pub(crate)` Remove exceptions from the test list after doing so --- build.rs | 13 ------------- src/math/expo2.rs | 2 +- src/math/k_cos.rs | 2 +- src/math/k_cosf.rs | 2 +- src/math/k_expo2f.rs | 2 +- src/math/k_sin.rs | 2 +- src/math/k_sinf.rs | 2 +- src/math/k_tan.rs | 2 +- src/math/k_tanf.rs | 2 +- src/math/rem_pio2.rs | 2 +- src/math/rem_pio2_large.rs | 4 ++-- src/math/rem_pio2f.rs | 2 +- 12 files changed, 12 insertions(+), 25 deletions(-) diff --git a/build.rs b/build.rs index 642e929..896b413 100644 --- a/build.rs +++ b/build.rs @@ -27,20 +27,7 @@ mod musl_reference_tests { // These files are all internal functions or otherwise miscellaneous, not // defining a function we want to test. const IGNORED_FILES: &[&str] = &[ - "expo2.rs", // kernel, private "fenv.rs", - "k_cos.rs", // kernel, private - "k_cosf.rs", // kernel, private - "k_expo2.rs", // kernel, private - "k_expo2f.rs", // kernel, private - "k_sin.rs", // kernel, private - "k_sinf.rs", // kernel, private - "k_tan.rs", // kernel, private - "k_tanf.rs", // kernel, private - "mod.rs", - "rem_pio2.rs", // kernel, private - "rem_pio2_large.rs", // kernel, private - "rem_pio2f.rs", // kernel, private "sincos.rs", // more than 1 result "sincosf.rs", // more than 1 result "jn.rs", // passed, but very slow diff --git a/src/math/expo2.rs b/src/math/expo2.rs index 9e60ca9..ae6cc81 100644 --- a/src/math/expo2.rs +++ b/src/math/expo2.rs @@ -3,7 +3,7 @@ use super::{combine_words, exp}; /* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn expo2(x: f64) -> f64 { +pub(crate) fn expo2(x: f64) -> f64 { /* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */ const K: i32 = 2043; let kln2 = f64::from_bits(0x40962066151add8b); diff --git a/src/math/k_cos.rs b/src/math/k_cos.rs index 8876fac..4687b36 100644 --- a/src/math/k_cos.rs +++ b/src/math/k_cos.rs @@ -53,7 +53,7 @@ const C6: f64 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ // any extra precision in w. #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_cos(x: f64, y: f64) -> f64 { +pub(crate) fn k_cos(x: f64, y: f64) -> f64 { let z = x * x; let w = z * z; let r = z * (C1 + z * (C2 + z * C3)) + w * w * (C4 + z * (C5 + z * C6)); diff --git a/src/math/k_cosf.rs b/src/math/k_cosf.rs index 9b48e19..79d0f23 100644 --- a/src/math/k_cosf.rs +++ b/src/math/k_cosf.rs @@ -22,7 +22,7 @@ const C3: f64 = 0.0000243904487962774090654; /* 0x199342e0ee5069.0p-68 */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_cosf(x: f64) -> f32 { +pub(crate) fn k_cosf(x: f64) -> f32 { let z = x * x; let w = z * z; let r = C2 + z * C3; diff --git a/src/math/k_expo2f.rs b/src/math/k_expo2f.rs index 68a7a50..de85077 100644 --- a/src/math/k_expo2f.rs +++ b/src/math/k_expo2f.rs @@ -6,7 +6,7 @@ const K: i32 = 235; /* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_expo2f(x: f32) -> f32 { +pub(crate) fn k_expo2f(x: f32) -> f32 { let k_ln2 = f32::from_bits(0x4322e3bc); /* note that k is odd and scale*scale overflows */ let scale = f32::from_bits(((0x7f + K / 2) as u32) << 23); diff --git a/src/math/k_sin.rs b/src/math/k_sin.rs index 15718c4..5d2bd68 100644 --- a/src/math/k_sin.rs +++ b/src/math/k_sin.rs @@ -45,7 +45,7 @@ const S6: f64 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ // sin(x) = x + (S1*x + (x *(r-y/2)+y)) #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_sin(x: f64, y: f64, iy: i32) -> f64 { +pub(crate) fn k_sin(x: f64, y: f64, iy: i32) -> f64 { let z = x * x; let w = z * z; let r = S2 + z * (S3 + z * S4) + z * w * (S5 + z * S6); diff --git a/src/math/k_sinf.rs b/src/math/k_sinf.rs index 157fc10..68fe926 100644 --- a/src/math/k_sinf.rs +++ b/src/math/k_sinf.rs @@ -22,7 +22,7 @@ const S4: f64 = 0.0000027183114939898219064; /* 0x16cd878c3b46a7.0p-71 */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_sinf(x: f64) -> f32 { +pub(crate) fn k_sinf(x: f64) -> f32 { let z = x * x; let w = z * z; let r = S3 + z * S4; diff --git a/src/math/k_tan.rs b/src/math/k_tan.rs index 684e937..ea3c386 100644 --- a/src/math/k_tan.rs +++ b/src/math/k_tan.rs @@ -60,7 +60,7 @@ const PIO4_LO: f64 = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 { +pub(crate) fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 { let hx = (f64::to_bits(x) >> 32) as u32; let big = (hx & 0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */ if big { diff --git a/src/math/k_tanf.rs b/src/math/k_tanf.rs index 96a5910..5265137 100644 --- a/src/math/k_tanf.rs +++ b/src/math/k_tanf.rs @@ -21,7 +21,7 @@ const T: [f64; 6] = [ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn k_tanf(x: f64, odd: bool) -> f32 { +pub(crate) fn k_tanf(x: f64, odd: bool) -> f32 { let z = x * x; /* * Split up the polynomial into small independent terms to give diff --git a/src/math/rem_pio2.rs b/src/math/rem_pio2.rs index 951dd08..285663e 100644 --- a/src/math/rem_pio2.rs +++ b/src/math/rem_pio2.rs @@ -43,7 +43,7 @@ const PIO2_3T: f64 = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ // caller must handle the case when reduction is not needed: |x| ~<= pi/4 */ #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn rem_pio2(x: f64) -> (i32, f64, f64) { +pub(crate) fn rem_pio2(x: f64) -> (i32, f64, f64) { let x1p24 = f64::from_bits(0x4170000000000000); let sign = (f64::to_bits(x) >> 63) as i32; diff --git a/src/math/rem_pio2_large.rs b/src/math/rem_pio2_large.rs index 8bab485..006d3e1 100644 --- a/src/math/rem_pio2_large.rs +++ b/src/math/rem_pio2_large.rs @@ -224,11 +224,11 @@ const PIO2: [f64; 8] = [ /// independent of the exponent of the input. #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 { +pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 { let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24 let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24) - #[cfg(target_pointer_width = "64")] + #[cfg(all(target_pointer_width = "64", feature = "checked"))] assert!(e0 <= 16360); let nx = x.len(); diff --git a/src/math/rem_pio2f.rs b/src/math/rem_pio2f.rs index 054c311..af2745d 100644 --- a/src/math/rem_pio2f.rs +++ b/src/math/rem_pio2f.rs @@ -33,7 +33,7 @@ const PIO2_1T: f64 = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */ /// use __rem_pio2_large() for large x #[inline] #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] -pub fn rem_pio2f(x: f32) -> (i32, f64) { +pub(crate) fn rem_pio2f(x: f32) -> (i32, f64) { let x64 = x as f64; let mut tx: [f64; 1] = [0.];