Coverage Report

Created: 2025-10-13 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/libm-0.2.11/src/math/mod.rs
Line
Count
Source
1
macro_rules! force_eval {
2
    ($e:expr) => {
3
        unsafe { ::core::ptr::read_volatile(&$e) }
4
    };
5
}
6
7
#[cfg(not(debug_assertions))]
8
macro_rules! i {
9
    ($array:expr, $index:expr) => {
10
        unsafe { *$array.get_unchecked($index) }
11
    };
12
    ($array:expr, $index:expr, = , $rhs:expr) => {
13
        unsafe {
14
            *$array.get_unchecked_mut($index) = $rhs;
15
        }
16
    };
17
    ($array:expr, $index:expr, += , $rhs:expr) => {
18
        unsafe {
19
            *$array.get_unchecked_mut($index) += $rhs;
20
        }
21
    };
22
    ($array:expr, $index:expr, -= , $rhs:expr) => {
23
        unsafe {
24
            *$array.get_unchecked_mut($index) -= $rhs;
25
        }
26
    };
27
    ($array:expr, $index:expr, &= , $rhs:expr) => {
28
        unsafe {
29
            *$array.get_unchecked_mut($index) &= $rhs;
30
        }
31
    };
32
    ($array:expr, $index:expr, == , $rhs:expr) => {
33
        unsafe { *$array.get_unchecked_mut($index) == $rhs }
34
    };
35
}
36
37
#[cfg(debug_assertions)]
38
macro_rules! i {
39
    ($array:expr, $index:expr) => {
40
        *$array.get($index).unwrap()
41
    };
42
    ($array:expr, $index:expr, = , $rhs:expr) => {
43
        *$array.get_mut($index).unwrap() = $rhs;
44
    };
45
    ($array:expr, $index:expr, -= , $rhs:expr) => {
46
        *$array.get_mut($index).unwrap() -= $rhs;
47
    };
48
    ($array:expr, $index:expr, += , $rhs:expr) => {
49
        *$array.get_mut($index).unwrap() += $rhs;
50
    };
51
    ($array:expr, $index:expr, &= , $rhs:expr) => {
52
        *$array.get_mut($index).unwrap() &= $rhs;
53
    };
54
    ($array:expr, $index:expr, == , $rhs:expr) => {
55
        *$array.get_mut($index).unwrap() == $rhs
56
    };
57
}
58
59
// Temporary macro to avoid panic codegen for division (in debug mode too). At
60
// the time of this writing this is only used in a few places, and once
61
// rust-lang/rust#72751 is fixed then this macro will no longer be necessary and
62
// the native `/` operator can be used and panics won't be codegen'd.
63
#[cfg(any(debug_assertions, not(feature = "unstable")))]
64
macro_rules! div {
65
    ($a:expr, $b:expr) => {
66
        $a / $b
67
    };
68
}
69
70
#[cfg(all(not(debug_assertions), feature = "unstable"))]
71
macro_rules! div {
72
    ($a:expr, $b:expr) => {
73
        unsafe { core::intrinsics::unchecked_div($a, $b) }
74
    };
75
}
76
77
macro_rules! llvm_intrinsically_optimized {
78
    (#[cfg($($clause:tt)*)] $e:expr) => {
79
        #[cfg(all(feature = "unstable", not(feature = "force-soft-floats"), $($clause)*))]
80
        {
81
            if true { // thwart the dead code lint
82
                $e
83
            }
84
        }
85
    };
86
}
87
88
// Public modules
89
mod acos;
90
mod acosf;
91
mod acosh;
92
mod acoshf;
93
mod asin;
94
mod asinf;
95
mod asinh;
96
mod asinhf;
97
mod atan;
98
mod atan2;
99
mod atan2f;
100
mod atanf;
101
mod atanh;
102
mod atanhf;
103
mod cbrt;
104
mod cbrtf;
105
mod ceil;
106
mod ceilf;
107
mod copysign;
108
mod copysignf;
109
mod cos;
110
mod cosf;
111
mod cosh;
112
mod coshf;
113
mod erf;
114
mod erff;
115
mod exp;
116
mod exp10;
117
mod exp10f;
118
mod exp2;
119
mod exp2f;
120
mod expf;
121
mod expm1;
122
mod expm1f;
123
mod fabs;
124
mod fabsf;
125
mod fdim;
126
mod fdimf;
127
mod floor;
128
mod floorf;
129
mod fma;
130
mod fmaf;
131
mod fmax;
132
mod fmaxf;
133
mod fmin;
134
mod fminf;
135
mod fmod;
136
mod fmodf;
137
mod frexp;
138
mod frexpf;
139
mod hypot;
140
mod hypotf;
141
mod ilogb;
142
mod ilogbf;
143
mod j0;
144
mod j0f;
145
mod j1;
146
mod j1f;
147
mod jn;
148
mod jnf;
149
mod ldexp;
150
mod ldexpf;
151
mod lgamma;
152
mod lgamma_r;
153
mod lgammaf;
154
mod lgammaf_r;
155
mod log;
156
mod log10;
157
mod log10f;
158
mod log1p;
159
mod log1pf;
160
mod log2;
161
mod log2f;
162
mod logf;
163
mod modf;
164
mod modff;
165
mod nextafter;
166
mod nextafterf;
167
mod pow;
168
mod powf;
169
mod remainder;
170
mod remainderf;
171
mod remquo;
172
mod remquof;
173
mod rint;
174
mod rintf;
175
mod round;
176
mod roundf;
177
mod scalbn;
178
mod scalbnf;
179
mod sin;
180
mod sincos;
181
mod sincosf;
182
mod sinf;
183
mod sinh;
184
mod sinhf;
185
mod sqrt;
186
mod sqrtf;
187
mod tan;
188
mod tanf;
189
mod tanh;
190
mod tanhf;
191
mod tgamma;
192
mod tgammaf;
193
mod trunc;
194
mod truncf;
195
196
// Use separated imports instead of {}-grouped imports for easier merging.
197
pub use self::acos::acos;
198
pub use self::acosf::acosf;
199
pub use self::acosh::acosh;
200
pub use self::acoshf::acoshf;
201
pub use self::asin::asin;
202
pub use self::asinf::asinf;
203
pub use self::asinh::asinh;
204
pub use self::asinhf::asinhf;
205
pub use self::atan::atan;
206
pub use self::atan2::atan2;
207
pub use self::atan2f::atan2f;
208
pub use self::atanf::atanf;
209
pub use self::atanh::atanh;
210
pub use self::atanhf::atanhf;
211
pub use self::cbrt::cbrt;
212
pub use self::cbrtf::cbrtf;
213
pub use self::ceil::ceil;
214
pub use self::ceilf::ceilf;
215
pub use self::copysign::copysign;
216
pub use self::copysignf::copysignf;
217
pub use self::cos::cos;
218
pub use self::cosf::cosf;
219
pub use self::cosh::cosh;
220
pub use self::coshf::coshf;
221
pub use self::erf::{erf, erfc};
222
pub use self::erff::{erfcf, erff};
223
pub use self::exp::exp;
224
pub use self::exp2::exp2;
225
pub use self::exp2f::exp2f;
226
pub use self::exp10::exp10;
227
pub use self::exp10f::exp10f;
228
pub use self::expf::expf;
229
pub use self::expm1::expm1;
230
pub use self::expm1f::expm1f;
231
pub use self::fabs::fabs;
232
pub use self::fabsf::fabsf;
233
pub use self::fdim::fdim;
234
pub use self::fdimf::fdimf;
235
pub use self::floor::floor;
236
pub use self::floorf::floorf;
237
pub use self::fma::fma;
238
pub use self::fmaf::fmaf;
239
pub use self::fmax::fmax;
240
pub use self::fmaxf::fmaxf;
241
pub use self::fmin::fmin;
242
pub use self::fminf::fminf;
243
pub use self::fmod::fmod;
244
pub use self::fmodf::fmodf;
245
pub use self::frexp::frexp;
246
pub use self::frexpf::frexpf;
247
pub use self::hypot::hypot;
248
pub use self::hypotf::hypotf;
249
pub use self::ilogb::ilogb;
250
pub use self::ilogbf::ilogbf;
251
pub use self::j0::{j0, y0};
252
pub use self::j0f::{j0f, y0f};
253
pub use self::j1::{j1, y1};
254
pub use self::j1f::{j1f, y1f};
255
pub use self::jn::{jn, yn};
256
pub use self::jnf::{jnf, ynf};
257
pub use self::ldexp::ldexp;
258
pub use self::ldexpf::ldexpf;
259
pub use self::lgamma::lgamma;
260
pub use self::lgamma_r::lgamma_r;
261
pub use self::lgammaf::lgammaf;
262
pub use self::lgammaf_r::lgammaf_r;
263
pub use self::log::log;
264
pub use self::log1p::log1p;
265
pub use self::log1pf::log1pf;
266
pub use self::log2::log2;
267
pub use self::log2f::log2f;
268
pub use self::log10::log10;
269
pub use self::log10f::log10f;
270
pub use self::logf::logf;
271
pub use self::modf::modf;
272
pub use self::modff::modff;
273
pub use self::nextafter::nextafter;
274
pub use self::nextafterf::nextafterf;
275
pub use self::pow::pow;
276
pub use self::powf::powf;
277
pub use self::remainder::remainder;
278
pub use self::remainderf::remainderf;
279
pub use self::remquo::remquo;
280
pub use self::remquof::remquof;
281
pub use self::rint::rint;
282
pub use self::rintf::rintf;
283
pub use self::round::round;
284
pub use self::roundf::roundf;
285
pub use self::scalbn::scalbn;
286
pub use self::scalbnf::scalbnf;
287
pub use self::sin::sin;
288
pub use self::sincos::sincos;
289
pub use self::sincosf::sincosf;
290
pub use self::sinf::sinf;
291
pub use self::sinh::sinh;
292
pub use self::sinhf::sinhf;
293
pub use self::sqrt::sqrt;
294
pub use self::sqrtf::sqrtf;
295
pub use self::tan::tan;
296
pub use self::tanf::tanf;
297
pub use self::tanh::tanh;
298
pub use self::tanhf::tanhf;
299
pub use self::tgamma::tgamma;
300
pub use self::tgammaf::tgammaf;
301
pub use self::trunc::trunc;
302
pub use self::truncf::truncf;
303
304
// Private modules
305
mod expo2;
306
mod fenv;
307
mod k_cos;
308
mod k_cosf;
309
mod k_expo2;
310
mod k_expo2f;
311
mod k_sin;
312
mod k_sinf;
313
mod k_tan;
314
mod k_tanf;
315
mod rem_pio2;
316
mod rem_pio2_large;
317
mod rem_pio2f;
318
319
// Private re-imports
320
use self::expo2::expo2;
321
use self::k_cos::k_cos;
322
use self::k_cosf::k_cosf;
323
use self::k_expo2::k_expo2;
324
use self::k_expo2f::k_expo2f;
325
use self::k_sin::k_sin;
326
use self::k_sinf::k_sinf;
327
use self::k_tan::k_tan;
328
use self::k_tanf::k_tanf;
329
use self::rem_pio2::rem_pio2;
330
use self::rem_pio2_large::rem_pio2_large;
331
use self::rem_pio2f::rem_pio2f;
332
333
#[inline]
334
0
fn get_high_word(x: f64) -> u32 {
335
0
    (x.to_bits() >> 32) as u32
336
0
}
337
338
#[inline]
339
0
fn get_low_word(x: f64) -> u32 {
340
0
    x.to_bits() as u32
341
0
}
342
343
#[inline]
344
0
fn with_set_high_word(f: f64, hi: u32) -> f64 {
345
0
    let mut tmp = f.to_bits();
346
0
    tmp &= 0x00000000_ffffffff;
347
0
    tmp |= (hi as u64) << 32;
348
0
    f64::from_bits(tmp)
349
0
}
350
351
#[inline]
352
0
fn with_set_low_word(f: f64, lo: u32) -> f64 {
353
0
    let mut tmp = f.to_bits();
354
0
    tmp &= 0xffffffff_00000000;
355
0
    tmp |= lo as u64;
356
0
    f64::from_bits(tmp)
357
0
}
358
359
#[inline]
360
0
fn combine_words(hi: u32, lo: u32) -> f64 {
361
0
    f64::from_bits((hi as u64) << 32 | lo as u64)
362
0
}