1*e4b17023SJohn Marino /* xexit.c -- Run any exit handlers, then exit.
2*e4b17023SJohn Marino Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc.
3*e4b17023SJohn Marino
4*e4b17023SJohn Marino This file is part of the libiberty library.
5*e4b17023SJohn Marino Libiberty is free software; you can redistribute it and/or
6*e4b17023SJohn Marino modify it under the terms of the GNU Library General Public
7*e4b17023SJohn Marino License as published by the Free Software Foundation; either
8*e4b17023SJohn Marino version 2 of the License, or (at your option) any later version.
9*e4b17023SJohn Marino
10*e4b17023SJohn Marino Libiberty is distributed in the hope that it will be useful,
11*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
12*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13*e4b17023SJohn Marino Library General Public License for more details.
14*e4b17023SJohn Marino
15*e4b17023SJohn Marino You should have received a copy of the GNU Library General Public
16*e4b17023SJohn Marino License along with libiberty; see the file COPYING.LIB. If not, write
17*e4b17023SJohn Marino to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18*e4b17023SJohn Marino Boston, MA 02110-1301, USA. */
19*e4b17023SJohn Marino
20*e4b17023SJohn Marino /*
21*e4b17023SJohn Marino
22*e4b17023SJohn Marino @deftypefn Replacement void xexit (int @var{code})
23*e4b17023SJohn Marino
24*e4b17023SJohn Marino Terminates the program. If any functions have been registered with
25*e4b17023SJohn Marino the @code{xatexit} replacement function, they will be called first.
26*e4b17023SJohn Marino Termination is handled via the system's normal @code{exit} call.
27*e4b17023SJohn Marino
28*e4b17023SJohn Marino @end deftypefn
29*e4b17023SJohn Marino
30*e4b17023SJohn Marino */
31*e4b17023SJohn Marino
32*e4b17023SJohn Marino #ifdef HAVE_CONFIG_H
33*e4b17023SJohn Marino #include "config.h"
34*e4b17023SJohn Marino #endif
35*e4b17023SJohn Marino #include <stdio.h>
36*e4b17023SJohn Marino #ifdef HAVE_STDLIB_H
37*e4b17023SJohn Marino #include <stdlib.h>
38*e4b17023SJohn Marino #endif
39*e4b17023SJohn Marino #include "libiberty.h"
40*e4b17023SJohn Marino
41*e4b17023SJohn Marino
42*e4b17023SJohn Marino /* This variable is set by xatexit if it is called. This way, xmalloc
43*e4b17023SJohn Marino doesn't drag xatexit into the link. */
44*e4b17023SJohn Marino void (*_xexit_cleanup) (void);
45*e4b17023SJohn Marino
46*e4b17023SJohn Marino void
xexit(int code)47*e4b17023SJohn Marino xexit (int code)
48*e4b17023SJohn Marino {
49*e4b17023SJohn Marino if (_xexit_cleanup != NULL)
50*e4b17023SJohn Marino (*_xexit_cleanup) ();
51*e4b17023SJohn Marino exit (code);
52*e4b17023SJohn Marino }
53