math.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "math.h"
  2. #ifdef IRON_WASM
  3. __attribute__((import_module("imports"), import_name("js_pow"))) float js_pow(float base, float exponent);
  4. __attribute__((import_module("imports"), import_name("js_floor"))) float js_floor(float x);
  5. __attribute__((import_module("imports"), import_name("js_sin"))) float js_sin(float x);
  6. __attribute__((import_module("imports"), import_name("js_cos"))) float js_cos(float x);
  7. __attribute__((import_module("imports"), import_name("js_tan"))) float js_tan(float x);
  8. __attribute__((import_module("imports"), import_name("js_log"))) float js_log(float x);
  9. __attribute__((import_module("imports"), import_name("js_exp"))) float js_exp(float x);
  10. __attribute__((import_module("imports"), import_name("js_sqrt"))) float js_sqrt(float x);
  11. #endif
  12. double ldexp(double x, int exp) {
  13. return 0.0;
  14. }
  15. double pow(double base, double exponent) {
  16. #ifdef IRON_WASM
  17. return js_pow(base, exponent);
  18. #endif
  19. return 0.0;
  20. }
  21. double floor(double x) {
  22. #ifdef IRON_WASM
  23. return js_floor(x);
  24. #endif
  25. return 0.0;
  26. }
  27. float floorf(float x) {
  28. #ifdef IRON_WASM
  29. return js_floor(x);
  30. #endif
  31. return 0.0f;
  32. }
  33. double sin(double x) {
  34. #ifdef IRON_WASM
  35. return js_sin(x);
  36. #endif
  37. return 0.0;
  38. }
  39. float sinf(float x) {
  40. #ifdef IRON_WASM
  41. return js_sin(x);
  42. #endif
  43. return 0.0f;
  44. }
  45. double cos(double x) {
  46. #ifdef IRON_WASM
  47. return js_cos(x);
  48. #endif
  49. return 0.0;
  50. }
  51. float cosf(float x) {
  52. #ifdef IRON_WASM
  53. return js_cos(x);
  54. #endif
  55. return 0.0f;
  56. }
  57. double tan(double x) {
  58. #ifdef IRON_WASM
  59. return js_tan(x);
  60. #endif
  61. return 0.0;
  62. }
  63. float tanf(float x) {
  64. #ifdef IRON_WASM
  65. return js_tan(x);
  66. #endif
  67. return 0.0f;
  68. }
  69. double log(double x) {
  70. #ifdef IRON_WASM
  71. return js_log(x);
  72. #endif
  73. return 0.0;
  74. }
  75. double exp(double x) {
  76. #ifdef IRON_WASM
  77. return js_exp(x);
  78. #endif
  79. return 0.0;
  80. }
  81. double sqrt(double x) {
  82. #ifdef IRON_WASM
  83. return js_sqrt(x);
  84. #endif
  85. return 0.0;
  86. }