Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib/exit.c')
-rw-r--r--newlib/libc/stdlib/exit.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/newlib/libc/stdlib/exit.c b/newlib/libc/stdlib/exit.c
index fb7f73e77..54664fec5 100644
--- a/newlib/libc/stdlib/exit.c
+++ b/newlib/libc/stdlib/exit.c
@@ -61,15 +61,20 @@ _DEFUN (exit, (code),
{
register struct _atexit *p;
register int n;
+ int i = 1;
#ifdef _REENT_SMALL
- for (p = &_REENT->_atexit, n = p->_ind; --n >= 0;)
- (*p->_fns[n]) ();
+ for (p = &_REENT->_atexit, n = p->_ind-1, i = (n>=0) ? (1<<n) : 0;
+ n >= 0; --n, i >>= 1)
#else
for (p = _REENT->_atexit; p; p = p->_next)
- for (n = p->_ind; --n >= 0;)
- (*p->_fns[n]) ();
+ for (n = p->_ind - 1, i = (n >= 0) ? (1 << n) : 0; n >= 0; --n, i >>= 1)
#endif
+ if (p->_fntypes & i)
+ (*((void (*)(int, void *))p->_fns[n]))(code, p->_fnargs[n]);
+ else
+ (*p->_fns[n]) ();
+
if (_REENT->__cleanup)
(*_REENT->__cleanup) (_REENT);
_exit (code);