kernel/api: Add additional binary libm functions

Also factored out (f64, f64) -> f64 libm wrappers into
a macro, similar to the unary ones.
This commit is contained in:
David Nadlinger 2020-11-11 01:21:39 +01:00
parent 291a782db0
commit 7c336f7770

View File

@ -64,6 +64,15 @@ macro_rules! api_libm_f64f64 {
}) })
} }
macro_rules! api_libm_f64f64f64 {
($i:ident) => ({
extern fn $i(x: f64, y: f64) -> f64 {
libm::$i(x, y)
}
api!($i = $i)
})
}
pub fn resolve(required: &[u8]) -> Option<u32> { pub fn resolve(required: &[u8]) -> Option<u32> {
let api = &[ let api = &[
// timing // timing
@ -206,15 +215,11 @@ pub fn resolve(required: &[u8]) -> Option<u32> {
api_libm_f64f64!(asin), api_libm_f64f64!(asin),
api_libm_f64f64!(asinh), api_libm_f64f64!(asinh),
api_libm_f64f64!(atan), api_libm_f64f64!(atan),
{ api_libm_f64f64f64!(atan2),
extern fn atan2(y: f64, x: f64) -> f64 {
libm::atan2(y, x)
}
api!(atan2 = atan2)
},
api_libm_f64f64!(atanh), api_libm_f64f64!(atanh),
api_libm_f64f64!(cbrt), api_libm_f64f64!(cbrt),
api_libm_f64f64!(ceil), api_libm_f64f64!(ceil),
api_libm_f64f64f64!(copysign),
api_libm_f64f64!(cos), api_libm_f64f64!(cos),
api_libm_f64f64!(cosh), api_libm_f64f64!(cosh),
api_libm_f64f64!(erf), api_libm_f64f64!(erf),
@ -231,18 +236,10 @@ pub fn resolve(required: &[u8]) -> Option<u32> {
} }
api!(fma = fma) api!(fma = fma)
}, },
{ api_libm_f64f64f64!(fmax),
extern fn fmod(x: f64, y: f64) -> f64 { api_libm_f64f64f64!(fmin),
libm::fmod(x, y) api_libm_f64f64f64!(fmod),
} api_libm_f64f64f64!(hypot),
api!(fmod = fmod)
},
{
extern fn hypot(x: f64, y: f64) -> f64 {
libm::hypot(x, y)
}
api!(hypot = hypot)
},
api_libm_f64f64!(j0), api_libm_f64f64!(j0),
api_libm_f64f64!(j1), api_libm_f64f64!(j1),
{ {
@ -255,12 +252,8 @@ pub fn resolve(required: &[u8]) -> Option<u32> {
api_libm_f64f64!(log), api_libm_f64f64!(log),
api_libm_f64f64!(log2), api_libm_f64f64!(log2),
api_libm_f64f64!(log10), api_libm_f64f64!(log10),
{ api_libm_f64f64f64!(nextafter),
extern fn pow(x: f64, y: f64) -> f64 { api_libm_f64f64f64!(pow),
libm::pow(x, y)
}
api!(pow = pow)
},
api_libm_f64f64!(round), api_libm_f64f64!(round),
api_libm_f64f64!(sin), api_libm_f64f64!(sin),
api_libm_f64f64!(sinh), api_libm_f64f64!(sinh),