1macro_rules! force_eval {
2 ($e:expr) => {
3 unsafe { ::core::ptr::read_volatile(&$e) }
4 };
5}
6
7#[cfg(not(debug_assertions))]
8macro_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)]
38macro_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")))]
64macro_rules! div {
65 ($a:expr, $b:expr) => {
66 $a / $b
67 };
68}
69
70#[cfg(all(not(debug_assertions), feature = "unstable"))]
71macro_rules! div {
72 ($a:expr, $b:expr) => {
73 unsafe { core::intrinsics::unchecked_div($a, $b) }
74 };
75}
76
77macro_rules! llvm_intrinsically_optimized {
78 (#[cfg($($clause:tt)*)] $e:expr) => {
79 #[cfg(all(feature = "unstable", $($clause)*))]
80 {
81 if true { // thwart the dead code lint
82 $e
83 }
84 }
85 };
86}
87
88// Public modules
89mod acos;
90mod acosf;
91mod acosh;
92mod acoshf;
93mod asin;
94mod asinf;
95mod asinh;
96mod asinhf;
97mod atan;
98mod atan2;
99mod atan2f;
100mod atanf;
101mod atanh;
102mod atanhf;
103mod cbrt;
104mod cbrtf;
105mod ceil;
106mod ceilf;
107mod copysign;
108mod copysignf;
109mod cos;
110mod cosf;
111mod cosh;
112mod coshf;
113mod erf;
114mod erff;
115mod exp;
116mod exp10;
117mod exp10f;
118mod exp2;
119mod exp2f;
120mod expf;
121mod expm1;
122mod expm1f;
123mod fabs;
124mod fabsf;
125mod fdim;
126mod fdimf;
127mod floor;
128mod floorf;
129mod fma;
130mod fmaf;
131mod fmax;
132mod fmaxf;
133mod fmin;
134mod fminf;
135mod fmod;
136mod fmodf;
137mod frexp;
138mod frexpf;
139mod hypot;
140mod hypotf;
141mod ilogb;
142mod ilogbf;
143mod j0;
144mod j0f;
145mod j1;
146mod j1f;
147mod jn;
148mod jnf;
149mod ldexp;
150mod ldexpf;
151mod lgamma;
152mod lgamma_r;
153mod lgammaf;
154mod lgammaf_r;
155mod log;
156mod log10;
157mod log10f;
158mod log1p;
159mod log1pf;
160mod log2;
161mod log2f;
162mod logf;
163mod modf;
164mod modff;
165mod nextafter;
166mod nextafterf;
167mod pow;
168mod powf;
169mod remainder;
170mod remainderf;
171mod remquo;
172mod remquof;
173mod rint;
174mod rintf;
175mod round;
176mod roundf;
177mod scalbn;
178mod scalbnf;
179mod sin;
180mod sincos;
181mod sincosf;
182mod sinf;
183mod sinh;
184mod sinhf;
185mod sqrt;
186mod sqrtf;
187mod tan;
188mod tanf;
189mod tanh;
190mod tanhf;
191mod tgamma;
192mod tgammaf;
193mod trunc;
194mod truncf;
195
196// Use separated imports instead of {}-grouped imports for easier merging.
197pub use self::acos::acos;
198pub use self::acosf::acosf;
199pub use self::acosh::acosh;
200pub use self::acoshf::acoshf;
201pub use self::asin::asin;
202pub use self::asinf::asinf;
203pub use self::asinh::asinh;
204pub use self::asinhf::asinhf;
205pub use self::atan::atan;
206pub use self::atan2::atan2;
207pub use self::atan2f::atan2f;
208pub use self::atanf::atanf;
209pub use self::atanh::atanh;
210pub use self::atanhf::atanhf;
211pub use self::cbrt::cbrt;
212pub use self::cbrtf::cbrtf;
213pub use self::ceil::ceil;
214pub use self::ceilf::ceilf;
215pub use self::copysign::copysign;
216pub use self::copysignf::copysignf;
217pub use self::cos::cos;
218pub use self::cosf::cosf;
219pub use self::cosh::cosh;
220pub use self::coshf::coshf;
221pub use self::erf::erf;
222pub use self::erf::erfc;
223pub use self::erff::erfcf;
224pub use self::erff::erff;
225pub use self::exp::exp;
226pub use self::exp10::exp10;
227pub use self::exp10f::exp10f;
228pub use self::exp2::exp2;
229pub use self::exp2f::exp2f;
230pub use self::expf::expf;
231pub use self::expm1::expm1;
232pub use self::expm1f::expm1f;
233pub use self::fabs::fabs;
234pub use self::fabsf::fabsf;
235pub use self::fdim::fdim;
236pub use self::fdimf::fdimf;
237pub use self::floor::floor;
238pub use self::floorf::floorf;
239pub use self::fma::fma;
240pub use self::fmaf::fmaf;
241pub use self::fmax::fmax;
242pub use self::fmaxf::fmaxf;
243pub use self::fmin::fmin;
244pub use self::fminf::fminf;
245pub use self::fmod::fmod;
246pub use self::fmodf::fmodf;
247pub use self::frexp::frexp;
248pub use self::frexpf::frexpf;
249pub use self::hypot::hypot;
250pub use self::hypotf::hypotf;
251pub use self::ilogb::ilogb;
252pub use self::ilogbf::ilogbf;
253pub use self::j0::j0;
254pub use self::j0::y0;
255pub use self::j0f::j0f;
256pub use self::j0f::y0f;
257pub use self::j1::j1;
258pub use self::j1::y1;
259pub use self::j1f::j1f;
260pub use self::j1f::y1f;
261pub use self::jn::jn;
262pub use self::jn::yn;
263pub use self::jnf::jnf;
264pub use self::jnf::ynf;
265pub use self::ldexp::ldexp;
266pub use self::ldexpf::ldexpf;
267pub use self::lgamma::lgamma;
268pub use self::lgamma_r::lgamma_r;
269pub use self::lgammaf::lgammaf;
270pub use self::lgammaf_r::lgammaf_r;
271pub use self::log::log;
272pub use self::log10::log10;
273pub use self::log10f::log10f;
274pub use self::log1p::log1p;
275pub use self::log1pf::log1pf;
276pub use self::log2::log2;
277pub use self::log2f::log2f;
278pub use self::logf::logf;
279pub use self::modf::modf;
280pub use self::modff::modff;
281pub use self::nextafter::nextafter;
282pub use self::nextafterf::nextafterf;
283pub use self::pow::pow;
284pub use self::powf::powf;
285pub use self::remainder::remainder;
286pub use self::remainderf::remainderf;
287pub use self::remquo::remquo;
288pub use self::remquof::remquof;
289pub use self::rint::rint;
290pub use self::rintf::rintf;
291pub use self::round::round;
292pub use self::roundf::roundf;
293pub use self::scalbn::scalbn;
294pub use self::scalbnf::scalbnf;
295pub use self::sin::sin;
296pub use self::sincos::sincos;
297pub use self::sincosf::sincosf;
298pub use self::sinf::sinf;
299pub use self::sinh::sinh;
300pub use self::sinhf::sinhf;
301pub use self::sqrt::sqrt;
302pub use self::sqrtf::sqrtf;
303pub use self::tan::tan;
304pub use self::tanf::tanf;
305pub use self::tanh::tanh;
306pub use self::tanhf::tanhf;
307pub use self::tgamma::tgamma;
308pub use self::tgammaf::tgammaf;
309pub use self::trunc::trunc;
310pub use self::truncf::truncf;
311
312// Private modules
313mod expo2;
314mod fenv;
315mod k_cos;
316mod k_cosf;
317mod k_expo2;
318mod k_expo2f;
319mod k_sin;
320mod k_sinf;
321mod k_tan;
322mod k_tanf;
323mod rem_pio2;
324mod rem_pio2_large;
325mod rem_pio2f;
326
327// Private re-imports
328use self::expo2::expo2;
329use self::k_cos::k_cos;
330use self::k_cosf::k_cosf;
331use self::k_expo2::k_expo2;
332use self::k_expo2f::k_expo2f;
333use self::k_sin::k_sin;
334use self::k_sinf::k_sinf;
335use self::k_tan::k_tan;
336use self::k_tanf::k_tanf;
337use self::rem_pio2::rem_pio2;
338use self::rem_pio2_large::rem_pio2_large;
339use self::rem_pio2f::rem_pio2f;
340
341#[inline]
342fn get_high_word(x: f64) -> u32 {
343 (x.to_bits() >> 32) as u32
344}
345
346#[inline]
347fn get_low_word(x: f64) -> u32 {
348 x.to_bits() as u32
349}
350
351#[inline]
352fn with_set_high_word(f: f64, hi: u32) -> f64 {
353 let mut tmp: u64 = f.to_bits();
354 tmp &= 0x00000000_ffffffff;
355 tmp |= (hi as u64) << 32;
356 f64::from_bits(tmp)
357}
358
359#[inline]
360fn with_set_low_word(f: f64, lo: u32) -> f64 {
361 let mut tmp: u64 = f.to_bits();
362 tmp &= 0xffffffff_00000000;
363 tmp |= lo as u64;
364 f64::from_bits(tmp)
365}
366
367#[inline]
368fn combine_words(hi: u32, lo: u32) -> f64 {
369 f64::from_bits((hi as u64) << 32 | lo as u64)
370}
371