1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
2
3Derived from exit.h in GNU C Library.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24<http://www.gnu.org/licenses/>.  */
25
26#ifndef	_EXIT_H
27#define _EXIT_H 1
28
29#define attribute_hidden
30#define INTDEF(name)
31
32#include <stdbool.h>
33#include <stdint.h>
34
35enum
36{
37  ef_free,	/* `ef_free' MUST be zero!  */
38  ef_us,
39  ef_on,
40  ef_at,
41  ef_cxa
42};
43
44struct exit_function
45  {
46    /* `flavour' should be of type of the `enum' above but since we need
47       this element in an atomic operation we have to use `long int'.  */
48    long int flavor;
49    union
50      {
51	void (*at) (void);
52	struct
53	  {
54	    void (*fn) (int status, void *arg);
55	    void *arg;
56	  } on;
57	struct
58	  {
59	    void (*fn) (void *arg, int status);
60	    void *arg;
61	    void *dso_handle;
62	  } cxa;
63      } func;
64  };
65struct exit_function_list
66  {
67    struct exit_function_list *next;
68    size_t idx;
69    struct exit_function fns[32];
70  };
71extern struct exit_function_list *__exit_funcs attribute_hidden;
72extern struct exit_function_list *__quick_exit_funcs attribute_hidden;
73
74extern struct exit_function *__new_exitfn (struct exit_function_list **listp);
75extern uint64_t __new_exitfn_called attribute_hidden;
76
77extern void __run_exit_handlers (int status, struct exit_function_list **listp,
78				 bool run_list_atexit)
79  attribute_hidden __attribute__ ((__noreturn__));
80
81extern int __internal_atexit (void (*func) (void *), void *arg, void *d,
82			      struct exit_function_list **listp)
83  attribute_hidden;
84extern int __cxa_at_quick_exit (void (*func) (void *), void *d);
85
86extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
87extern int __cxa_atexit_internal (void (*func) (void *), void *arg, void *d)
88     attribute_hidden;
89
90extern void __cxa_finalize (void *d);
91
92#endif	/* exit.h  */
93