expose libm functions to kernel
This commit is contained in:
parent
59cf2764ce
commit
e0560a2db9
@ -14,7 +14,7 @@ let
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./src;
|
||||
cargoSha256 = "11kd1vmm4i4plqwxbsgrxia1ihs2szw1r7af8j645zib71f0qx87";
|
||||
cargoSha256 = "04asmk07xc7asbpl15d9pgm31dd77lj9hkfgf76kcq6ds7l04k12";
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.gnumake
|
||||
|
7
src/Cargo.lock
generated
7
src/Cargo.lock
generated
@ -242,6 +242,12 @@ dependencies = [
|
||||
"libregister",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
||||
|
||||
[[package]]
|
||||
name = "libregister"
|
||||
version = "0.0.0"
|
||||
@ -412,6 +418,7 @@ dependencies = [
|
||||
"libboard_zynq",
|
||||
"libc",
|
||||
"libcortex_a9",
|
||||
"libm",
|
||||
"libregister",
|
||||
"libsupport_zynq",
|
||||
"log",
|
||||
|
@ -23,6 +23,7 @@ futures = { version = "0.3", default-features = false, features = ["async-await"
|
||||
async-recursion = "0.3"
|
||||
fatfs = { version = "0.3", features = ["core_io"], default-features = false }
|
||||
log_buffer = { version = "1.2" }
|
||||
libm = { version = "0.2", features = ["unstable"] }
|
||||
|
||||
libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zc706.git" }
|
||||
libsupport_zynq = { default-features = false, git = "https://git.m-labs.hk/M-Labs/zc706.git" }
|
||||
|
@ -1,3 +1,5 @@
|
||||
use libm;
|
||||
|
||||
use crate::eh_artiq;
|
||||
use crate::rtio;
|
||||
use super::rpc::{rpc_send, rpc_send_async, rpc_recv};
|
||||
@ -16,6 +18,15 @@ macro_rules! api {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! api_libm_f64f64 {
|
||||
($i:ident) => ({
|
||||
extern fn $i(x: f64) -> f64 {
|
||||
libm::$i(x)
|
||||
}
|
||||
api!($i = $i)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn resolve(required: &[u8]) -> Option<u32> {
|
||||
let api = &[
|
||||
// timing
|
||||
@ -117,14 +128,32 @@ pub fn resolve(required: &[u8]) -> Option<u32> {
|
||||
api!(__aeabi_memclr8),
|
||||
api!(__aeabi_memclr4),
|
||||
api!(__aeabi_memclr),
|
||||
|
||||
// libc
|
||||
api!(memcmp, extern { fn memcmp(a: *const u8, b: *mut u8, size: usize); }),
|
||||
|
||||
// exceptions
|
||||
api!(_Unwind_Resume = unwind::_Unwind_Resume),
|
||||
api!(__artiq_personality = eh_artiq::artiq_personality),
|
||||
api!(__artiq_raise = eh_artiq::raise),
|
||||
api!(__artiq_reraise = eh_artiq::reraise),
|
||||
|
||||
// libm
|
||||
api_libm_f64f64!(log),
|
||||
api_libm_f64f64!(log10),
|
||||
api_libm_f64f64!(exp),
|
||||
{
|
||||
extern fn pow(x: f64, y: f64) -> f64 {
|
||||
libm::pow(x, y)
|
||||
}
|
||||
api!(pow = pow)
|
||||
},
|
||||
api_libm_f64f64!(sin),
|
||||
api_libm_f64f64!(cos),
|
||||
api_libm_f64f64!(tan),
|
||||
api_libm_f64f64!(asin),
|
||||
api_libm_f64f64!(acos),
|
||||
api_libm_f64f64!(atan),
|
||||
];
|
||||
api.iter()
|
||||
.find(|&&(exported, _)| exported.as_bytes() == required)
|
||||
|
Loading…
Reference in New Issue
Block a user