From 9f0ba583d6ed8ed830cc2871d91d3339d36d36d7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 24 Apr 2011 19:44:02 -0700 Subject: [PATCH] support for __cxa_atexit argument --- src/library.js | 4 ++-- src/preamble.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/library.js b/src/library.js index c7fe551bf..b21062886 100644 --- a/src/library.js +++ b/src/library.js @@ -514,8 +514,8 @@ var Library = { throw 'exit(' + status + ') called, at ' + new Error().stack; }, - atexit: function(func) { - __ATEXIT__.push(func); + atexit: function(func, arg) { + __ATEXIT__.push({ func: func, arg: arg }); }, __cxa_atexit: 'atexit', diff --git a/src/preamble.js b/src/preamble.js index 0232ff207..44f5c876f 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -287,11 +287,12 @@ function __initializeRuntime__() { function __shutdownRuntime__() { while( __ATEXIT__.length > 0) { - var func = __ATEXIT__.pop(); + var atexit = __ATEXIT__.pop(); + var func = atexit.func; if (typeof func === 'number') { func = FUNCTION_TABLE[func]; } - func(); + func(atexit.arg); } }