-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a recipe for emscripten event loop
Use recipe_emscript in emscripten build
- Loading branch information
Showing
7 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "common.h" | ||
|
||
struct sim_state; | ||
|
||
int recipe_emscript(struct sim_state *s) | ||
{ | ||
(void)s; | ||
fatal(0, "emscripten recipe not applicable in this build"); | ||
return -1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "emscripten.h" | ||
#include "sim.h" | ||
|
||
struct emscripten_wrap { | ||
struct sim_state *s; | ||
const struct run_ops *ops; | ||
void **run_data; | ||
void *ops_data; | ||
int rc; | ||
}; | ||
|
||
static void emscripten_wrap_step(void *data_) | ||
{ | ||
struct emscripten_wrap *d = data_; | ||
d->rc = interp_run_sim_block(d->s, d->ops, d->run_data, d->ops_data); | ||
} | ||
|
||
static int emscripten_setup(struct sim_state *s, const struct run_ops *ops, | ||
void **run_data, void *ops_data) | ||
{ | ||
struct emscripten_wrap data = { | ||
.s = s, | ||
.ops = ops, | ||
.run_data = run_data, | ||
.ops_data = ops_data, | ||
}; | ||
|
||
emscripten_cancel_main_loop(); // In case we get called more than once | ||
emscripten_set_main_loop_arg(emscripten_wrap_step, &data, 1000, 1); | ||
|
||
return data.rc; | ||
} | ||
|
||
int recipe_emscript(struct sim_state *s) | ||
{ | ||
s->run_sim = emscripten_setup; | ||
return 0; | ||
} | ||
|