@@ -54,13 +54,13 @@ __attribute__((constructor)) void __syscall_init_umask(void) {
5454#define EM_JS_MACROS (ret , func_name , args , body ...) \
5555 EM_JS(ret, func_name, args, body)
5656
57- EM_JS_MACROS ( void , _emscripten_promising_main_js , ( void ), {
58- // Define FS.createAsyncInputDevice(), This is quite similar to
59- // FS.createDevice() defined here:
60- // https://github.com/emscripten-core/emscripten/blob/4.0.11/src/lib/libfs.js?plain=1#L1642
61- // but instead of returning one byte at a time , the input() function should
62- // return a Uint8Array. This makes the handler code simpler, the
63- // `createAsyncInputDevice` simpler, and everything faster.
57+ // Define FS.createAsyncInputDevice( ), This is quite similar to
58+ // FS.createDevice() defined here:
59+ // https://github.com/emscripten-core/emscripten/blob/4.0.11/src/lib/libfs.js?plain=1#L1642
60+ // but instead of returning one byte at a time, the input() function should
61+ // return a Uint8Array. This makes the handler code simpler , the
62+ // `createAsyncInputDevice` simpler, and everything faster.
63+ EM_JS_MACROS ( void , __fs_init_async_input_device_js , ( void ), {
6464 FS .createAsyncInputDevice = function (parent , name , input ) {
6565 parent = typeof parent == 'string' ? parent : FS .getPath (parent );
6666 var path = PATH .join2 (parent , name );
@@ -103,44 +103,14 @@ EM_JS_MACROS(void, _emscripten_promising_main_js, (void), {
103103 FS .registerDevice (dev , ops );
104104 return FS .mkdev (path , mode , dev );
105105 };
106- if (!WebAssembly .promising ) {
107- // No stack switching support =(
108- return ;
109- }
110- const origResolveGlobalSymbol = resolveGlobalSymbol ;
111- if (ENVIRONMENT_IS_NODE && !Module .onExit ) {
112- Module .onExit = (code ) = > process .exit (code );
113- }
114- // * wrap the main symbol with WebAssembly.promising,
115- // * call exit_with_live_runtime() to prevent emscripten from shutting down
116- // the runtime before the promise resolves,
117- // * call onExit / process.exit ourselves, since exit_with_live_runtime()
118- // prevented Emscripten from calling it normally.
119- resolveGlobalSymbol = function (name , direct = false) {
120- const orig = origResolveGlobalSymbol (name , direct );
121- if (name == = "main" ) {
122- const main = WebAssembly .promising (orig .sym );
123- orig .sym = (...args ) = > {
124- (async () = > {
125- const ret = await main (...args );
126- Module .onExit ?.(ret );
127- })();
128- _emscripten_exit_with_live_runtime ();
129- };
130- }
131- return orig ;
132- };
133106})
134107
135- EM_JS_DEPS (_emscripten_promising_main ,
136- "$FS,$PATH,$FS_getMode,$resolveGlobalSymbol,"
137- "emscripten_exit_with_live_runtime" );
108+ EM_JS_DEPS (__fs_init_async_input_device , "$FS,$PATH,$FS_getMode" );
138109
139- __attribute__((constructor )) void _emscripten_promising_main (void ) {
140- _emscripten_promising_main_js ();
110+ __attribute__((constructor )) void __fs_init_async_input_device (void ) {
111+ __fs_init_async_input_device_js ();
141112}
142113
143-
144114#define IOVEC_T_BUF_OFFSET 0
145115#define IOVEC_T_BUF_LEN_OFFSET 4
146116#define IOVEC_T_SIZE 8
0 commit comments