Blame stdlib/exit.h

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