mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-28 12:05:47 +08:00
2013-05-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/sys/reent.h (_ATEXIT_INIT): Define. (_ATEXIT_INIT_PTR): Likewise. (_REENT_INIT_ATEXIT): Likewise. (_REENT_INIT_ATEXIT_PTR): Likewise. (_GLOBAL_ATEXIT): Likewise. * libc/stdlib/__atexit.c (_GLOBAL_ATEXIT0): Define. (__register_exitproc): Use _GLOBAL_ATEXIT and _GLOBAL_ATEXIT0. * libc/stdlib/__call_atexit.c (__call_exitprocs): Likewise. -
This commit is contained in:
parent
c0e447afd0
commit
6bd6954bdc
@ -1,3 +1,14 @@
|
|||||||
|
2013-05-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* libc/include/sys/reent.h (_ATEXIT_INIT): Define.
|
||||||
|
(_ATEXIT_INIT_PTR): Likewise.
|
||||||
|
(_REENT_INIT_ATEXIT): Likewise.
|
||||||
|
(_REENT_INIT_ATEXIT_PTR): Likewise.
|
||||||
|
(_GLOBAL_ATEXIT): Likewise.
|
||||||
|
* libc/stdlib/__atexit.c (_GLOBAL_ATEXIT0): Define.
|
||||||
|
(__register_exitproc): Use _GLOBAL_ATEXIT and _GLOBAL_ATEXIT0.
|
||||||
|
* libc/stdlib/__call_atexit.c (__call_exitprocs): Likewise.
|
||||||
|
|
||||||
2013-05-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2013-05-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* libc/stdlib/__atexit.c (__atexit_lock): Declare.
|
* libc/stdlib/__atexit.c (__atexit_lock): Declare.
|
||||||
|
@ -85,6 +85,12 @@ struct _atexit {
|
|||||||
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
||||||
struct _on_exit_args * _on_exit_args_ptr;
|
struct _on_exit_args * _on_exit_args_ptr;
|
||||||
};
|
};
|
||||||
|
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, _NULL}
|
||||||
|
# define _ATEXIT_INIT_PTR(var) \
|
||||||
|
(var)->_next = _NULL; \
|
||||||
|
(var)->_ind = 0; \
|
||||||
|
(var)->_fns[0] = _NULL; \
|
||||||
|
(var)->_on_exit_args_ptr = _NULL
|
||||||
#else
|
#else
|
||||||
struct _atexit {
|
struct _atexit {
|
||||||
struct _atexit *_next; /* next in list */
|
struct _atexit *_next; /* next in list */
|
||||||
@ -93,8 +99,20 @@ struct _atexit {
|
|||||||
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
|
||||||
struct _on_exit_args _on_exit_args;
|
struct _on_exit_args _on_exit_args;
|
||||||
};
|
};
|
||||||
|
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}
|
||||||
|
# define _ATEXIT_INIT_PTR(var) \
|
||||||
|
(var)->_next = _NULL; \
|
||||||
|
(var)->_ind = 0; \
|
||||||
|
(var)->_fns[0] = _NULL; \
|
||||||
|
(var)->_on_exit_args._fntypes = 0; \
|
||||||
|
(var)->_on_exit_args._fnargs[0] = _NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _REENT_INIT_ATEXIT \
|
||||||
|
_NULL, _ATEXIT_INIT,
|
||||||
|
#define _REENT_INIT_ATEXIT_PTR(var, var0) \
|
||||||
|
(var)->_atexit = _NULL; _ATEXIT_INIT_PTR(var0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stdio buffers.
|
* Stdio buffers.
|
||||||
*
|
*
|
||||||
@ -425,8 +443,7 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||||||
_NULL, \
|
_NULL, \
|
||||||
_NULL, \
|
_NULL, \
|
||||||
_NULL, \
|
_NULL, \
|
||||||
_NULL, \
|
_REENT_INIT_ATEXIT \
|
||||||
{_NULL, 0, {_NULL}, _NULL}, \
|
|
||||||
{_NULL, 0, _NULL}, \
|
{_NULL, 0, _NULL}, \
|
||||||
_NULL, \
|
_NULL, \
|
||||||
_NULL, \
|
_NULL, \
|
||||||
@ -452,11 +469,7 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||||||
(var)->_localtime_buf = _NULL; \
|
(var)->_localtime_buf = _NULL; \
|
||||||
(var)->_asctime_buf = _NULL; \
|
(var)->_asctime_buf = _NULL; \
|
||||||
(var)->_sig_func = _NULL; \
|
(var)->_sig_func = _NULL; \
|
||||||
(var)->_atexit = _NULL; \
|
_REENT_INIT_ATEXIT_PTR(var, &(var)->_atexit0) \
|
||||||
(var)->_atexit0._next = _NULL; \
|
|
||||||
(var)->_atexit0._ind = 0; \
|
|
||||||
(var)->_atexit0._fns[0] = _NULL; \
|
|
||||||
(var)->_atexit0._on_exit_args_ptr = _NULL; \
|
|
||||||
(var)->__sglue._next = _NULL; \
|
(var)->__sglue._next = _NULL; \
|
||||||
(var)->__sglue._niobs = 0; \
|
(var)->__sglue._niobs = 0; \
|
||||||
(var)->__sglue._iobs = _NULL; \
|
(var)->__sglue._iobs = _NULL; \
|
||||||
@ -698,8 +711,7 @@ struct _reent
|
|||||||
{0, {0}} \
|
{0, {0}} \
|
||||||
} \
|
} \
|
||||||
}, \
|
}, \
|
||||||
_NULL, \
|
_REENT_INIT_ATEXIT \
|
||||||
{_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
|
|
||||||
_NULL, \
|
_NULL, \
|
||||||
{_NULL, 0, _NULL} \
|
{_NULL, 0, _NULL} \
|
||||||
}
|
}
|
||||||
@ -791,6 +803,8 @@ void _reclaim_reent _PARAMS ((struct _reent *));
|
|||||||
|
|
||||||
#define _GLOBAL_REENT _global_impure_ptr
|
#define _GLOBAL_REENT _global_impure_ptr
|
||||||
|
|
||||||
|
#define _GLOBAL_ATEXIT (_GLOBAL_REENT->_atexit)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,8 @@ void * malloc(size_t) _ATTRIBUTE((__weak__));
|
|||||||
extern _LOCK_RECURSIVE_T __atexit_lock;
|
extern _LOCK_RECURSIVE_T __atexit_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define _GLOBAL_ATEXIT0 (&_GLOBAL_REENT->_atexit0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Register a function to be performed at exit or on shared library unload.
|
* Register a function to be performed at exit or on shared library unload.
|
||||||
*/
|
*/
|
||||||
@ -34,9 +36,9 @@ _DEFUN (__register_exitproc,
|
|||||||
__lock_acquire_recursive(__atexit_lock);
|
__lock_acquire_recursive(__atexit_lock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p = _GLOBAL_REENT->_atexit;
|
p = _GLOBAL_ATEXIT;
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
_GLOBAL_REENT->_atexit = p = &_GLOBAL_REENT->_atexit0;
|
_GLOBAL_ATEXIT = p = _GLOBAL_ATEXIT0;
|
||||||
if (p->_ind >= _ATEXIT_SIZE)
|
if (p->_ind >= _ATEXIT_SIZE)
|
||||||
{
|
{
|
||||||
#ifndef _ATEXIT_DYNAMIC_ALLOC
|
#ifndef _ATEXIT_DYNAMIC_ALLOC
|
||||||
@ -56,8 +58,8 @@ _DEFUN (__register_exitproc,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p->_ind = 0;
|
p->_ind = 0;
|
||||||
p->_next = _GLOBAL_REENT->_atexit;
|
p->_next = _GLOBAL_ATEXIT;
|
||||||
_GLOBAL_REENT->_atexit = p;
|
_GLOBAL_ATEXIT = p;
|
||||||
#ifndef _REENT_SMALL
|
#ifndef _REENT_SMALL
|
||||||
p->_on_exit_args._fntypes = 0;
|
p->_on_exit_args._fntypes = 0;
|
||||||
p->_on_exit_args._is_cxa = 0;
|
p->_on_exit_args._is_cxa = 0;
|
||||||
|
@ -76,8 +76,8 @@ _DEFUN (__call_exitprocs, (code, d),
|
|||||||
|
|
||||||
restart:
|
restart:
|
||||||
|
|
||||||
p = _GLOBAL_REENT->_atexit;
|
p = _GLOBAL_ATEXIT;
|
||||||
lastp = &_GLOBAL_REENT->_atexit;
|
lastp = &_GLOBAL_ATEXIT;
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
#ifdef _REENT_SMALL
|
#ifdef _REENT_SMALL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user