math.rs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_family = "wasm",
  18. target_os = "unknown",
  19. not(target_env = "wasi")
  20. ),
  21. all(target_arch = "x86_64", target_os = "uefi"),
  22. all(target_arch = "xtensa", target_os = "none"),
  23. all(target_vendor = "fortanix", target_env = "sgx")
  24. ))]
  25. no_mangle! {
  26. fn acos(x: f64) -> f64;
  27. fn asin(x: f64) -> f64;
  28. fn cbrt(x: f64) -> f64;
  29. fn expm1(x: f64) -> f64;
  30. fn hypot(x: f64, y: f64) -> f64;
  31. fn tan(x: f64) -> f64;
  32. fn cos(x: f64) -> f64;
  33. fn expf(x: f32) -> f32;
  34. fn log2(x: f64) -> f64;
  35. fn log2f(x: f32) -> f32;
  36. fn log10(x: f64) -> f64;
  37. fn log10f(x: f32) -> f32;
  38. fn log(x: f64) -> f64;
  39. fn logf(x: f32) -> f32;
  40. fn fmin(x: f64, y: f64) -> f64;
  41. fn fminf(x: f32, y: f32) -> f32;
  42. fn fmax(x: f64, y: f64) -> f64;
  43. fn fmaxf(x: f32, y: f32) -> f32;
  44. fn round(x: f64) -> f64;
  45. fn roundf(x: f32) -> f32;
  46. fn sin(x: f64) -> f64;
  47. fn pow(x: f64, y: f64) -> f64;
  48. fn powf(x: f32, y: f32) -> f32;
  49. fn fmod(x: f64, y: f64) -> f64;
  50. fn fmodf(x: f32, y: f32) -> f32;
  51. fn acosf(n: f32) -> f32;
  52. fn atan2f(a: f32, b: f32) -> f32;
  53. fn atanf(n: f32) -> f32;
  54. fn coshf(n: f32) -> f32;
  55. fn expm1f(n: f32) -> f32;
  56. fn fdim(a: f64, b: f64) -> f64;
  57. fn fdimf(a: f32, b: f32) -> f32;
  58. fn log1pf(n: f32) -> f32;
  59. fn sinhf(n: f32) -> f32;
  60. fn tanhf(n: f32) -> f32;
  61. fn ldexp(f: f64, n: i32) -> f64;
  62. fn ldexpf(f: f32, n: i32) -> f32;
  63. }
  64. #[cfg(any(
  65. all(
  66. target_family = "wasm",
  67. target_os = "unknown",
  68. not(target_env = "wasi")
  69. ),
  70. all(target_arch = "xtensa", target_os = "none"),
  71. all(target_vendor = "fortanix", target_env = "sgx")
  72. ))]
  73. no_mangle! {
  74. fn atan(x: f64) -> f64;
  75. fn atan2(x: f64, y: f64) -> f64;
  76. fn cosh(x: f64) -> f64;
  77. fn log1p(x: f64) -> f64;
  78. fn sinh(x: f64) -> f64;
  79. fn tanh(x: f64) -> f64;
  80. fn cosf(x: f32) -> f32;
  81. fn exp(x: f64) -> f64;
  82. fn sinf(x: f32) -> f32;
  83. fn exp2(x: f64) -> f64;
  84. fn exp2f(x: f32) -> f32;
  85. fn fma(x: f64, y: f64, z: f64) -> f64;
  86. fn fmaf(x: f32, y: f32, z: f32) -> f32;
  87. fn asinf(n: f32) -> f32;
  88. fn cbrtf(n: f32) -> f32;
  89. fn hypotf(x: f32, y: f32) -> f32;
  90. fn tanf(n: f32) -> f32;
  91. }
  92. #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
  93. no_mangle! {
  94. fn ceil(x: f64) -> f64;
  95. fn ceilf(x: f32) -> f32;
  96. fn floor(x: f64) -> f64;
  97. fn floorf(x: f32) -> f32;
  98. fn trunc(x: f64) -> f64;
  99. fn truncf(x: f32) -> f32;
  100. }
  101. // only for the thumb*-none-eabi* targets
  102. #[cfg(all(target_arch = "arm", target_os = "none"))]
  103. no_mangle! {
  104. fn fmin(x: f64, y: f64) -> f64;
  105. fn fminf(x: f32, y: f32) -> f32;
  106. fn fmax(x: f64, y: f64) -> f64;
  107. fn fmaxf(x: f32, y: f32) -> f32;
  108. // `f64 % f64`
  109. fn fmod(x: f64, y: f64) -> f64;
  110. // `f32 % f32`
  111. fn fmodf(x: f32, y: f32) -> f32;
  112. }