math.rs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #[allow(dead_code)]
  2. #[path = "../libm/src/math/mod.rs"]
  3. mod libm;
  4. macro_rules! no_mangle {
  5. ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => {
  6. intrinsics! {
  7. $(
  8. pub extern "C" fn $fun($($iid: $ity),+) -> $oty {
  9. self::libm::$fun($($iid),+)
  10. }
  11. )+
  12. }
  13. }
  14. }
  15. #[cfg(any(
  16. all(
  17. target_arch = "wasm32",
  18. target_os = "unknown",
  19. not(target_env = "wasi")
  20. ),
  21. all(target_vendor = "fortanix", target_env = "sgx")
  22. ))]
  23. no_mangle! {
  24. fn acos(x: f64) -> f64;
  25. fn asin(x: f64) -> f64;
  26. fn atan(x: f64) -> f64;
  27. fn atan2(x: f64, y: f64) -> f64;
  28. fn cbrt(x: f64) -> f64;
  29. fn cosh(x: f64) -> f64;
  30. fn expm1(x: f64) -> f64;
  31. fn hypot(x: f64, y: f64) -> f64;
  32. fn log1p(x: f64) -> f64;
  33. fn sinh(x: f64) -> f64;
  34. fn tan(x: f64) -> f64;
  35. fn tanh(x: f64) -> f64;
  36. fn cos(x: f64) -> f64;
  37. fn cosf(x: f32) -> f32;
  38. fn exp(x: f64) -> f64;
  39. fn expf(x: f32) -> f32;
  40. fn log2(x: f64) -> f64;
  41. fn log2f(x: f32) -> f32;
  42. fn log10(x: f64) -> f64;
  43. fn log10f(x: f32) -> f32;
  44. fn log(x: f64) -> f64;
  45. fn logf(x: f32) -> f32;
  46. fn fmin(x: f64, y: f64) -> f64;
  47. fn fminf(x: f32, y: f32) -> f32;
  48. fn fmax(x: f64, y: f64) -> f64;
  49. fn fmaxf(x: f32, y: f32) -> f32;
  50. fn round(x: f64) -> f64;
  51. fn roundf(x: f32) -> f32;
  52. fn sin(x: f64) -> f64;
  53. fn sinf(x: f32) -> f32;
  54. fn pow(x: f64, y: f64) -> f64;
  55. fn powf(x: f32, y: f32) -> f32;
  56. fn exp2(x: f64) -> f64;
  57. fn exp2f(x: f32) -> f32;
  58. fn fmod(x: f64, y: f64) -> f64;
  59. fn fmodf(x: f32, y: f32) -> f32;
  60. fn fma(x: f64, y: f64, z: f64) -> f64;
  61. fn fmaf(x: f32, y: f32, z: f32) -> f32;
  62. fn acosf(n: f32) -> f32;
  63. fn asinf(n: f32) -> f32;
  64. fn atan2f(a: f32, b: f32) -> f32;
  65. fn atanf(n: f32) -> f32;
  66. fn cbrtf(n: f32) -> f32;
  67. fn coshf(n: f32) -> f32;
  68. fn expm1f(n: f32) -> f32;
  69. fn fdim(a: f64, b: f64) -> f64;
  70. fn fdimf(a: f32, b: f32) -> f32;
  71. fn hypotf(x: f32, y: f32) -> f32;
  72. fn log1pf(n: f32) -> f32;
  73. fn sinhf(n: f32) -> f32;
  74. fn tanf(n: f32) -> f32;
  75. fn tanhf(n: f32) -> f32;
  76. fn ldexp(f: f64, n: i32) -> f64;
  77. fn ldexpf(f: f32, n: i32) -> f32;
  78. }
  79. #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
  80. no_mangle! {
  81. fn ceil(x: f64) -> f64;
  82. fn ceilf(x: f32) -> f32;
  83. fn floor(x: f64) -> f64;
  84. fn floorf(x: f32) -> f32;
  85. fn trunc(x: f64) -> f64;
  86. fn truncf(x: f32) -> f32;
  87. }
  88. // only for the thumb*-none-eabi* targets
  89. #[cfg(all(target_arch = "arm", target_os = "none"))]
  90. no_mangle! {
  91. // `f64 % f64`
  92. fn fmod(x: f64, y: f64) -> f64;
  93. // `f32 % f32`
  94. fn fmodf(x: f32, y: f32) -> f32;
  95. }