Skip to content

Commit

Permalink
Actually implement the float functions
Browse files Browse the repository at this point in the history
  • Loading branch information
YtvwlD committed Sep 3, 2024
1 parent 581eb55 commit b4d2f7a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions towboot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ scroll = { version = "0.12", default-features = false }

towboot_config = { path = "../towboot_config" }

# i686-unknown-uefi currently lacks float functions, see hacks.rs
[target.'cfg(target_arch = "x86")'.dependencies]
libm = "0.2"

[build-dependencies]
built = { version = "0.7", features = ["git2"] }
15 changes: 7 additions & 8 deletions towboot/src/hacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
//! This module contains missing symbols.
//!
//! The fmod and fmodf functions are [currently missing](https://github.com/rust-lang/rust/issues/128533)
//! on i686-unknown-uefi. In the long run, this should be fixed in
//! `compiler_builtins`. For now, this monkeypatching seems to be enough.
//! on i686-unknown-uefi, so let's use the ones of libm.
//! In the long run, this should be fixed in `compiler_builtins`.
//! For now, this monkeypatching seems to be enough.
//!
//! see https://github.com/rust-lang/compiler-builtins/blob/master/src/math.rs
//! We could also use libm::fmod{,f} here, but then we'd need __truncdfsf2.
//! Let's just hope they are never called.
#[cfg(target_arch = "x86")]
#[no_mangle]
pub extern "C" fn fmod(_x: f64, _y: f64) -> f64 {
unimplemented!();
pub extern "C" fn fmod(x: f64, y: f64) -> f64 {
libm::fmod(x, y)
}
#[cfg(target_arch = "x86")]
#[no_mangle]
pub extern "C" fn fmodf(_x: f32, _y: f32) -> f32 {
unimplemented!();
pub extern "C" fn fmodf(x: f32, y: f32) -> f32 {
libm::fmodf(x, y)
}

0 comments on commit b4d2f7a

Please sign in to comment.