1 /* 2 Copyright (c) 1990 Regents of the University of California. 3 All rights reserved. 4 */ 5 /* 6 * Common definitions for atexit-like routines 7 */ 8 9 #include <stdint.h> 10 11 enum __atexit_types 12 { 13 __et_atexit, 14 __et_onexit, 15 __et_cxa 16 }; 17 18 #ifdef _REENT_GLOBAL_ATEXIT 19 #define NEWLIB_THREAD_LOCAL_ATEXIT 20 #else 21 #define NEWLIB_THREAD_LOCAL_ATEXIT NEWLIB_THREAD_LOCAL 22 #endif 23 24 #define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */ 25 26 struct _on_exit_args { 27 void * _fnargs[_ATEXIT_SIZE]; /* user fn args */ 28 void * _dso_handle[_ATEXIT_SIZE]; 29 /* Bitmask is set if user function takes arguments. */ 30 uint32_t _fntypes; /* type of exit routine - 31 Must have at least _ATEXIT_SIZE bits */ 32 /* Bitmask is set if function was registered via __cxa_atexit. */ 33 uint32_t _is_cxa; 34 }; 35 36 struct _atexit { 37 struct _atexit *_next; /* next in list */ 38 int _ind; /* next index in this table */ 39 /* Some entries may already have been called, and will be NULL. */ 40 void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ 41 struct _on_exit_args _on_exit_args; 42 }; 43 44 extern NEWLIB_THREAD_LOCAL_ATEXIT struct _atexit _atexit0; 45 extern NEWLIB_THREAD_LOCAL_ATEXIT struct _atexit *_atexit; 46 47 void __call_exitprocs (int, void *); 48 int __register_exitproc (int, void (*fn) (void), void *, void *); 49 50