Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,10 @@ def check_memory_setting(setting):
# MINIMAL_RUNTIME only needs callRuntimeCallbacks in certain cases, but the normal runtime
# always does.
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$callRuntimeCallbacks']
if settings.EXIT_RUNTIME or settings.USE_PTHREADS:
# Use by callMain
# TODO(sbc): have callMain use callUserCallback instead.
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$runtimeKeepalivePush', '$runtimeKeepalivePop']

if settings.EXIT_RUNTIME and not settings.STANDALONE_WASM:
# Internal function implemented in musl that calls any functions registered
Expand Down
2 changes: 2 additions & 0 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ function callMain(args) {
// that if we get here main returned zero.
var ret = 0;
#else
{{{ runtimeKeepalivePush() }}}
var ret = entryFunction(argc, argv);
{{{ runtimeKeepalivePop() }}}
#endif // STANDALONE_WASM

#if BENCHMARK
Expand Down
17 changes: 11 additions & 6 deletions tests/browser/test_glfw3.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ assert(glfwSet##Function(Value) == Value); /* The previously set callback */
assert(glfwSet##Function(Window, Value) == NULL); /* Default value (no callback was set) */ \
assert(glfwSet##Function(Window, Value) == Value); /* The previously set callback */

int main()
{
static int exited = 0;

__attribute__((destructor))
void onExit() {
exited = 1;
}

int main() {
GLFWwindow *window;
char *userptr = "userptr";

Expand Down Expand Up @@ -121,9 +127,11 @@ int main()
glfwSetWindowSize(window, 1, 1);
glfwGetWindowSize(window, &w, &h);
assert(w == 1 && h == 1);
assert(exited == 0);

glfwSetWindowSize(window, 640, 480);
glfwGetFramebufferSize(window, &w, &h);
assert(exited == 0);

// XXX: not implemented
// glfwIconifyWindow(window);
Expand Down Expand Up @@ -210,9 +218,6 @@ int main()
#endif

glfwTerminate();

#ifdef REPORT_RESULT
REPORT_RESULT(1);
#endif
printf("done\n");
return 0;
}
2 changes: 1 addition & 1 deletion tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ def in_html(expected):
def test_glfw3(self, args):
for opts in [[], ['-sLEGACY_GL_EMULATION'], ['-Os', '--closure=1']]:
print(opts)
self.btest(test_file('browser/test_glfw3.c'), args=['-sUSE_GLFW=3', '-lglfw', '-lGL'] + args + opts, expected='1')
self.btest_exit(test_file('browser/test_glfw3.c'), args=['-sUSE_GLFW=3', '-lglfw', '-lGL'] + args + opts)

@requires_graphics_hardware
def test_glfw_events(self):
Expand Down