xref: /netbsd-src/external/gpl3/gcc.old/dist/libiberty/xexit.c (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg /* xexit.c -- Run any exit handlers, then exit.
2*8feb0f0bSmrg    Copyright (C) 1994-2020 Free Software Foundation, Inc.
31debfc3dSmrg 
41debfc3dSmrg This file is part of the libiberty library.
51debfc3dSmrg Libiberty is free software; you can redistribute it and/or
61debfc3dSmrg modify it under the terms of the GNU Library General Public
71debfc3dSmrg License as published by the Free Software Foundation; either
81debfc3dSmrg version 2 of the License, or (at your option) any later version.
91debfc3dSmrg 
101debfc3dSmrg Libiberty is distributed in the hope that it will be useful,
111debfc3dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
121debfc3dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
131debfc3dSmrg Library General Public License for more details.
141debfc3dSmrg 
151debfc3dSmrg You should have received a copy of the GNU Library General Public
161debfc3dSmrg License along with libiberty; see the file COPYING.LIB.  If not, write
171debfc3dSmrg to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
181debfc3dSmrg Boston, MA 02110-1301, USA.  */
191debfc3dSmrg 
201debfc3dSmrg /*
211debfc3dSmrg 
221debfc3dSmrg @deftypefn Replacement void xexit (int @var{code})
231debfc3dSmrg 
241debfc3dSmrg Terminates the program.  If any functions have been registered with
251debfc3dSmrg the @code{xatexit} replacement function, they will be called first.
261debfc3dSmrg Termination is handled via the system's normal @code{exit} call.
271debfc3dSmrg 
281debfc3dSmrg @end deftypefn
291debfc3dSmrg 
301debfc3dSmrg */
311debfc3dSmrg 
321debfc3dSmrg #ifdef HAVE_CONFIG_H
331debfc3dSmrg #include "config.h"
341debfc3dSmrg #endif
351debfc3dSmrg #include <stdio.h>
361debfc3dSmrg #ifdef HAVE_STDLIB_H
371debfc3dSmrg #include <stdlib.h>
381debfc3dSmrg #endif
391debfc3dSmrg #include "libiberty.h"
401debfc3dSmrg 
411debfc3dSmrg 
421debfc3dSmrg /* This variable is set by xatexit if it is called.  This way, xmalloc
431debfc3dSmrg    doesn't drag xatexit into the link.  */
441debfc3dSmrg void (*_xexit_cleanup) (void);
451debfc3dSmrg 
461debfc3dSmrg void
xexit(int code)471debfc3dSmrg xexit (int code)
481debfc3dSmrg {
491debfc3dSmrg   if (_xexit_cleanup != NULL)
501debfc3dSmrg     (*_xexit_cleanup) ();
511debfc3dSmrg   exit (code);
521debfc3dSmrg }
53