aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js3
-rw-r--r--src/postamble.js5
-rw-r--r--src/preamble.js5
3 files changed, 9 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js
index 56583c76..19b8e90f 100644
--- a/src/library.js
+++ b/src/library.js
@@ -26,7 +26,8 @@ LibraryManager.library = {
_impure_ptr: 0,
$FS__deps: ['$ERRNO_CODES', '__setErrNo', 'stdin', 'stdout', 'stderr', '_impure_ptr'],
- $FS__postset: '__ATINIT__.unshift({ func: function() { FS.ignorePermissions = false; if (!FS.init.initialized) FS.init() } });' +
+ $FS__postset: '__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });' +
+ '__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });' +
'__ATEXIT__.push({ func: function() { FS.quit() } });',
$FS: {
// The path to the current folder.
diff --git a/src/postamble.js b/src/postamble.js
index 1f4c9c04..cf863669 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -40,10 +40,9 @@ function run(args) {
Module['preRun']();
}
- initRuntime();
-
var ret = null;
if (Module['_main']) {
+ preMain();
ret = Module.callMain(args);
if (!Module['noExitRuntime']) {
exitRuntime();
@@ -60,6 +59,8 @@ Module['run'] = run;
// {{PRE_RUN_ADDITIONS}}
+initRuntime();
+
#if INVOKE_RUN
#else
addRunDependency();
diff --git a/src/preamble.js b/src/preamble.js
index 39412bc3..968571a0 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -697,12 +697,15 @@ function callRuntimeCallbacks(callbacks) {
}
var __ATINIT__ = []; // functions called during startup
+var __ATMAIN__ = []; // functions called when main() is to be run
var __ATEXIT__ = []; // functions called during shutdown
function initRuntime() {
callRuntimeCallbacks(__ATINIT__);
}
-
+function preMain() {
+ callRuntimeCallbacks(__ATMAIN__);
+}
function exitRuntime() {
callRuntimeCallbacks(__ATEXIT__);