Skip to content

Commit

Permalink
Remove unnecessary functions from JSMATH. NFC
Browse files Browse the repository at this point in the history
See the comments at the top of `emscripten/js_math.h` for why JS
versions of these functions are not needed.

As a followup I plan to map `jsmath.c` functions to `em_math.h`
functions instead of using EM_JS here.

See emscripten-core#19284
  • Loading branch information
sbc100 committed Dec 12, 2024
1 parent 1171ada commit ebb0f16
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions system/lib/jsmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ CALL_JS_1_TRIPLE(atan, Math.atan)
CALL_JS_1_TRIPLE(exp, Math.exp)
CALL_JS_1_TRIPLE(log, Math.log)
CALL_JS_1_TRIPLE(sqrt, Math.sqrt)
CALL_JS_1_TRIPLE(fabs, Math.abs)
CALL_JS_1_TRIPLE(ceil, Math.ceil)
CALL_JS_1_TRIPLE(floor, Math.floor)

#define CALL_JS_2(cname, jsname, type, casttype) \
EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \
Expand All @@ -46,15 +43,9 @@ CALL_JS_2_TRIPLE(pow, Math.pow)
CALL_JS_1_IMPL(cname, double, double, impl) \
CALL_JS_1_IMPL(cname##f, float, float, impl)

CALL_JS_1_IMPL_TRIPLE(round, {
return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5);
})
CALL_JS_1_IMPL_TRIPLE(rint, {
function round(x) {
return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5);
}
return (x - Math.floor(x) != .5) ? round(x) : round(x / 2) * 2;
})

double nearbyint(double x) { return rint(x); }
float nearbyintf(float x) { return rintf(x); }

0 comments on commit ebb0f16

Please sign in to comment.