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