Skip to content

Commit

Permalink
expose some math to UEFI envs
Browse files Browse the repository at this point in the history
  • Loading branch information
gshep committed Sep 29, 2021
1 parent 2be2bc0 commit f5064a8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod int;

#[cfg(any(
all(target_arch = "wasm32", target_os = "unknown"),
all(target_arch = "x86_64", target_os = "uefi"),
all(target_arch = "arm", target_os = "none"),
all(target_vendor = "fortanix", target_env = "sgx")
))]
Expand Down
46 changes: 29 additions & 17 deletions src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@ macro_rules! no_mangle {
target_os = "unknown",
not(target_env = "wasi")
),
all(target_arch = "x86_64", target_os = "uefi"),
all(target_vendor = "fortanix", target_env = "sgx")
))]
no_mangle! {
fn acos(x: f64) -> f64;
fn asin(x: f64) -> f64;
fn atan(x: f64) -> f64;
fn atan2(x: f64, y: f64) -> f64;
fn cbrt(x: f64) -> f64;
fn cosh(x: f64) -> f64;
fn expm1(x: f64) -> f64;
fn hypot(x: f64, y: f64) -> f64;
fn log1p(x: f64) -> f64;
fn sinh(x: f64) -> f64;
fn tan(x: f64) -> f64;
fn tanh(x: f64) -> f64;
fn cos(x: f64) -> f64;
fn cosf(x: f32) -> f32;
fn exp(x: f64) -> f64;
fn expf(x: f32) -> f32;
fn log2(x: f64) -> f64;
fn log2f(x: f32) -> f32;
Expand All @@ -52,33 +45,52 @@ no_mangle! {
fn round(x: f64) -> f64;
fn roundf(x: f32) -> f32;
fn sin(x: f64) -> f64;
fn sinf(x: f32) -> f32;
fn pow(x: f64, y: f64) -> f64;
fn powf(x: f32, y: f32) -> f32;
fn exp2(x: f64) -> f64;
fn exp2f(x: f32) -> f32;
fn fmod(x: f64, y: f64) -> f64;
fn fmodf(x: f32, y: f32) -> f32;
fn fma(x: f64, y: f64, z: f64) -> f64;
fn fmaf(x: f32, y: f32, z: f32) -> f32;
fn acosf(n: f32) -> f32;
fn asinf(n: f32) -> f32;
fn atan2f(a: f32, b: f32) -> f32;
fn atanf(n: f32) -> f32;
fn cbrtf(n: f32) -> f32;
fn coshf(n: f32) -> f32;
fn expm1f(n: f32) -> f32;
fn fdim(a: f64, b: f64) -> f64;
fn fdimf(a: f32, b: f32) -> f32;
fn hypotf(x: f32, y: f32) -> f32;
fn log1pf(n: f32) -> f32;
fn sinhf(n: f32) -> f32;
fn tanf(n: f32) -> f32;
fn tanhf(n: f32) -> f32;
fn ldexp(f: f64, n: i32) -> f64;
fn ldexpf(f: f32, n: i32) -> f32;
}

#[cfg(any(
all(
target_arch = "wasm32",
target_os = "unknown",
not(target_env = "wasi")
),
all(target_vendor = "fortanix", target_env = "sgx")
))]
no_mangle! {
fn atan(x: f64) -> f64;
fn atan2(x: f64, y: f64) -> f64;
fn cosh(x: f64) -> f64;
fn log1p(x: f64) -> f64;
fn sinh(x: f64) -> f64;
fn tanh(x: f64) -> f64;
fn cosf(x: f32) -> f32;
fn exp(x: f64) -> f64;
fn sinf(x: f32) -> f32;
fn exp2(x: f64) -> f64;
fn exp2f(x: f32) -> f32;
fn fma(x: f64, y: f64, z: f64) -> f64;
fn fmaf(x: f32, y: f32, z: f32) -> f32;
fn asinf(n: f32) -> f32;
fn cbrtf(n: f32) -> f32;
fn hypotf(x: f32, y: f32) -> f32;
fn tanf(n: f32) -> f32;
}

#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
no_mangle! {
fn ceil(x: f64) -> f64;
Expand Down

0 comments on commit f5064a8

Please sign in to comment.