From d2033d0f06f6962031c51187c73e6bec8cae6e9b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 24 May 2022 12:17:19 +0900 Subject: [PATCH] [WASM] System initialization has no stack rewinding code to Asyncify --- main.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index 5cffa24cc8..e76228713f 100644 --- a/main.c +++ b/main.c @@ -32,6 +32,19 @@ static int rb_main(int argc, char **argv) +{ + RUBY_INIT_STACK; + ruby_init(); + return ruby_run_node(ruby_options(argc, argv)); +} + +#if defined(__wasm__) && !defined(__EMSCRIPTEN__) +int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv); +#define rb_main(argc, argv) rb_wasm_rt_start(rb_main, argc, argv) +#endif + +int +main(int argc, char **argv) { #ifdef RUBY_DEBUG_ENV ruby_set_debug_option(getenv("RUBY_DEBUG")); @@ -41,20 +54,5 @@ rb_main(int argc, char **argv) #endif ruby_sysinit(&argc, &argv); - { - RUBY_INIT_STACK; - ruby_init(); - return ruby_run_node(ruby_options(argc, argv)); - } -} - -int -main(int argc, char **argv) -{ -#if defined(__wasm__) && !defined(__EMSCRIPTEN__) - int rb_wasm_rt_start(int (main)(int argc, char **argv), int argc, char **argv); - return rb_wasm_rt_start(rb_main, argc, argv); -#else return rb_main(argc, argv); -#endif }