Skip to content

Commit

Permalink
Remove unnecessary functions from jsmath.c. NFC (#23143)
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 #19284
  • Loading branch information
sbc100 authored Dec 13, 2024
1 parent 3b8d3fa commit d04f14a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion system/include/emscripten/em_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
// Math.ceil -> f32.ceil and f64.ceil (ceil() and ceilf() in math.h)
// Math.clz32(x) -> i32.clz and i64.clz (call __builtin_clz() and __builtin_clzll())
// Math.floor -> f32.floor and f64.floor (floor() and floorf() in math.h)
// Math.fround -> f64.promote_f32(f32.demote_f64()) (call double d = (double)(float)someDouble;)
// Math.fround -> f64.promote_f32(f32.demote_f64()) (double d = (double)(float)someDouble;)
// Math.imul(x, y) -> i32.mul and i64.mul (directly multiply two signed integers)
// Math.min -> f32.min and f64.min (fminf() and fmin() in math.h)
// Math.max -> f32.max and f64.max (fmaxf() and fmax() in math.h)
Expand Down
6 changes: 0 additions & 6 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) \
EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \
Expand Down Expand Up @@ -55,6 +52,3 @@ CALL_JS_1_IMPL_TRIPLE(rint, {
}
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 d04f14a

Please sign in to comment.