1#[cfg(target_arch = "x86_64")]
8macro_rules! ld_wrapper {
9 ($name:ident, $base:path, f64_ret) => {
10 #[no_mangle]
11 pub unsafe extern "C" fn $name(x: f64) -> f64 {
12 $base(x)
13 }
14 };
15 ($name:ident, $base:path, f64_f64_ret) => {
16 #[no_mangle]
17 pub unsafe extern "C" fn $name(x: f64, y: f64) -> f64 {
18 $base(x, y)
19 }
20 };
21 ($name:ident, $base:path, f64_int_ret) => {
22 #[no_mangle]
23 pub unsafe extern "C" fn $name(x: f64, n: i32) -> f64 {
24 $base(x, n)
25 }
26 };
27 ($name:ident, $base:path, f64_long_ret) => {
28 #[no_mangle]
29 pub unsafe extern "C" fn $name(x: f64, n: core::ffi::c_long) -> f64 {
30 $base(x, n)
31 }
32 };
33 ($name:ident, $base:path, f64_f64_f64_ret) => {
34 #[no_mangle]
35 pub unsafe extern "C" fn $name(x: f64, y: f64, z: f64) -> f64 {
36 $base(x, y, z)
37 }
38 };
39 ($name:ident, $base:path, int_f64_ret) => {
40 #[no_mangle]
41 pub unsafe extern "C" fn $name(x: f64) -> i32 {
42 $base(x)
43 }
44 };
45 ($name:ident, $base:path, long_f64_ret) => {
46 #[no_mangle]
47 pub unsafe extern "C" fn $name(x: f64) -> core::ffi::c_long {
48 $base(x)
49 }
50 };
51 ($name:ident, $base:path, longlong_f64_ret) => {
52 #[no_mangle]
53 pub unsafe extern "C" fn $name(x: f64) -> i64 {
54 $base(x)
55 }
56 };
57}
58
59#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
60macro_rules! ld_wrapper {
61 ($name:ident, $base:path, f64_ret) => {
62 #[no_mangle]
63 pub unsafe extern "C" fn $name(x: f128) -> f128 {
64 f64_to_f128($base(f128_to_f64(x)))
65 }
66 };
67 ($name:ident, $base:path, f64_f64_ret) => {
68 #[no_mangle]
69 pub unsafe extern "C" fn $name(x: f128, y: f128) -> f128 {
70 f64_to_f128($base(f128_to_f64(x), f128_to_f64(y)))
71 }
72 };
73 ($name:ident, $base:path, f64_int_ret) => {
74 #[no_mangle]
75 pub unsafe extern "C" fn $name(x: f128, n: i32) -> f128 {
76 f64_to_f128($base(f128_to_f64(x), n))
77 }
78 };
79 ($name:ident, $base:path, f64_long_ret) => {
80 #[no_mangle]
81 pub unsafe extern "C" fn $name(x: f128, n: core::ffi::c_long) -> f128 {
82 f64_to_f128($base(f128_to_f64(x), n))
83 }
84 };
85 ($name:ident, $base:path, f64_f64_f64_ret) => {
86 #[no_mangle]
87 pub unsafe extern "C" fn $name(x: f128, y: f128, z: f128) -> f128 {
88 f64_to_f128($base(f128_to_f64(x), f128_to_f64(y), f128_to_f64(z)))
89 }
90 };
91 ($name:ident, $base:path, int_f64_ret) => {
92 #[no_mangle]
93 pub unsafe extern "C" fn $name(x: f128) -> i32 {
94 $base(f128_to_f64(x))
95 }
96 };
97 ($name:ident, $base:path, long_f64_ret) => {
98 #[no_mangle]
99 pub unsafe extern "C" fn $name(x: f128) -> core::ffi::c_long {
100 $base(f128_to_f64(x))
101 }
102 };
103 ($name:ident, $base:path, longlong_f64_ret) => {
104 #[no_mangle]
105 pub unsafe extern "C" fn $name(x: f128) -> i64 {
106 $base(f128_to_f64(x))
107 }
108 };
109}
110
111
112ld_wrapper!(acosl, crate::acos, f64_ret);
113ld_wrapper!(asinl, crate::asin, f64_ret);
114ld_wrapper!(atanl, crate::atan, f64_ret);
115ld_wrapper!(ceill, crate::ceil, f64_ret);
116ld_wrapper!(cosl, crate::cos, f64_ret);
117ld_wrapper!(coshl, crate::cosh, f64_ret);
118ld_wrapper!(expl, crate::exp, f64_ret);
119ld_wrapper!(fabsl, crate::fabs, f64_ret);
120ld_wrapper!(floorl, crate::floor, f64_ret);
121ld_wrapper!(hypotl, crate::hypot, f64_f64_ret);
122ld_wrapper!(ldexpl, crate::ldexp, f64_int_ret);
123ld_wrapper!(logl, crate::log, f64_ret);
124ld_wrapper!(log2l, crate::log2, f64_ret);
125ld_wrapper!(log10l, crate::log10, f64_ret);
126ld_wrapper!(powl, crate::pow, f64_f64_ret);
127ld_wrapper!(roundl, crate::round, f64_ret);
128ld_wrapper!(scalblnl, crate::scalbln, f64_long_ret);
129ld_wrapper!(scalbnl, crate::scalbn, f64_int_ret);
130ld_wrapper!(sinl, crate::sin, f64_ret);
131ld_wrapper!(sinhl, crate::sinh, f64_ret);
132ld_wrapper!(sqrtl, crate::sqrt, f64_ret);
133ld_wrapper!(tanl, crate::tan, f64_ret);
134ld_wrapper!(tanhl, crate::tanh, f64_ret);
135ld_wrapper!(truncl, crate::trunc, f64_ret);
136ld_wrapper!(atan2l, crate::atan2, f64_f64_ret);
137ld_wrapper!(copysignl, crate::copysign, f64_f64_ret);
138ld_wrapper!(fmodl, crate::fmod, f64_f64_ret);
139
140#[cfg(target_arch = "x86_64")]
141#[no_mangle]
142pub unsafe extern "C" fn frexpl(x: f64, exp: *mut i32) -> f64 {
143 crate::frexp(x, exp)
144}
145
146#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
147#[no_mangle]
148pub unsafe extern "C" fn frexpl(x: f128, exp: *mut i32) -> f128 {
149 f64_to_f128(crate::frexp(f128_to_f64(x), exp))
150}
151
152#[cfg(target_arch = "x86_64")]
153#[no_mangle]
154pub unsafe extern "C" fn modfl(x: f64, iptr: *mut f64) -> f64 {
155 crate::modf(x, iptr)
156}
157
158#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
159#[no_mangle]
160pub unsafe extern "C" fn modfl(x: f128, iptr: *mut f128) -> f128 {
161 let mut ip = 0.0f64;
162 let fp = crate::modf(f128_to_f64(x), &mut ip);
163 *iptr = f64_to_f128(ip);
164 f64_to_f128(fp)
165}
166
167#[cfg(target_arch = "x86_64")]
168#[no_mangle]
169pub unsafe extern "C" fn nanl(_tagp: *const core::ffi::c_char) -> f64 {
170 f64::NAN
171}
172
173#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
174#[no_mangle]
175pub unsafe extern "C" fn nanl(_tagp: *const core::ffi::c_char) -> f128 {
176 f64_to_f128(f64::NAN)
177}
178
179#[cfg(target_arch = "x86_64")]
180#[no_mangle]
181pub unsafe extern "C" fn sincosl(x: f64, s: *mut f64, c: *mut f64) {
182 *s = crate::sin(x);
183 *c = crate::cos(x);
184}
185
186#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
187#[no_mangle]
188pub unsafe extern "C" fn sincosl(x: f128, s: *mut f128, c: *mut f128) {
189 *s = f64_to_f128(crate::sin(f128_to_f64(x)));
190 *c = f64_to_f128(crate::cos(f128_to_f64(x)));
191}
192
193#[cfg(target_arch = "x86_64")]
194#[no_mangle]
195pub unsafe extern "C" fn remquol(x: f64, y: f64, quo: *mut i32) -> f64 {
196 crate::remquo(x, y, quo)
197}
198
199#[cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "powerpc64", target_arch = "loongarch64"))]
200#[no_mangle]
201pub unsafe extern "C" fn remquol(x: f128, y: f128, quo: *mut i32) -> f128 {
202 f64_to_f128(crate::remquo(f128_to_f64(x), f128_to_f64(y), quo))
203}
204
205
206#[no_mangle]
207pub unsafe extern "C" fn exp10l(x: f64) -> f64 {
208 crate::pow(10.0, x)
209}
210
211ld_wrapper!(acoshl, crate::acosh, f64_ret);
212ld_wrapper!(asinhl, crate::asinh, f64_ret);
213ld_wrapper!(atanhl, crate::atanh, f64_ret);
214ld_wrapper!(cbrtl, crate::cbrt, f64_ret);
215ld_wrapper!(erfl, crate::erf, f64_ret);
216ld_wrapper!(erfcl, libm::erfc, f64_ret);
219ld_wrapper!(exp2l, libm::exp2, f64_ret);
220ld_wrapper!(expm1l, crate::expm1, f64_ret);
221ld_wrapper!(fdiml, crate::fdim, f64_f64_ret);
222ld_wrapper!(fmal, crate::fma, f64_f64_f64_ret);
223ld_wrapper!(fmaxl, crate::fmax_impl, f64_f64_ret);
224ld_wrapper!(fminl, crate::fmin_impl, f64_f64_ret);
225ld_wrapper!(ilogbl, crate::ilogb, int_f64_ret);
226ld_wrapper!(lgammal, crate::lgamma, f64_ret);
227ld_wrapper!(log1pl, crate::log1p, f64_ret);
228ld_wrapper!(logbl, crate::logb, f64_ret);
229ld_wrapper!(nearbyintl, crate::nearbyint, f64_ret);
230ld_wrapper!(nextafterl, crate::nextafter, f64_f64_ret);
231ld_wrapper!(nexttowardl, crate::nexttoward, f64_f64_ret);
232ld_wrapper!(remainderl, crate::remainder, f64_f64_ret);
233ld_wrapper!(rintl, crate::rint, f64_ret);
234ld_wrapper!(tgammal, crate::tgamma, f64_ret);
235ld_wrapper!(lroundl, crate::lround, long_f64_ret);
236ld_wrapper!(llroundl, crate::llround, longlong_f64_ret);