Blame stdlib/exit.h

Packit 6c4009
/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_EXIT_H
Packit 6c4009
#define _EXIT_H 1
Packit 6c4009
Packit 6c4009
#include <stdbool.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
#include <libc-lock.h>
Packit 6c4009
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  ef_free,	/* `ef_free' MUST be zero!  */
Packit 6c4009
  ef_us,
Packit 6c4009
  ef_on,
Packit 6c4009
  ef_at,
Packit 6c4009
  ef_cxa
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
struct exit_function
Packit 6c4009
  {
Packit 6c4009
    /* `flavour' should be of type of the `enum' above but since we need
Packit 6c4009
       this element in an atomic operation we have to use `long int'.  */
Packit 6c4009
    long int flavor;
Packit 6c4009
    union
Packit 6c4009
      {
Packit 6c4009
	void (*at) (void);
Packit 6c4009
	struct
Packit 6c4009
	  {
Packit 6c4009
	    void (*fn) (int status, void *arg);
Packit 6c4009
	    void *arg;
Packit 6c4009
	  } on;
Packit 6c4009
	struct
Packit 6c4009
	  {
Packit 6c4009
	    void (*fn) (void *arg, int status);
Packit 6c4009
	    void *arg;
Packit 6c4009
	    void *dso_handle;
Packit 6c4009
	  } cxa;
Packit 6c4009
      } func;
Packit 6c4009
  };
Packit 6c4009
struct exit_function_list
Packit 6c4009
  {
Packit 6c4009
    struct exit_function_list *next;
Packit 6c4009
    size_t idx;
Packit 6c4009
    struct exit_function fns[32];
Packit 6c4009
  };
Packit 6c4009
Packit 6c4009
extern struct exit_function_list *__exit_funcs attribute_hidden;
Packit 6c4009
extern struct exit_function_list *__quick_exit_funcs attribute_hidden;
Packit 6c4009
extern uint64_t __new_exitfn_called attribute_hidden;
Packit 6c4009
Packit 6c4009
/* True once all registered atexit/at_quick_exit/onexit handlers have been
Packit 6c4009
   called */
Packit 6c4009
extern bool __exit_funcs_done attribute_hidden;
Packit 6c4009
Packit 6c4009
/* This lock protects __exit_funcs, __quick_exit_funcs, __exit_funcs_done
Packit 6c4009
   and __new_exitfn_called globals against simultaneous access from
Packit 6c4009
   atexit/on_exit/at_quick_exit in multiple threads, and also from
Packit 6c4009
   simultaneous access while another thread is in the middle of calling
Packit 6c4009
   exit handlers.  See BZ#14333.  Note: for lists, the entire list, and
Packit 6c4009
   each associated entry in the list, is protected for all access by this
Packit 6c4009
   lock.  */
Packit 6c4009
__libc_lock_define (extern, __exit_funcs_lock);
Packit 6c4009
Packit 6c4009
Packit 6c4009
extern struct exit_function *__new_exitfn (struct exit_function_list **listp)
Packit 6c4009
  attribute_hidden;
Packit 6c4009
Packit 6c4009
extern void __run_exit_handlers (int status,
Packit 6c4009
				 struct exit_function_list **listp,
Packit 6c4009
				 bool run_list_atexit, bool run_dtors)
Packit 6c4009
  attribute_hidden __attribute__ ((__noreturn__));
Packit 6c4009
Packit 6c4009
extern int __internal_atexit (void (*func) (void *), void *arg, void *d,
Packit 6c4009
			      struct exit_function_list **listp)
Packit 6c4009
  attribute_hidden;
Packit 6c4009
extern int __cxa_at_quick_exit (void (*func) (void *), void *d);
Packit 6c4009
Packit 6c4009
Packit 6c4009
#endif	/* exit.h  */