]> git.proxmox.com Git - rustc.git/blame - src/libstd/sys/wasm/cmath.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / libstd / sys / wasm / cmath.rs
CommitLineData
abe05a73
XL
1// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#[inline]
12pub unsafe fn cbrtf(n: f32) -> f32 {
13 f64::cbrt(n as f64) as f32
14}
15
16#[inline]
17pub unsafe fn expm1f(n: f32) -> f32 {
18 f64::exp_m1(n as f64) as f32
19}
20
21#[inline]
22#[allow(deprecated)]
23pub unsafe fn fdimf(a: f32, b: f32) -> f32 {
24 f64::abs_sub(a as f64, b as f64) as f32
25}
26
27#[inline]
28pub unsafe fn log1pf(n: f32) -> f32 {
29 f64::ln_1p(n as f64) as f32
30}
31
32#[inline]
33pub unsafe fn hypotf(x: f32, y: f32) -> f32 {
34 f64::hypot(x as f64, y as f64) as f32
35}
36
37#[inline]
38pub unsafe fn acosf(n: f32) -> f32 {
39 f64::acos(n as f64) as f32
40}
41
42#[inline]
43pub unsafe fn asinf(n: f32) -> f32 {
44 f64::asin(n as f64) as f32
45}
46
47#[inline]
48pub unsafe fn atan2f(n: f32, b: f32) -> f32 {
49 f64::atan2(n as f64, b as f64) as f32
50}
51
52#[inline]
53pub unsafe fn atanf(n: f32) -> f32 {
54 f64::atan(n as f64) as f32
55}
56
57#[inline]
58pub unsafe fn coshf(n: f32) -> f32 {
59 f64::cosh(n as f64) as f32
60}
61
62#[inline]
63pub unsafe fn sinhf(n: f32) -> f32 {
64 f64::sinh(n as f64) as f32
65}
66
67#[inline]
68pub unsafe fn tanf(n: f32) -> f32 {
69 f64::tan(n as f64) as f32
70}
71
72#[inline]
73pub unsafe fn tanhf(n: f32) -> f32 {
74 f64::tanh(n as f64) as f32
75}
76
0bf4aa26 77// These symbols are all defined in `compiler-builtins`
abe05a73 78extern {
abe05a73 79 pub fn acos(n: f64) -> f64;
abe05a73 80 pub fn asin(n: f64) -> f64;
abe05a73 81 pub fn atan(n: f64) -> f64;
abe05a73 82 pub fn atan2(a: f64, b: f64) -> f64;
abe05a73 83 pub fn cbrt(n: f64) -> f64;
abe05a73 84 pub fn cosh(n: f64) -> f64;
abe05a73
XL
85 pub fn expm1(n: f64) -> f64;
86 pub fn fdim(a: f64, b: f64) -> f64;
abe05a73 87 pub fn log1p(n: f64) -> f64;
abe05a73 88 pub fn sinh(n: f64) -> f64;
abe05a73 89 pub fn tan(n: f64) -> f64;
abe05a73 90 pub fn tanh(n: f64) -> f64;
abe05a73
XL
91 pub fn hypot(x: f64, y: f64) -> f64;
92}