Skip to content

Commit aba238d

Browse files
committed
add more math functions
1 parent 2d3b12a commit aba238d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

libm

Submodule libm updated from 7275814 to 0e97df2

src/math.rs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,50 @@
22
#[path = "../../libm/src/math/mod.rs"]
33
mod libm;
44

5-
#[no_mangle]
6-
pub fn fmodf(x: f32, y: f32) -> f32 {
7-
self::libm::fmodf(x, y)
5+
macro_rules! no_mangle {
6+
($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => {
7+
$(
8+
#[no_mangle]
9+
pub fn $fun($($iid: $ity),+) -> $oty {
10+
self::libm::$fun($($iid),+)
11+
}
12+
)+
13+
}
814
}
915

10-
#[no_mangle]
11-
pub fn powf(x: f32, y: f32) -> f32 {
12-
self::libm::powf(x, y)
16+
no_mangle! {
17+
fn acos(x: f64) -> f64;
18+
fn asin(x: f64) -> f64;
19+
// fn atan(x: f64) -> f64;
20+
// fn atan2(x: f64, y: f64) -> f64;
21+
fn cbrt(x: f64) -> f64;
22+
// fn cosh(x: f64) -> f64;
23+
fn expm1(x: f64) -> f64;
24+
fn hypot(x: f64, y: f64) -> f64;
25+
fn log1p(x: f64) -> f64;
26+
fn sinh(x: f64) -> f64;
27+
fn tan(x: f64) -> f64;
28+
fn tanh(x: f64) -> f64;
29+
fn cos(x: f64) -> f64;
30+
fn cosf(x: f32) -> f32;
31+
fn exp(x: f64) -> f64;
32+
fn expf(x: f32) -> f32;
33+
fn log2(x: f64) -> f64;
34+
fn log2f(x: f32) -> f32;
35+
fn log10(x: f64) -> f64;
36+
fn log10f(x: f32) -> f32;
37+
fn log(x: f64) -> f64;
38+
fn logf(x: f32) -> f32;
39+
fn round(x: f64) -> f64;
40+
fn roundf(x: f32) -> f32;
41+
fn sin(x: f64) -> f64;
42+
fn sinf(x: f32) -> f32;
43+
// fn pow(x: f64, y: f64) -> f64;
44+
fn powf(x: f32, y: f32) -> f32;
45+
fn exp2(x: f64) -> f64;
46+
fn exp2f(x: f32) -> f32;
47+
fn fmod(x: f64, y: f64) -> f64;
48+
fn fmodf(x: f32, y: f32) -> f32;
49+
fn fma(x: f64, y: f64, z: f64) -> f64;
50+
fn fmaf(x: f32, y: f32, z: f32) -> f32;
1351
}

0 commit comments

Comments
 (0)