1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use std::{f32, f64};
pub extern "C" fn ceilf32(x: f32) -> f32 {
x.ceil()
}
pub extern "C" fn floorf32(x: f32) -> f32 {
x.floor()
}
pub extern "C" fn truncf32(x: f32) -> f32 {
x.trunc()
}
pub extern "C" fn nearbyintf32(x: f32) -> f32 {
#[inline]
fn copysign(x: f32, y: f32) -> f32 {
let bitmask = y.to_bits() & (1 << 31);
f32::from_bits(x.to_bits() | bitmask)
}
if x.is_nan() {
f32::from_bits(x.to_bits() | (1 << 22))
} else {
let k = f32::EPSILON.recip();
let a = x.abs();
if a < k {
copysign((a + k) - k, x)
} else {
x
}
}
}
pub extern "C" fn ceilf64(x: f64) -> f64 {
x.ceil()
}
pub extern "C" fn floorf64(x: f64) -> f64 {
x.floor()
}
pub extern "C" fn truncf64(x: f64) -> f64 {
x.trunc()
}
pub extern "C" fn nearbyintf64(x: f64) -> f64 {
#[inline]
fn copysign(x: f64, y: f64) -> f64 {
let bitmask = y.to_bits() & (1 << 63);
f64::from_bits(x.to_bits() | bitmask)
}
if x.is_nan() {
f64::from_bits(x.to_bits() | (1 << 51))
} else {
let k = f64::EPSILON.recip();
let a = x.abs();
if a < k {
copysign((a + k) - k, x)
} else {
x
}
}
}
#[cfg(all(
any(target_os = "freebsd", target_os = "linux"),
target_arch = "aarch64"
))]
#[no_mangle]
pub extern "C" fn __rust_probestack() {}