|
10 | 10 | #![allow(internal_features)]
|
11 | 11 | #![no_std]
|
12 | 12 |
|
13 |
| -#[allow(dead_code)] |
14 |
| -#[allow(clippy::all)] // We don't get `libm`'s list of `allow`s, so just ignore Clippy. |
15 |
| -#[path = "../../../src/math/mod.rs"] |
16 |
| -pub mod libm; |
17 |
| - |
18 |
| -use core::ffi::c_int; |
19 |
| - |
| 13 | +mod math; |
20 | 14 | // Required for macro paths.
|
21 |
| -use libm::support; |
22 |
| - |
23 |
| -/// Mark functions `#[no_mangle]` and with the C ABI. |
24 |
| -macro_rules! no_mangle { |
25 |
| - ($( $name:ident( $($tt:tt)+ ) -> $ret:ty; )+) => { |
26 |
| - $( no_mangle!(@inner $name( $($tt)+ ) -> $ret); )+ |
27 |
| - }; |
28 |
| - |
29 |
| - // Handle simple functions with single return types |
30 |
| - (@inner $name:ident( $($arg:ident: $aty:ty),+ ) -> $ret:ty) => { |
31 |
| - #[no_mangle] |
32 |
| - extern "C" fn $name($($arg: $aty),+) -> $ret { |
33 |
| - libm::$name($($arg),+) |
34 |
| - } |
35 |
| - }; |
36 |
| - |
37 |
| - |
38 |
| - // Functions with `&mut` return values need to be handled differently, use `|` to |
39 |
| - // separate inputs vs. outputs. |
40 |
| - ( |
41 |
| - @inner $name:ident( $($arg:ident: $aty:ty),+ | $($rarg:ident: $rty:ty),+) -> $ret:ty |
42 |
| - ) => { |
43 |
| - #[no_mangle] |
44 |
| - extern "C" fn $name($($arg: $aty,)+ $($rarg: $rty),+) -> $ret { |
45 |
| - let ret; |
46 |
| - (ret, $(*$rarg),+) = libm::$name($($arg),+); |
47 |
| - ret |
48 |
| - } |
49 |
| - }; |
50 |
| -} |
51 |
| - |
52 |
| -no_mangle! { |
53 |
| - frexp(x: f64 | y: &mut c_int) -> f64; |
54 |
| - frexpf(x: f32 | y: &mut c_int) -> f32; |
55 |
| - acos(x: f64) -> f64; |
56 |
| - acosf(x: f32) -> f32; |
57 |
| - acosh(x: f64) -> f64; |
58 |
| - acoshf(x: f32) -> f32; |
59 |
| - asin(x: f64) -> f64; |
60 |
| - asinf(x: f32) -> f32; |
61 |
| - asinh(x: f64) -> f64; |
62 |
| - asinhf(x: f32) -> f32; |
63 |
| - atan(x: f64) -> f64; |
64 |
| - atan2(x: f64, y: f64) -> f64; |
65 |
| - atan2f(x: f32, y: f32) -> f32; |
66 |
| - atanf(x: f32) -> f32; |
67 |
| - atanh(x: f64) -> f64; |
68 |
| - atanhf(x: f32) -> f32; |
69 |
| - cbrt(x: f64) -> f64; |
70 |
| - cbrtf(x: f32) -> f32; |
71 |
| - ceil(x: f64) -> f64; |
72 |
| - ceilf(x: f32) -> f32; |
73 |
| - ceilf128(x: f128) -> f128; |
74 |
| - ceilf16(x: f16) -> f16; |
75 |
| - copysign(x: f64, y: f64) -> f64; |
76 |
| - copysignf(x: f32, y: f32) -> f32; |
77 |
| - copysignf128(x: f128, y: f128) -> f128; |
78 |
| - copysignf16(x: f16, y: f16) -> f16; |
79 |
| - cos(x: f64) -> f64; |
80 |
| - cosf(x: f32) -> f32; |
81 |
| - cosh(x: f64) -> f64; |
82 |
| - coshf(x: f32) -> f32; |
83 |
| - erf(x: f64) -> f64; |
84 |
| - erfc(x: f64) -> f64; |
85 |
| - erfcf(x: f32) -> f32; |
86 |
| - erff(x: f32) -> f32; |
87 |
| - exp(x: f64) -> f64; |
88 |
| - exp10(x: f64) -> f64; |
89 |
| - exp10f(x: f32) -> f32; |
90 |
| - exp2(x: f64) -> f64; |
91 |
| - exp2f(x: f32) -> f32; |
92 |
| - expf(x: f32) -> f32; |
93 |
| - expm1(x: f64) -> f64; |
94 |
| - expm1f(x: f32) -> f32; |
95 |
| - fabs(x: f64) -> f64; |
96 |
| - fabsf(x: f32) -> f32; |
97 |
| - fabsf128(x: f128) -> f128; |
98 |
| - fabsf16(x: f16) -> f16; |
99 |
| - fdim(x: f64, y: f64) -> f64; |
100 |
| - fdimf(x: f32, y: f32) -> f32; |
101 |
| - fdimf128(x: f128, y: f128) -> f128; |
102 |
| - fdimf16(x: f16, y: f16) -> f16; |
103 |
| - floor(x: f64) -> f64; |
104 |
| - floorf(x: f32) -> f32; |
105 |
| - floorf128(x: f128) -> f128; |
106 |
| - floorf16(x: f16) -> f16; |
107 |
| - fma(x: f64, y: f64, z: f64) -> f64; |
108 |
| - fmaf(x: f32, y: f32, z: f32) -> f32; |
109 |
| - fmax(x: f64, y: f64) -> f64; |
110 |
| - fmaxf(x: f32, y: f32) -> f32; |
111 |
| - fmin(x: f64, y: f64) -> f64; |
112 |
| - fminf(x: f32, y: f32) -> f32; |
113 |
| - fmod(x: f64, y: f64) -> f64; |
114 |
| - fmodf(x: f32, y: f32) -> f32; |
115 |
| - hypot(x: f64, y: f64) -> f64; |
116 |
| - hypotf(x: f32, y: f32) -> f32; |
117 |
| - ilogb(x: f64) -> c_int; |
118 |
| - ilogbf(x: f32) -> c_int; |
119 |
| - j0(x: f64) -> f64; |
120 |
| - j0f(x: f32) -> f32; |
121 |
| - j1(x: f64) -> f64; |
122 |
| - j1f(x: f32) -> f32; |
123 |
| - jn(x: c_int, y: f64) -> f64; |
124 |
| - jnf(x: c_int, y: f32) -> f32; |
125 |
| - ldexp(x: f64, y: c_int) -> f64; |
126 |
| - ldexpf(x: f32, y: c_int) -> f32; |
127 |
| - lgamma(x: f64) -> f64; |
128 |
| - lgamma_r(x: f64 | r: &mut c_int) -> f64; |
129 |
| - lgammaf(x: f32) -> f32; |
130 |
| - lgammaf_r(x: f32 | r: &mut c_int) -> f32; |
131 |
| - log(x: f64) -> f64; |
132 |
| - log10(x: f64) -> f64; |
133 |
| - log10f(x: f32) -> f32; |
134 |
| - log1p(x: f64) -> f64; |
135 |
| - log1pf(x: f32) -> f32; |
136 |
| - log2(x: f64) -> f64; |
137 |
| - log2f(x: f32) -> f32; |
138 |
| - logf(x: f32) -> f32; |
139 |
| - modf(x: f64 | r: &mut f64) -> f64; |
140 |
| - modff(x: f32 | r: &mut f32) -> f32; |
141 |
| - nextafter(x: f64, y: f64) -> f64; |
142 |
| - nextafterf(x: f32, y: f32) -> f32; |
143 |
| - pow(x: f64, y: f64) -> f64; |
144 |
| - powf(x: f32, y: f32) -> f32; |
145 |
| - remainder(x: f64, y: f64) -> f64; |
146 |
| - remainderf(x: f32, y: f32) -> f32; |
147 |
| - remquo(x: f64, y: f64 | q: &mut c_int) -> f64; |
148 |
| - remquof(x: f32, y: f32 | q: &mut c_int) -> f32; |
149 |
| - rint(x: f64) -> f64; |
150 |
| - rintf(x: f32) -> f32; |
151 |
| - rintf128(x: f128) -> f128; |
152 |
| - rintf16(x: f16) -> f16; |
153 |
| - round(x: f64) -> f64; |
154 |
| - roundf(x: f32) -> f32; |
155 |
| - scalbn(x: f64, y: c_int) -> f64; |
156 |
| - scalbnf(x: f32, y: c_int) -> f32; |
157 |
| - sin(x: f64) -> f64; |
158 |
| - sinf(x: f32) -> f32; |
159 |
| - sinh(x: f64) -> f64; |
160 |
| - sinhf(x: f32) -> f32; |
161 |
| - sqrt(x: f64) -> f64; |
162 |
| - sqrtf(x: f32) -> f32; |
163 |
| - tan(x: f64) -> f64; |
164 |
| - tanf(x: f32) -> f32; |
165 |
| - tanh(x: f64) -> f64; |
166 |
| - tanhf(x: f32) -> f32; |
167 |
| - tgamma(x: f64) -> f64; |
168 |
| - tgammaf(x: f32) -> f32; |
169 |
| - trunc(x: f64) -> f64; |
170 |
| - truncf(x: f32) -> f32; |
171 |
| - truncf128(x: f128) -> f128; |
172 |
| - truncf16(x: f16) -> f16; |
173 |
| - y0(x: f64) -> f64; |
174 |
| - y0f(x: f32) -> f32; |
175 |
| - y1(x: f64) -> f64; |
176 |
| - y1f(x: f32) -> f32; |
177 |
| - yn(x: c_int, y: f64) -> f64; |
178 |
| - ynf(x: c_int, y: f32) -> f32; |
179 |
| -} |
180 |
| - |
181 |
| -/* sincos has no direct return type, not worth handling in the macro */ |
182 |
| - |
183 |
| -#[no_mangle] |
184 |
| -extern "C" fn sincos(x: f64, s: &mut f64, c: &mut f64) { |
185 |
| - (*s, *c) = libm::sincos(x); |
186 |
| -} |
187 |
| - |
188 |
| -#[no_mangle] |
189 |
| -extern "C" fn sincosf(x: f32, s: &mut f32, c: &mut f32) { |
190 |
| - (*s, *c) = libm::sincosf(x); |
191 |
| -} |
192 |
| - |
193 |
| -#[panic_handler] |
194 |
| -fn panic(_info: &core::panic::PanicInfo) -> ! { |
195 |
| - loop {} |
196 |
| -} |
| 15 | +use math::libm::support; |
0 commit comments