]>
Commit | Line | Data |
---|---|---|
8faf50e0 XL |
1 | #[allow(dead_code)] |
2 | #[path = "../libm/src/math/mod.rs"] | |
3 | mod libm; | |
4 | ||
5 | macro_rules! no_mangle { | |
6 | ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { | |
7 | intrinsics! { | |
8 | $( | |
9 | pub extern "C" fn $fun($($iid: $ity),+) -> $oty { | |
10 | self::libm::$fun($($iid),+) | |
11 | } | |
12 | )+ | |
13 | } | |
14 | } | |
15 | } | |
16 | ||
532ac7d7 XL |
17 | #[cfg(any( |
18 | all( | |
3c0e092e | 19 | target_family = "wasm", |
532ac7d7 XL |
20 | target_os = "unknown", |
21 | not(target_env = "wasi") | |
22 | ), | |
f2b60f7d | 23 | target_os = "xous", |
3c0e092e XL |
24 | all(target_arch = "x86_64", target_os = "uefi"), |
25 | all(target_arch = "xtensa", target_os = "none"), | |
532ac7d7 XL |
26 | all(target_vendor = "fortanix", target_env = "sgx") |
27 | ))] | |
8faf50e0 XL |
28 | no_mangle! { |
29 | fn acos(x: f64) -> f64; | |
30 | fn asin(x: f64) -> f64; | |
8faf50e0 | 31 | fn cbrt(x: f64) -> f64; |
8faf50e0 XL |
32 | fn expm1(x: f64) -> f64; |
33 | fn hypot(x: f64, y: f64) -> f64; | |
8faf50e0 | 34 | fn tan(x: f64) -> f64; |
8faf50e0 | 35 | fn cos(x: f64) -> f64; |
8faf50e0 XL |
36 | fn expf(x: f32) -> f32; |
37 | fn log2(x: f64) -> f64; | |
38 | fn log2f(x: f32) -> f32; | |
39 | fn log10(x: f64) -> f64; | |
40 | fn log10f(x: f32) -> f32; | |
41 | fn log(x: f64) -> f64; | |
42 | fn logf(x: f32) -> f32; | |
dc9dc135 XL |
43 | fn fmin(x: f64, y: f64) -> f64; |
44 | fn fminf(x: f32, y: f32) -> f32; | |
45 | fn fmax(x: f64, y: f64) -> f64; | |
46 | fn fmaxf(x: f32, y: f32) -> f32; | |
8faf50e0 XL |
47 | fn round(x: f64) -> f64; |
48 | fn roundf(x: f32) -> f32; | |
487cf647 FG |
49 | fn rint(x: f64) -> f64; |
50 | fn rintf(x: f32) -> f32; | |
8faf50e0 | 51 | fn sin(x: f64) -> f64; |
8faf50e0 XL |
52 | fn pow(x: f64, y: f64) -> f64; |
53 | fn powf(x: f32, y: f32) -> f32; | |
8faf50e0 XL |
54 | fn fmod(x: f64, y: f64) -> f64; |
55 | fn fmodf(x: f32, y: f32) -> f32; | |
0731742a | 56 | fn acosf(n: f32) -> f32; |
0731742a XL |
57 | fn atan2f(a: f32, b: f32) -> f32; |
58 | fn atanf(n: f32) -> f32; | |
0731742a XL |
59 | fn coshf(n: f32) -> f32; |
60 | fn expm1f(n: f32) -> f32; | |
48663c56 | 61 | fn fdim(a: f64, b: f64) -> f64; |
0731742a | 62 | fn fdimf(a: f32, b: f32) -> f32; |
0731742a XL |
63 | fn log1pf(n: f32) -> f32; |
64 | fn sinhf(n: f32) -> f32; | |
0731742a | 65 | fn tanhf(n: f32) -> f32; |
48663c56 XL |
66 | fn ldexp(f: f64, n: i32) -> f64; |
67 | fn ldexpf(f: f32, n: i32) -> f32; | |
f2b60f7d FG |
68 | fn tgamma(x: f64) -> f64; |
69 | fn tgammaf(x: f32) -> f32; | |
3c0e092e XL |
70 | fn atan(x: f64) -> f64; |
71 | fn atan2(x: f64, y: f64) -> f64; | |
72 | fn cosh(x: f64) -> f64; | |
73 | fn log1p(x: f64) -> f64; | |
74 | fn sinh(x: f64) -> f64; | |
75 | fn tanh(x: f64) -> f64; | |
76 | fn cosf(x: f32) -> f32; | |
77 | fn exp(x: f64) -> f64; | |
78 | fn sinf(x: f32) -> f32; | |
79 | fn exp2(x: f64) -> f64; | |
80 | fn exp2f(x: f32) -> f32; | |
81 | fn fma(x: f64, y: f64, z: f64) -> f64; | |
82 | fn fmaf(x: f32, y: f32, z: f32) -> f32; | |
83 | fn asinf(n: f32) -> f32; | |
84 | fn cbrtf(n: f32) -> f32; | |
85 | fn hypotf(x: f32, y: f32) -> f32; | |
86 | fn tanf(n: f32) -> f32; | |
87 | } | |
88 | ||
353b0b11 FG |
89 | #[cfg(any( |
90 | all( | |
91 | target_family = "wasm", | |
92 | target_os = "unknown", | |
93 | not(target_env = "wasi") | |
94 | ), | |
95 | target_os = "xous", | |
96 | all(target_arch = "x86_64", target_os = "uefi"), | |
97 | all(target_arch = "xtensa", target_os = "none"), | |
98 | all(target_vendor = "fortanix", target_env = "sgx") | |
99 | ))] | |
100 | intrinsics! { | |
101 | pub extern "C" fn lgamma_r(x: f64, s: &mut i32) -> f64 { | |
102 | let r = self::libm::lgamma_r(x); | |
103 | *s = r.1; | |
104 | r.0 | |
105 | } | |
106 | ||
107 | pub extern "C" fn lgammaf_r(x: f32, s: &mut i32) -> f32 { | |
108 | let r = self::libm::lgammaf_r(x); | |
109 | *s = r.1; | |
110 | r.0 | |
111 | } | |
112 | } | |
113 | ||
114 | #[cfg(any( | |
115 | target_os = "xous", | |
116 | target_os = "uefi", | |
117 | all(target_arch = "xtensa", target_os = "none"), | |
118 | ))] | |
f2b60f7d FG |
119 | no_mangle! { |
120 | fn sqrtf(x: f32) -> f32; | |
121 | fn sqrt(x: f64) -> f64; | |
122 | } | |
123 | ||
124 | #[cfg(any( | |
125 | all(target_vendor = "fortanix", target_env = "sgx"), | |
353b0b11 | 126 | all(target_arch = "xtensa", target_os = "none"), |
f2b60f7d FG |
127 | target_os = "xous", |
128 | target_os = "uefi" | |
129 | ))] | |
0731742a XL |
130 | no_mangle! { |
131 | fn ceil(x: f64) -> f64; | |
132 | fn ceilf(x: f32) -> f32; | |
133 | fn floor(x: f64) -> f64; | |
134 | fn floorf(x: f32) -> f32; | |
135 | fn trunc(x: f64) -> f64; | |
136 | fn truncf(x: f32) -> f32; | |
8faf50e0 XL |
137 | } |
138 | ||
9c376795 | 139 | // only for the thumb*-none-eabi*, riscv32*-none-elf and x86_64-unknown-none targets that lack the floating point instruction set |
2b03887a FG |
140 | #[cfg(any( |
141 | all(target_arch = "arm", target_os = "none"), | |
9c376795 FG |
142 | all(target_arch = "riscv32", not(target_feature = "f"), target_os = "none"), |
143 | all(target_arch = "x86_64", target_os = "none") | |
2b03887a | 144 | ))] |
8faf50e0 | 145 | no_mangle! { |
5869c6ff XL |
146 | fn fmin(x: f64, y: f64) -> f64; |
147 | fn fminf(x: f32, y: f32) -> f32; | |
148 | fn fmax(x: f64, y: f64) -> f64; | |
149 | fn fmaxf(x: f32, y: f32) -> f32; | |
8faf50e0 XL |
150 | // `f64 % f64` |
151 | fn fmod(x: f64, y: f64) -> f64; | |
152 | // `f32 % f32` | |
153 | fn fmodf(x: f32, y: f32) -> f32; | |
154 | } |