Skip to content

Commit

Permalink
Fix #14
Browse files Browse the repository at this point in the history
dynCall_vii is no longer supported on newer versions of Emscripten. I replaced it with my own implementation.
  • Loading branch information
nepx committed Dec 21, 2020
1 parent 6308263 commit 4265483
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libhalfix.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,15 @@
// Emscripten support code
// ========================================================================

var dynCall_vii;
var cycles, now;
function run_wrapper2() {
wrap("emscripten_init")();

now = new Date().getTime();
cycles = wrap("emscripten_get_cycles");
get_now = wrap("emscripten_get_now");
dynCall_vii = wrap("emscripten_dyncall_vii");
run = wrap("emscripten_run");

wrap("emscripten_set_fast")(_halfix.fast);
Expand Down Expand Up @@ -891,7 +894,7 @@
* @param {number} arg2 The second argument
*/
function fptr_vii(cb, cb_ptr, arg2) {
Module["dynCall_vii"](cb, cb_ptr, arg2);
dynCall_vii(cb, cb_ptr, arg2);
}
/**
* Copy a string into JavaScript
Expand Down
6 changes: 4 additions & 2 deletions makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ if (!result) result = "halfix";

if (build_type === "emscripten") {
end_flags.push("-s", "WASM=" + wasm);
end_flags.push(
"-s", "\"EXTRA_EXPORTED_RUNTIME_METHODS=['dynCall_vii']\"");
// Emscripten no longer supports dynCall, apparently.
// Should've known better than to rely on an internal, undocumented method.
//end_flags.push(
// "-s", "\"EXTRA_EXPORTED_RUNTIME_METHODS=['dynCall_vii']\"");
console.log(end_flags);
}

Expand Down
10 changes: 10 additions & 0 deletions src/emscripten/emscripten.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ EMSCRIPTEN_KEEPALIVE
double emscripten_get_cycles(void){
return (double)cpu_get_cycles();
}
EMSCRIPTEN_KEEPALIVE
double emscripten_get_now(void){
return (double)get_now();
}

void pc_set_fast(int yes);
EMSCRIPTEN_KEEPALIVE
void emscripten_set_fast(int val){
pc_set_fast(val);
}

EMSCRIPTEN_KEEPALIVE
void emscripten_dyncall_vii(void* func, void* a, int b){
// All *_cb() functions have the following signature: void (void*, int)
((void(*)(void*, int))func)(a, b);
}

// does nothing
int main()
{
Expand Down

0 comments on commit 4265483

Please sign in to comment.