exit.h 2.6 KB

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