186d7f5d3SJohn Marino /* xexit.c -- Run any exit handlers, then exit.
286d7f5d3SJohn Marino Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc.
386d7f5d3SJohn Marino
486d7f5d3SJohn Marino This file is part of the libiberty library.
586d7f5d3SJohn Marino Libiberty is free software; you can redistribute it and/or
686d7f5d3SJohn Marino modify it under the terms of the GNU Library General Public
786d7f5d3SJohn Marino License as published by the Free Software Foundation; either
886d7f5d3SJohn Marino version 2 of the License, or (at your option) any later version.
986d7f5d3SJohn Marino
1086d7f5d3SJohn Marino Libiberty is distributed in the hope that it will be useful,
1186d7f5d3SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
1286d7f5d3SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1386d7f5d3SJohn Marino Library General Public License for more details.
1486d7f5d3SJohn Marino
1586d7f5d3SJohn Marino You should have received a copy of the GNU Library General Public
1686d7f5d3SJohn Marino License along with libiberty; see the file COPYING.LIB. If not, write
1786d7f5d3SJohn Marino to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
1886d7f5d3SJohn Marino Boston, MA 02110-1301, USA. */
1986d7f5d3SJohn Marino
2086d7f5d3SJohn Marino /*
2186d7f5d3SJohn Marino
2286d7f5d3SJohn Marino @deftypefn Replacement void xexit (int @var{code})
2386d7f5d3SJohn Marino
2486d7f5d3SJohn Marino Terminates the program. If any functions have been registered with
2586d7f5d3SJohn Marino the @code{xatexit} replacement function, they will be called first.
2686d7f5d3SJohn Marino Termination is handled via the system's normal @code{exit} call.
2786d7f5d3SJohn Marino
2886d7f5d3SJohn Marino @end deftypefn
2986d7f5d3SJohn Marino
3086d7f5d3SJohn Marino */
3186d7f5d3SJohn Marino
3286d7f5d3SJohn Marino #ifdef HAVE_CONFIG_H
3386d7f5d3SJohn Marino #include "config.h"
3486d7f5d3SJohn Marino #endif
3586d7f5d3SJohn Marino #include <stdio.h>
3686d7f5d3SJohn Marino #ifdef HAVE_STDLIB_H
3786d7f5d3SJohn Marino #include <stdlib.h>
3886d7f5d3SJohn Marino #endif
3986d7f5d3SJohn Marino #include "libiberty.h"
4086d7f5d3SJohn Marino
4186d7f5d3SJohn Marino
4286d7f5d3SJohn Marino /* This variable is set by xatexit if it is called. This way, xmalloc
4386d7f5d3SJohn Marino doesn't drag xatexit into the link. */
4486d7f5d3SJohn Marino void (*_xexit_cleanup) (void);
4586d7f5d3SJohn Marino
4686d7f5d3SJohn Marino void
xexit(int code)4786d7f5d3SJohn Marino xexit (int code)
4886d7f5d3SJohn Marino {
4986d7f5d3SJohn Marino if (_xexit_cleanup != NULL)
5086d7f5d3SJohn Marino (*_xexit_cleanup) ();
5186d7f5d3SJohn Marino exit (code);
5286d7f5d3SJohn Marino }
53