Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
augustin-cheron committed May 11, 2021
1 parent 8fcbaea commit 10a255a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ members = [
]

[dev-dependencies]
no-panic = "0.1.8"
no-panic = "0.1.15"

[build-dependencies]
rand = { version = "0.6.5", optional = true }
rand = { version = "0.8.3", optional = true }
2 changes: 1 addition & 1 deletion crates/libm-c-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ panic = "abort"

[dependencies]
libm = { path = "../.." }
libc = {version="0.2", default-features=false}
libc = { version = "0.2.94", default-features = false }
22 changes: 19 additions & 3 deletions crates/libm-c-abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
#![no_std]
#![feature(lang_items)]
#![feature(core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;

mod lib_f32;
mod lib_f64;
mod lib_fenv;
mod lib_long_double;
mod musl_missing;
mod new_lib;

pub use lib_f32::*;
pub use lib_f64::*;
pub use lib_fenv::*;
pub use lib_long_double::*;

pub use musl_missing::*;
pub use new_lib::*;

#[no_mangle]
pub static mut signgam: i32 = 0;

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_panic: &PanicInfo<'_>) -> ! {
loop {}
fn panic(_info: &PanicInfo) -> ! {
intrinsics::abort()
}

/*
#[panic_handler]
fn panic(_: &PanicInfo<'_>) -> ! {
extern "Rust" {
#[link_name = "\nerror(panic-never): your program contains at least one panicking branch"]
fn undefined() -> !;
}
unsafe { undefined() }
}
*/

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
23 changes: 0 additions & 23 deletions crates/libm-c-abi/src/lib_f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,26 +325,3 @@ pub extern "C" fn remainderf(numer: c_float, denom: c_float) -> c_float {
libm::remquof(numer, denom).0
}

// todo : add a newlib test cfg feature flag?
#[no_mangle]
pub extern "C" fn __isfinitef(x: c_float) -> c_int {
if (x as f32).is_finite() {
1
} else {
0
}
}
#[no_mangle]
pub extern "C" fn __isnormalf(x: c_float) -> c_int {
if (x as f32).is_normal() {
1
} else {
0
}
}

#[no_mangle]
pub extern "C" fn __fpclassifyf(_x: c_float) -> c_int {
const FP_NORMAL: i32 = 0x4;
FP_NORMAL
}
25 changes: 25 additions & 0 deletions crates/libm-c-abi/src/new_lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use libc::{c_float, c_int, c_long, c_longlong};

// todo : add a newlib test cfg feature flag?
#[no_mangle]
pub extern "C" fn __isfinitef(x: c_float) -> c_int {
if (x as f32).is_finite() {
1
} else {
0
}
}
#[no_mangle]
pub extern "C" fn __isnormalf(x: c_float) -> c_int {
if (x as f32).is_normal() {
1
} else {
0
}
}

#[no_mangle]
pub extern "C" fn __fpclassifyf(_x: c_float) -> c_int {
const FP_NORMAL: i32 = 0x4;
FP_NORMAL
}

0 comments on commit 10a255a

Please sign in to comment.