Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add libm support #37

Merged
merged 5 commits into from
Jun 13, 2020
Merged

add libm support #37

merged 5 commits into from
Jun 13, 2020

Conversation

stlankes
Copy link
Contributor

@stlankes stlankes commented Jun 4, 2020

libm is port of MUSL's libm to Rust. This crate is used to support basic arithmetic functions.

libm is port of MUSL's libm to Rust.
Use this crate to support basic arithmetic functions.
let z: f64 = y.log(E);

println!("x = {}, e^x = {}, ln(e^x) = {}", x, y, z);

Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a check here if x and z are approximately the same instead of always returning Ok(())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea

libm::atan2(a, b)
}

pub extern "C" fn atan2f(a: f32, b: f32) -> f32 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think #[no_mangle] is missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I revise the PR

libm::log(x)
}

pub fn logf(x: f32) -> f32 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one intentionally a rust function?

@stlankes stlankes merged commit ed62936 into hermit-os:master Jun 13, 2020
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 13, 2023
Hermit: Remove floor symbol

This symbol should be provided by Hermit.

It was introduced in 2019 (rust-lang#65167). Since 2020, Hermit provides these math functions on its own (hermit-os/hermit-rs#37). I think moving this to Hermit was merely an oversight.

Related:
* hermit-os/kernel#654
* hermit-os/hermit-rs#406

CC: `@stlankes`
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request May 31, 2023
Hermit: Remove floor symbol

This symbol should be provided by Hermit.

It was introduced in 2019 (rust-lang/rust#65167). Since 2020, Hermit provides these math functions on its own (hermit-os/hermit-rs#37). I think moving this to Hermit was merely an oversight.

Related:
* hermit-os/kernel#654
* hermit-os/hermit-rs#406

CC: `@stlankes`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants