From 6950d3487c4c3380d50c803ed8f2d09d446a8690 Mon Sep 17 00:00:00 2001 From: Kevin Boos Date: Wed, 11 May 2022 14:24:42 -0500 Subject: [PATCH] Export more `libm` functions as `#[no_mangle]`. Adds the following function wrappers: * `ceil` * `floor` * `ceilf` * `floorf` * `trunc` * `truncf` --- kernel/nano_core/src/libm.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/kernel/nano_core/src/libm.rs b/kernel/nano_core/src/libm.rs index 9a427796aa..8d6fcbc164 100644 --- a/kernel/nano_core/src/libm.rs +++ b/kernel/nano_core/src/libm.rs @@ -1,5 +1,5 @@ -//! In no_std compilation environments, the `libm` crate doesn't properly export -//! various no_mangle symbols properly, so we do it manually here. +//! When compiling for certain `no_std` targets, the `libm` crate doesn't properly export +//! various `no_mangle` symbols from `libm` properly, so we do it manually here. #[no_mangle] pub extern "C" fn fmod(a: f64, b: f64) -> f64 { @@ -30,3 +30,33 @@ pub extern "C" fn fmax(a: f64, b: f64) -> f64 { pub extern "C" fn fmaxf(a: f32, b: f32) -> f32 { libm::fmaxf(a, b) } + +#[no_mangle] +pub extern "C" fn ceil(x: f64) -> f64 { + libm::ceil(x) +} + +#[no_mangle] +pub extern "C" fn floor(x: f64) -> f64 { + libm::floor(x) +} + +#[no_mangle] +pub extern "C" fn ceilf(x: f32) -> f32 { + libm::ceilf(x) +} + +#[no_mangle] +pub extern "C" fn floorf(x: f32) -> f32 { + libm::floorf(x) +} + +#[no_mangle] +pub extern "C" fn trunc(x: f64) -> f64 { + libm::trunc(x) +} + +#[no_mangle] +pub extern "C" fn truncf(x: f32) -> f32 { + libm::truncf(x) +}