From 3f4515c64e2a653602b9d675e08036fb690bde21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 7 Feb 2019 17:01:55 +0200 Subject: [PATCH] Optimize C runtime exit() function: in MINIMAL_RUNTIME exit will throw --- src/library.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/library.js b/src/library.js index 08a3722c905c0..f56507a41ac3f 100644 --- a/src/library.js +++ b/src/library.js @@ -271,12 +271,22 @@ LibraryManager.library = { __execvpe: 'execl', fexecve: 'execl', - _exit: function(status) { + exit: function(status) { +#if MINIMAL_RUNTIME + throw 'exit(' + status + ')'; +#else // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html exit(status); +#endif }, + _exit__sig: 'vi', + _exit: 'exit', + + _Exit__sig: 'vi', + _Exit: 'exit', + fork__deps: ['__setErrNo'], fork: function() { // pid_t fork(void); @@ -826,15 +836,6 @@ LibraryManager.library = { abs: 'Math_abs', labs: 'Math_abs', - exit__deps: ['_exit'], - exit: function(status) { - __exit(status); - }, - _Exit__deps: ['exit'], - _Exit: function(status) { - __exit(status); - }, - _ZSt9terminatev__deps: ['exit'], _ZSt9terminatev: function() { _exit(-1234);