Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdlib / on_exit_args.c
blob88f9ffdbddf0a320d4ea1a78c94c04c9898fd74e
1 /*
2 * Static instance of _on_exit_args struct.
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.
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.
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.
22 #include <reent.h>
24 #ifdef _REENT_SMALL
26 static struct _on_exit_args _on_exit_args_instance = {{_NULL}, {_NULL}, 0, 0};
28 struct _on_exit_args * const __on_exit_args = &_on_exit_args_instance;
30 #endif /* def _REENT_SMALL */