|
2 | 2 | // See JS_MATH setting in settings.js for details. |
3 | 3 | // |
4 | 4 |
|
5 | | -#include <emscripten.h> |
| 5 | +#include <emscripten/em_math.h> |
| 6 | +#include <emscripten/em_js.h> |
6 | 7 | #include <math.h> |
7 | 8 | #include <stdlib.h> |
8 | 9 |
|
9 | 10 | #define CALL_JS_1(cname, jsname, type) \ |
10 | | - EM_JS(type, JS_##cname, (type x), { return jsname(x) }); \ |
11 | | - type cname(type x) { return JS_##cname(x); } |
12 | | - |
13 | | -#define CALL_JS_1_TRIPLE(cname, jsname) \ |
14 | | - CALL_JS_1(cname, jsname, double) \ |
15 | | - CALL_JS_1(cname##f, jsname, float) |
16 | | - |
17 | | -CALL_JS_1_TRIPLE(cos, Math.cos) |
18 | | -CALL_JS_1_TRIPLE(sin, Math.sin) |
19 | | -CALL_JS_1_TRIPLE(tan, Math.tan) |
20 | | -CALL_JS_1_TRIPLE(acos, Math.acos) |
21 | | -CALL_JS_1_TRIPLE(asin, Math.asin) |
22 | | -CALL_JS_1_TRIPLE(atan, Math.atan) |
23 | | -CALL_JS_1_TRIPLE(exp, Math.exp) |
24 | | -CALL_JS_1_TRIPLE(log, Math.log) |
25 | | -CALL_JS_1_TRIPLE(sqrt, Math.sqrt) |
| 11 | + type cname(type x) { return (type)emscripten_math_##jsname(x); } |
| 12 | + |
| 13 | +#define CALL_JS_1_TRIPLE(name) \ |
| 14 | + CALL_JS_1(name, name, double) \ |
| 15 | + CALL_JS_1(name##f, name, float) |
| 16 | + |
| 17 | +CALL_JS_1_TRIPLE(cos) |
| 18 | +CALL_JS_1_TRIPLE(sin) |
| 19 | +CALL_JS_1_TRIPLE(tan) |
| 20 | +CALL_JS_1_TRIPLE(acos) |
| 21 | +CALL_JS_1_TRIPLE(asin) |
| 22 | +CALL_JS_1_TRIPLE(atan) |
| 23 | +CALL_JS_1_TRIPLE(exp) |
| 24 | +CALL_JS_1_TRIPLE(log) |
| 25 | +CALL_JS_1_TRIPLE(sqrt) |
26 | 26 |
|
27 | 27 | #define CALL_JS_2(cname, jsname, type) \ |
28 | | - EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \ |
29 | | - type cname(type x, type y) { return JS_##cname(x, y); } |
| 28 | + type cname(type x, type y) { return (type)emscripten_math_##jsname(x, y); } |
30 | 29 |
|
31 | | -#define CALL_JS_2_TRIPLE(cname, jsname) \ |
32 | | - CALL_JS_2(cname, jsname, double) \ |
33 | | - CALL_JS_2(cname##f, jsname, float) |
| 30 | +#define CALL_JS_2_TRIPLE(name) \ |
| 31 | + CALL_JS_2(name, name, double) \ |
| 32 | + CALL_JS_2(name##f, name, float) |
34 | 33 |
|
35 | | -CALL_JS_2_TRIPLE(atan2, Math.atan2) |
36 | | -CALL_JS_2_TRIPLE(pow, Math.pow) |
| 34 | +CALL_JS_2_TRIPLE(atan2) |
| 35 | +CALL_JS_2_TRIPLE(pow) |
37 | 36 |
|
38 | 37 | #define CALL_JS_1_IMPL(cname, type, impl) \ |
39 | 38 | EM_JS(type, JS_##cname, (type x), impl); \ |
|
0 commit comments