source: trunk/libs/newlib/src/newlib/libc/stdlib/on_exit_args.c @ 567

Last change on this file since 567 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/*
2 * Static instance of _on_exit_args struct.
3 *
4 * When _REENT_SMALL is used, _atexit struct only contains a pointer to
5 * _on_exit_args struct, so this was always allocated with malloc() - even for
6 * the first 32 calls of atexit()-like functions, which are guaranteed to
7 * succeed, but could fail because of "out of memory" error. This is even worse
8 * when _ATEXIT_DYNAMIC_ALLOC is _NOT_ defined, in which case malloc() is not
9 * used by internals of atexit()-like functions. In such configuration all calls
10 * to the functions that need _on_exit_args struct (on_exit() and
11 * __cxa_atexit()) would fail.
12 *
13 * Thats why a static instance of _on_exit_args struct is provided for
14 * _REENT_SMALL configuration. This way the first 32 calls to atexit()-like
15 * functions don't need malloc() and will always succeed.
16 *
17 * Because this struct is not needed for "normal" atexit(), it is used as a weak
18 * reference in __register_exitproc(), but any use of on_exit() or
19 * __cxa_atexit() will force it to be linked.
20 */
21
22#include <reent.h>
23
24#ifdef _REENT_SMALL
25
26static struct _on_exit_args _on_exit_args_instance = {{_NULL}, {_NULL}, 0, 0};
27
28struct _on_exit_args * const __on_exit_args = &_on_exit_args_instance;
29
30#endif  /* def _REENT_SMALL */
Note: See TracBrowser for help on using the repository browser.