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

Commit 651455d

Browse files
committed
Common private function needs to be no_panic
1 parent ff51032 commit 651455d

17 files changed

+34
-1
lines changed

src/math/acos.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const QS3: f64 = -6.88283971605453293030e-01; /* 0xBFE6066C, 0x1B8D0159 */
4949
const QS4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
5050

5151
#[inline]
52+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
5253
fn r(z: f64) -> f64 {
5354
let p: f64 = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z * (PS4 + z * PS5)))));
5455
let q: f64 = 1.0 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4)));

src/math/acosf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const P_S2: f32 = -8.6563630030e-03;
2323
const Q_S1: f32 = -7.0662963390e-01;
2424

2525
#[inline]
26+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2627
fn r(z: f32) -> f32 {
2728
let p = z * (P_S0 + z * (P_S1 + z * P_S2));
2829
let q = 1. + z * Q_S1;

src/math/asin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const Q_S3: f64 = -6.88283971605453293030e-01; /* 0xBFE6066C, 0x1B8D0159 */
5656
const Q_S4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
5757

5858
#[inline]
59+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
5960
fn comp_r(z: f64) -> f64 {
6061
let p = z * (P_S0 + z * (P_S1 + z * (P_S2 + z * (P_S3 + z * (P_S4 + z * P_S5)))));
6162
let q = 1.0 + z * (Q_S1 + z * (Q_S2 + z * (Q_S3 + z * Q_S4)));

src/math/asinf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const P_S2: f32 = -8.6563630030e-03;
2525
const Q_S1: f32 = -7.0662963390e-01;
2626

2727
#[inline]
28+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2829
fn r(z: f32) -> f32 {
2930
let p = z * (P_S0 + z * (P_S1 + z * P_S2));
3031
let q = 1. + z * Q_S1;

src/math/erf.rs

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ const SB5: f64 = 2.55305040643316442583e+03; /* 0x40A3F219, 0xCEDF3BE6 */
172172
const SB6: f64 = 4.74528541206955367215e+02; /* 0x407DA874, 0xE79FE763 */
173173
const SB7: f64 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
174174

175+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
175176
fn erfc1(x: f64) -> f64 {
176177
let s: f64;
177178
let p: f64;
@@ -184,6 +185,7 @@ fn erfc1(x: f64) -> f64 {
184185
1.0 - ERX - p / q
185186
}
186187

188+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
187189
fn erfc2(ix: u32, mut x: f64) -> f64 {
188190
let s: f64;
189191
let r: f64;

src/math/erff.rs

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const SB5: f32 = 2.5530502930e+03; /* 0x451f90ce */
8383
const SB6: f32 = 4.7452853394e+02; /* 0x43ed43a7 */
8484
const SB7: f32 = -2.2440952301e+01; /* 0xc1b38712 */
8585

86+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
8687
fn erfc1(x: f32) -> f32 {
8788
let s: f32;
8889
let p: f32;
@@ -94,6 +95,7 @@ fn erfc1(x: f32) -> f32 {
9495
return 1.0 - ERX - p / q;
9596
}
9697

98+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
9799
fn erfc2(mut ix: u32, mut x: f32) -> f32 {
98100
let s: f32;
99101
let r: f32;

src/math/fma.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct Num {
1111
}
1212

1313
#[inline]
14+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
1415
fn normalize(x: f64) -> Num {
1516
let x1p63: f64 = f64::from_bits(0x43e0000000000000); // 0x1p63 === 2 ^ 63
1617

@@ -31,6 +32,7 @@ fn normalize(x: f64) -> Num {
3132
}
3233

3334
#[inline]
35+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
3436
fn mul(x: u64, y: u64) -> (u64, u64) {
3537
let t1: u64;
3638
let t2: u64;

src/math/hypot.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::sqrt;
55
const SPLIT: f64 = 134217728. + 1.; // 0x1p27 + 1 === (2 ^ 27) + 1
66

77
#[inline]
8+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
89
fn sq(x: f64) -> (f64, f64) {
910
let xh: f64;
1011
let xl: f64;

src/math/j0.rs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */
5959
const TPI: f64 = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */
6060

6161
/* common method when |x|>=2 */
62+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
6263
fn common(ix: u32, x: f64, y0: bool) -> f64 {
6364
let s: f64;
6465
let mut c: f64;

src/math/j0f.rs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use super::{cosf, fabsf, logf, sinf, sqrtf};
1818
const INVSQRTPI: f32 = 5.6418961287e-01; /* 0x3f106ebb */
1919
const TPI: f32 = 6.3661974669e-01; /* 0x3f22f983 */
2020

21+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2122
fn common(ix: u32, x: f32, y0: bool) -> f32 {
2223
let z: f32;
2324
let s: f32;
@@ -219,6 +220,7 @@ const PS2: [f32; 5] = [
219220
1.4657617569e+01, /* 0x416a859a */
220221
];
221222

223+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
222224
fn pzerof(x: f32) -> f32 {
223225
let p: &[f32; 6];
224226
let q: &[f32; 5];
@@ -331,6 +333,7 @@ const QS2: [f32; 6] = [
331333
-5.3109550476e+00, /* 0xc0a9f358 */
332334
];
333335

336+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
334337
fn qzerof(x: f32) -> f32 {
335338
let p: &[f32; 6];
336339
let q: &[f32; 6];

src/math/j1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use super::{cos, fabs, get_high_word, get_low_word, log, sin, sqrt};
5959
const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */
6060
const TPI: f64 = 6.36619772367581382433e-01; /* 0x3FE45F30, 0x6DC9C883 */
6161

62+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
6263
fn common(ix: u32, x: f64, y1: bool, sign: bool) -> f64 {
6364
let z: f64;
6465
let mut s: f64;

src/math/j1f.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
/* origin: FreeBSD /usr/src/lib/msun/src/e_j1f.c */
23
/*
34
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
@@ -18,6 +19,8 @@ use super::{cosf, fabsf, logf, sinf, sqrtf};
1819
const INVSQRTPI: f32 = 5.6418961287e-01; /* 0x3f106ebb */
1920
const TPI: f32 = 6.3661974669e-01; /* 0x3f22f983 */
2021

22+
#[inline]
23+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2124
fn common(ix: u32, x: f32, y1: bool, sign: bool) -> f32 {
2225
let z: f64;
2326
let mut s: f64;
@@ -72,7 +75,7 @@ pub fn j1f(x: f32) -> f32 {
7275
let mut ix: u32;
7376
let sign: bool;
7477

75-
ix = x.to_bits();
78+
/*ix = x.to_bits();
7679
sign = (ix >> 31) != 0;
7780
ix &= 0x7fffffff;
7881
if ix >= 0x7f800000 {
@@ -92,6 +95,8 @@ pub fn j1f(x: f32) -> f32 {
9295
z = 0.5;
9396
}
9497
return z * x;
98+
*/
99+
x
95100
}
96101

97102
const U0: [f32; 5] = [
@@ -218,6 +223,7 @@ const PS2: [f32; 5] = [
218223
8.3646392822e+00, /* 0x4105d590 */
219224
];
220225

226+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
221227
fn ponef(x: f32) -> f32 {
222228
let p: &[f32; 6];
223229
let q: &[f32; 5];
@@ -330,6 +336,7 @@ const QS2: [f32; 6] = [
330336
-4.9594988823e+00, /* 0xc09eb437 */
331337
];
332338

339+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
333340
fn qonef(x: f32) -> f32 {
334341
let p: &[f32; 6];
335342
let q: &[f32; 6];

src/math/k_tan.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub(crate) fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 {
102102
}
103103

104104
#[inline]
105+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
105106
fn zero_low_word(x: f64) -> f64 {
106107
f64::from_bits(f64::to_bits(x) & 0xFFFF_FFFF_0000_0000)
107108
}

src/math/lgamma_r.rs

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const W5: f64 = 8.36339918996282139126e-04; /* 0x3F4B67BA, 0x4CDAD5D1 */
145145
const W6: f64 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
146146

147147
/* sin(PI*x) assuming x > 2^-100, if sin(PI*x)==0 the sign is arbitrary */
148+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
148149
fn sin_pi(mut x: f64) -> f64 {
149150
let mut n: i32;
150151

src/math/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,19 @@ use self::rem_pio2_large::rem_pio2_large;
315315
use self::rem_pio2f::rem_pio2f;
316316

317317
#[inline]
318+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
318319
fn get_high_word(x: f64) -> u32 {
319320
(x.to_bits() >> 32) as u32
320321
}
321322

322323
#[inline]
324+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
323325
fn get_low_word(x: f64) -> u32 {
324326
x.to_bits() as u32
325327
}
326328

327329
#[inline]
330+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
328331
fn with_set_high_word(f: f64, hi: u32) -> f64 {
329332
let mut tmp = f.to_bits();
330333
tmp &= 0x00000000_ffffffff;
@@ -333,6 +336,7 @@ fn with_set_high_word(f: f64, hi: u32) -> f64 {
333336
}
334337

335338
#[inline]
339+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
336340
fn with_set_low_word(f: f64, lo: u32) -> f64 {
337341
let mut tmp = f.to_bits();
338342
tmp &= 0xffffffff_00000000;
@@ -341,6 +345,7 @@ fn with_set_low_word(f: f64, lo: u32) -> f64 {
341345
}
342346

343347
#[inline]
348+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
344349
fn combine_words(hi: u32, lo: u32) -> f64 {
345350
f64::from_bits((hi as u64) << 32 | lo as u64)
346351
}

src/math/rem_pio2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub(crate) fn rem_pio2(x: f64) -> (i32, f64, f64) {
5050
let ix = (f64::to_bits(x) >> 32) as u32 & 0x7fffffff;
5151

5252
#[inline]
53+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
5354
fn medium(x: f64, ix: u32) -> (i32, f64, f64) {
5455
/* rint(x/(pi/2)), Assume round-to-nearest. */
5556
let f_n = x as f64 * INV_PIO2 + TO_INT - TO_INT;

src/math/tgamma.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use super::{exp, floor, k_cos, k_sin, pow};
2828
const PI: f64 = 3.141592653589793238462643383279502884;
2929

3030
/* sin(pi x) with x > 0x1p-100, if sin(pi*x)==0 the sign is arbitrary */
31+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
3132
fn sinpi(mut x: f64) -> f64 {
3233
let mut n: isize;
3334

@@ -111,6 +112,7 @@ const FACT: [f64; 23] = [
111112
];
112113

113114
/* S(x) rational function for positive x */
115+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
114116
fn s(x: f64) -> f64 {
115117
let mut num: f64 = 0.0;
116118
let mut den: f64 = 0.0;

0 commit comments

Comments
 (0)