12a6b7db3Sskrll /* xexit.c -- Run any exit handlers, then exit.
2*f22f0ef4Schristos    Copyright (C) 1994-2022 Free Software Foundation, Inc.
32a6b7db3Sskrll 
42a6b7db3Sskrll This file is part of the libiberty library.
52a6b7db3Sskrll Libiberty is free software; you can redistribute it and/or
62a6b7db3Sskrll modify it under the terms of the GNU Library General Public
72a6b7db3Sskrll License as published by the Free Software Foundation; either
82a6b7db3Sskrll version 2 of the License, or (at your option) any later version.
92a6b7db3Sskrll 
102a6b7db3Sskrll Libiberty is distributed in the hope that it will be useful,
112a6b7db3Sskrll but WITHOUT ANY WARRANTY; without even the implied warranty of
122a6b7db3Sskrll MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
132a6b7db3Sskrll Library General Public License for more details.
142a6b7db3Sskrll 
152a6b7db3Sskrll You should have received a copy of the GNU Library General Public
162a6b7db3Sskrll License along with libiberty; see the file COPYING.LIB.  If not, write
172a6b7db3Sskrll to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
182a6b7db3Sskrll Boston, MA 02110-1301, USA.  */
192a6b7db3Sskrll 
202a6b7db3Sskrll /*
212a6b7db3Sskrll 
222a6b7db3Sskrll @deftypefn Replacement void xexit (int @var{code})
232a6b7db3Sskrll 
242a6b7db3Sskrll Terminates the program.  If any functions have been registered with
252a6b7db3Sskrll the @code{xatexit} replacement function, they will be called first.
262a6b7db3Sskrll Termination is handled via the system's normal @code{exit} call.
272a6b7db3Sskrll 
282a6b7db3Sskrll @end deftypefn
292a6b7db3Sskrll 
302a6b7db3Sskrll */
312a6b7db3Sskrll 
322a6b7db3Sskrll #ifdef HAVE_CONFIG_H
332a6b7db3Sskrll #include "config.h"
342a6b7db3Sskrll #endif
352a6b7db3Sskrll #include <stdio.h>
362a6b7db3Sskrll #ifdef HAVE_STDLIB_H
372a6b7db3Sskrll #include <stdlib.h>
382a6b7db3Sskrll #endif
392a6b7db3Sskrll #include "libiberty.h"
402a6b7db3Sskrll 
412a6b7db3Sskrll 
422a6b7db3Sskrll /* This variable is set by xatexit if it is called.  This way, xmalloc
432a6b7db3Sskrll    doesn't drag xatexit into the link.  */
442a6b7db3Sskrll void (*_xexit_cleanup) (void);
452a6b7db3Sskrll 
462a6b7db3Sskrll void
xexit(int code)472a6b7db3Sskrll xexit (int code)
482a6b7db3Sskrll {
492a6b7db3Sskrll   if (_xexit_cleanup != NULL)
502a6b7db3Sskrll     (*_xexit_cleanup) ();
512a6b7db3Sskrll   exit (code);
522a6b7db3Sskrll }
53