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