Skip to content

Commit 49920bc

Browse files
committed
Auto merge of #84522 - CDirkx:cmath, r=yaahc
Reuse `sys::unix::cmath` on other platforms Reuse `sys::unix::cmath` on all non-`windows` platforms. `unix` is chosen as the canonical location instead of `unsupported` or `common` because `unsupported` doesn't make sense semantically and `common` is reserved for code that is supported on all platforms. Also `unix` is already the home of some non-`windows` code that is technically not exclusive to `unix` like `unix::path`.
2 parents bcd696d + 26fb1e3 commit 49920bc

File tree

10 files changed

+34
-118
lines changed

10 files changed

+34
-118
lines changed

library/std/src/sys/hermit/cmath.rs

-29
This file was deleted.

library/std/src/sys/hermit/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::os::raw::c_char;
2020

2121
pub mod alloc;
2222
pub mod args;
23+
#[path = "../unix/cmath.rs"]
2324
pub mod cmath;
2425
pub mod condvar;
2526
pub mod env;

library/std/src/sys/sgx/cmath.rs

-31
This file was deleted.

library/std/src/sys/sgx/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod waitqueue;
1313

1414
pub mod alloc;
1515
pub mod args;
16+
#[path = "../unix/cmath.rs"]
1617
pub mod cmath;
1718
pub mod condvar;
1819
pub mod env;

library/std/src/sys/unix/cmath.rs

+28-27
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
#![cfg(not(test))]
22

3-
use libc::{c_double, c_float};
3+
// These symbols are all defined by `libm`,
4+
// or by `compiler-builtins` on unsupported platforms.
45

56
extern "C" {
6-
pub fn acos(n: c_double) -> c_double;
7-
pub fn acosf(n: c_float) -> c_float;
8-
pub fn asin(n: c_double) -> c_double;
9-
pub fn asinf(n: c_float) -> c_float;
10-
pub fn atan(n: c_double) -> c_double;
11-
pub fn atan2(a: c_double, b: c_double) -> c_double;
12-
pub fn atan2f(a: c_float, b: c_float) -> c_float;
13-
pub fn atanf(n: c_float) -> c_float;
14-
pub fn cbrt(n: c_double) -> c_double;
15-
pub fn cbrtf(n: c_float) -> c_float;
16-
pub fn cosh(n: c_double) -> c_double;
17-
pub fn coshf(n: c_float) -> c_float;
18-
pub fn expm1(n: c_double) -> c_double;
19-
pub fn expm1f(n: c_float) -> c_float;
20-
pub fn fdim(a: c_double, b: c_double) -> c_double;
21-
pub fn fdimf(a: c_float, b: c_float) -> c_float;
22-
pub fn hypot(x: c_double, y: c_double) -> c_double;
23-
pub fn hypotf(x: c_float, y: c_float) -> c_float;
24-
pub fn log1p(n: c_double) -> c_double;
25-
pub fn log1pf(n: c_float) -> c_float;
26-
pub fn sinh(n: c_double) -> c_double;
27-
pub fn sinhf(n: c_float) -> c_float;
28-
pub fn tan(n: c_double) -> c_double;
29-
pub fn tanf(n: c_float) -> c_float;
30-
pub fn tanh(n: c_double) -> c_double;
31-
pub fn tanhf(n: c_float) -> c_float;
7+
pub fn acos(n: f64) -> f64;
8+
pub fn acosf(n: f32) -> f32;
9+
pub fn asin(n: f64) -> f64;
10+
pub fn asinf(n: f32) -> f32;
11+
pub fn atan(n: f64) -> f64;
12+
pub fn atan2(a: f64, b: f64) -> f64;
13+
pub fn atan2f(a: f32, b: f32) -> f32;
14+
pub fn atanf(n: f32) -> f32;
15+
pub fn cbrt(n: f64) -> f64;
16+
pub fn cbrtf(n: f32) -> f32;
17+
pub fn cosh(n: f64) -> f64;
18+
pub fn coshf(n: f32) -> f32;
19+
pub fn expm1(n: f64) -> f64;
20+
pub fn expm1f(n: f32) -> f32;
21+
pub fn fdim(a: f64, b: f64) -> f64;
22+
pub fn fdimf(a: f32, b: f32) -> f32;
23+
pub fn hypot(x: f64, y: f64) -> f64;
24+
pub fn hypotf(x: f32, y: f32) -> f32;
25+
pub fn log1p(n: f64) -> f64;
26+
pub fn log1pf(n: f32) -> f32;
27+
pub fn sinh(n: f64) -> f64;
28+
pub fn sinhf(n: f32) -> f32;
29+
pub fn tan(n: f64) -> f64;
30+
pub fn tanf(n: f32) -> f32;
31+
pub fn tanh(n: f64) -> f64;
32+
pub fn tanhf(n: f32) -> f32;
3233
}

library/std/src/sys/unix/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod weak;
1111
pub mod alloc;
1212
pub mod android;
1313
pub mod args;
14+
#[path = "../unix/cmath.rs"]
1415
pub mod cmath;
1516
pub mod condvar;
1617
pub mod env;

library/std/src/sys/unsupported/cmath.rs

-29
This file was deleted.

library/std/src/sys/unsupported/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
pub mod alloc;
44
pub mod args;
5+
#[path = "../unix/cmath.rs"]
56
pub mod cmath;
67
pub mod condvar;
78
pub mod env;

library/std/src/sys/wasi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::mem;
2020
#[path = "../unix/alloc.rs"]
2121
pub mod alloc;
2222
pub mod args;
23-
#[path = "../unsupported/cmath.rs"]
23+
#[path = "../unix/cmath.rs"]
2424
pub mod cmath;
2525
#[path = "../unsupported/condvar.rs"]
2626
pub mod condvar;

library/std/src/sys/wasm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
pub mod alloc;
2020
pub mod args;
21-
#[path = "../unsupported/cmath.rs"]
21+
#[path = "../unix/cmath.rs"]
2222
pub mod cmath;
2323
pub mod env;
2424
#[path = "../unsupported/fs.rs"]

0 commit comments

Comments
 (0)