Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit b10d776

Browse files
committed
Remove workarounds due to lack of extern C APIs
1 parent 1a49d70 commit b10d776

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

crates/libm-bench/benches/bench.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,16 @@ macro_rules! bench_fn {
2222
#[bench]
2323
#[allow(unused_mut)]
2424
pub fn $id(bh: &mut Bencher) {
25-
// Type of the system libm fn:
26-
type FnTy = unsafe extern "C" fn ($($arg_ids: $arg_tys),*) -> $ret_ty;
27-
28-
// FIXME: extern "C" wrapper
29-
extern "C" fn libm_fn($($arg_ids: $arg_tys),*) -> $ret_ty {
30-
libm::$id($($arg_ids),*)
31-
}
25+
type FnTy
26+
= unsafe extern "C" fn ($($arg_ids: $arg_tys),*) -> $ret_ty;
3227

3328
// Generate a tuple of arguments containing random values:
3429
let mut rng = rand::thread_rng();
3530
let mut x: ( $($arg_tys,)+ ) = ( $(rng.gen::<$arg_tys>(),)+ );
3631

3732
adjust_input!(fn: $id, input: x);
3833

39-
bh.iter(|| test::black_box(x).call(libm_fn as FnTy))
34+
bh.iter(|| test::black_box(x).call(libm::$id as FnTy))
4035
}
4136
};
4237
}

crates/libm-test/tests/system_libm.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ macro_rules! system_libm {
8080
type FnTy
8181
= unsafe extern "C" fn ($($arg_ids: $arg_tys),*) -> $ret_ty;
8282

83-
// FIXME: extern "C" wrapper over our libm functions
84-
// Shouldn't be needed once they are all extern "C"
85-
extern "C" fn libm_fn($($arg_ids: $arg_tys),*) -> $ret_ty {
86-
libm::$id($($arg_ids),*)
87-
}
88-
extern "C" {
83+
extern "C" {
8984
// The system's libm function:
9085
fn $id($($arg_ids: $arg_tys),*) -> $ret_ty;
9186
}
@@ -98,7 +93,7 @@ macro_rules! system_libm {
9893
// correct_input!(fn: $id, input: args);
9994
adjust_input!(fn: $id, input: args);
10095

101-
let result = args.call(libm_fn as FnTy);
96+
let result = args.call(libm::$id as FnTy);
10297
let expected = args.call($id as FnTy);
10398
assert_approx_eq!(
10499
result == expected,

0 commit comments

Comments
 (0)