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