mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
* stdlib/Makefile (routines): Add quick_exit, at_quick_exit, and
cxa_at_quick_exit. (static-only-routines): Add at_quick_exit. * stdlib/Versions: Export quick_exit and __cxa_at_quick_exit for GLIBC_2.10. * stdlib/quick_exit.c: New file. * stdlib/at_quick_exit.c: New file. * stdlib/cxa_at_quick_exit.c: New file. * stdlib/cxa_atexit.c (__cxa_atexit): Move body to new function. Call it appropriately. (__internal_atexit): New function. (__new_exitfn): Now takes parameter to point to the list to use. * stdlib/cxa_finalize.c: Remove quick_exit handlers, don't call them. * stdlib/exit.c (__run_exit_handlers): New function. Split from... (exit): ...here. Just call __run_exit_handlers appropriately. * stdlib/exit.h: Declare __quick_exit_funcs, __run_exit_handlers, __internal_atexit, __cxa_at_quick_exit. Adjust __new_exitfn. * stdlib/on_exit.c: Adjust call to __new_exitfn. * stdlib/stdlib.h: Declare at_quick_exit and quick_exit.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 1991,95,96,97,99,2001,2002,2005 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991,95,96,97,99,2001,2002,2005,2009
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -30,20 +31,22 @@ DEFINE_HOOK (__libc_atexit, (void))
|
||||
in the reverse of the order in which they were registered
|
||||
perform stdio cleanup, and terminate program execution with STATUS. */
|
||||
void
|
||||
exit (int status)
|
||||
attribute_hidden
|
||||
__run_exit_handlers (int status, struct exit_function_list **listp,
|
||||
bool run_list_atexit)
|
||||
{
|
||||
/* We do it this way to handle recursive calls to exit () made by
|
||||
the functions registered with `atexit' and `on_exit'. We call
|
||||
everyone on the list and use the status value in the last
|
||||
exit (). */
|
||||
while (__exit_funcs != NULL)
|
||||
while (*listp != NULL)
|
||||
{
|
||||
struct exit_function_list *old;
|
||||
struct exit_function_list *cur = *listp;
|
||||
|
||||
while (__exit_funcs->idx > 0)
|
||||
while (cur->idx > 0)
|
||||
{
|
||||
const struct exit_function *const f =
|
||||
&__exit_funcs->fns[--__exit_funcs->idx];
|
||||
&cur->fns[--cur->idx];
|
||||
switch (f->flavor)
|
||||
{
|
||||
void (*atfct) (void);
|
||||
@ -77,16 +80,23 @@ exit (int status)
|
||||
}
|
||||
}
|
||||
|
||||
old = __exit_funcs;
|
||||
__exit_funcs = __exit_funcs->next;
|
||||
if (__exit_funcs != NULL)
|
||||
*listp = cur->next;
|
||||
if (*listp != NULL)
|
||||
/* Don't free the last element in the chain, this is the statically
|
||||
allocate element. */
|
||||
free (old);
|
||||
free (cur);
|
||||
}
|
||||
|
||||
RUN_HOOK (__libc_atexit, ());
|
||||
if (run_list_atexit)
|
||||
RUN_HOOK (__libc_atexit, ());
|
||||
|
||||
_exit (status);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
exit (int status)
|
||||
{
|
||||
__run_exit_handlers (status, __exit_funcs, true);
|
||||
}
|
||||
libc_hidden_def (exit)
|
||||
|
Reference in New Issue
Block a user