math.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 fabs(double n) {
  13. return n < 0 ? -n : n;
  14. }
  15. float fabsf(float n) {
  16. return n < 0 ? -n : n;
  17. }
  18. double fmax(double x, double y) {
  19. return 0.0;
  20. }
  21. float fmaxf(float x, float y) {
  22. return 0.0f;
  23. }
  24. double fmin(double x, double y) {
  25. return 0.0;
  26. }
  27. float fminf(float x, float y) {
  28. return 0.0f;
  29. }
  30. double ldexp(double x, int exp) {
  31. return 0.0;
  32. }
  33. double pow(double base, double exponent) {
  34. #ifdef IRON_WASM
  35. return js_pow(base, exponent);
  36. #endif
  37. return 0.0;
  38. }
  39. float powf(float base, float exponent) {
  40. #ifdef IRON_WASM
  41. return js_pow(base, exponent);
  42. #endif
  43. return 0.0f;
  44. }
  45. double floor(double x) {
  46. #ifdef IRON_WASM
  47. return js_floor(x);
  48. #endif
  49. return 0.0;
  50. }
  51. float floorf(float x) {
  52. #ifdef IRON_WASM
  53. return js_floor(x);
  54. #endif
  55. return 0.0f;
  56. }
  57. double ceil(double x) {
  58. // #ifdef IRON_WASM
  59. // return js_ceil(x);
  60. // #endif
  61. return 0.0;
  62. }
  63. float ceilf(float x) {
  64. // #ifdef IRON_WASM
  65. // return js_ceil(x);
  66. // #endif
  67. return 0.0f;
  68. }
  69. double round(double x) {
  70. // #ifdef IRON_WASM
  71. // return js_round(x);
  72. // #endif
  73. return 0.0;
  74. }
  75. float roundf(float x) {
  76. // #ifdef IRON_WASM
  77. // return js_round(x);
  78. // #endif
  79. return 0.0f;
  80. }
  81. double sin(double x) {
  82. #ifdef IRON_WASM
  83. return js_sin(x);
  84. #endif
  85. return 0.0;
  86. }
  87. float sinf(float x) {
  88. #ifdef IRON_WASM
  89. return js_sin(x);
  90. #endif
  91. return 0.0f;
  92. }
  93. float asinf(float x) {
  94. return 0.0f;
  95. }
  96. double cos(double x) {
  97. #ifdef IRON_WASM
  98. return js_cos(x);
  99. #endif
  100. return 0.0;
  101. }
  102. float cosf(float x) {
  103. #ifdef IRON_WASM
  104. return js_cos(x);
  105. #endif
  106. return 0.0f;
  107. }
  108. double acos(double x) {
  109. return 0.0;
  110. }
  111. float acosf(float x) {
  112. return 0.0f;
  113. }
  114. double tan(double x) {
  115. #ifdef IRON_WASM
  116. return js_tan(x);
  117. #endif
  118. return 0.0;
  119. }
  120. float tanf(float x) {
  121. #ifdef IRON_WASM
  122. return js_tan(x);
  123. #endif
  124. return 0.0f;
  125. }
  126. float atanf(float x) {
  127. return 0.0f;
  128. }
  129. double atan2(double x, double y) {
  130. return 0.0;
  131. }
  132. float atan2f(float x, float y) {
  133. return 0.0f;
  134. }
  135. double log(double x) {
  136. #ifdef IRON_WASM
  137. return js_log(x);
  138. #endif
  139. return 0.0;
  140. }
  141. float logf(float x) {
  142. #ifdef IRON_WASM
  143. return js_log(x);
  144. #endif
  145. return 0.0f;
  146. }
  147. float log2f(float x) {
  148. return 0.0f;
  149. }
  150. double exp(double x) {
  151. #ifdef IRON_WASM
  152. return js_exp(x);
  153. #endif
  154. return 0.0;
  155. }
  156. float expf(float x) {
  157. #ifdef IRON_WASM
  158. return js_exp(x);
  159. #endif
  160. return 0.0;
  161. }
  162. double sqrt(double x) {
  163. #ifdef IRON_WASM
  164. return js_sqrt(x);
  165. #endif
  166. return 0.0;
  167. }
  168. float sqrtf(float x) {
  169. #ifdef IRON_WASM
  170. return js_sqrt(x);
  171. #endif
  172. return 0.0f;
  173. }
  174. double fmod(double x, double y) {
  175. return 0.0;
  176. }
  177. int isnan(float x) {
  178. return 0;
  179. }