Skip to content

Commit 2ffcc96

Browse files
authored
Indirectly update to libm 0.2 (rust-lang/packed-simd#335)
Unfortunately, `libm 0.2` remove the `F32Ext` and `F64Ext` extension traits, which makes it harder to choose the different methods. However, this was already dealt with in rust-num/num-traits#144 for `Float`, so we can piggy-back on that here, no longer using `libm` directly. Closes rust-lang/packed-simd#294
1 parent 3fbbca6 commit 2ffcc96

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ maintenance = { status = "experimental" }
2222
[dependencies]
2323
cfg-if = "1.0.0"
2424
core_arch = { version = "0.1.5", optional = true }
25-
libm = "0.1.4"
25+
num-traits = { version = "0.2.14", default-features = false, features = ["libm"] }
2626

2727
[features]
2828
default = []

src/codegen/math/float/tanh.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
// FIXME 64-bit 1 elem vectors tanh
55

6+
#[cfg(not(feature = "std"))]
7+
use num_traits::Float;
8+
69
use crate::*;
710

811
pub(crate) trait Tanh {
@@ -22,11 +25,11 @@ macro_rules! define_tanh {
2225
};
2326

2427
(f32 => $name:ident, $type:ty, $lanes:expr) => {
25-
define_tanh!($name, f32, $type, $lanes, libm::F32Ext);
28+
define_tanh!($name, f32, $type, $lanes, Float);
2629
};
2730

2831
(f64 => $name:ident, $type:ty, $lanes:expr) => {
29-
define_tanh!($name, f64, $type, $lanes, libm::F64Ext);
32+
define_tanh!($name, f64, $type, $lanes, Float);
3033
};
3134
}
3235

@@ -43,11 +46,11 @@ define_tanh!(f64 => tanh_v4f64, f64x4, 4);
4346
define_tanh!(f64 => tanh_v8f64, f64x8, 8);
4447

4548
fn tanh_f32(x: f32) -> f32 {
46-
libm::F32Ext::tanh(x)
49+
Float::tanh(x)
4750
}
4851

4952
fn tanh_f64(x: f64) -> f64 {
50-
libm::F64Ext::tanh(x)
53+
Float::tanh(x)
5154
}
5255

5356
gen_unary_impl_table!(Tanh, tanh);

0 commit comments

Comments
 (0)