mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-15 19:09:58 +08:00
0c8593cf11
* libc/include/sys/reent.h (struct _on_exit_args): Add _dso_handle and _is_cxa. (struct _atexit): Add _next when _REENT_SMALL. (struct _reent): Add _atexit0 when _REENT_SMALL. (_REENT_INIT_PTR): Adjust. * libc/stdlib/Makefile.am (GENERAL_SOURCES): Add __atexit.c and __call_exit.c. (EXTENDED_SOURCES): Add cxa_atexit.c and cxa_finalize.c. * libc/stdlib/Makefile.in: Regenerate. * libc/stdlib/__atexit.c: New file. * libc/stdlib/__call_atexit.c: New file. * libc/stdlib/atexit.h: Remove old definitions. Add new. * libc/stdlib/atexit.c (atexit): Use __register_exitproc. * libc/stdlib/cxa_atexit.c: New file. * libc/stdlib/cxa_finalize.c: New file. * libc/stdlib/exit.c (exit): Use __call_exitprocs. * libc/stdlib/on_exit.c (on_exit): Use __register_exitproc. 2004-09-09 Jeff Johnston <jjohnstn@redhat.com> * libc/reent/reent.c [_REENT_SMALL]: Fix reference to _on_exit_args_ptr.
67 lines
1.7 KiB
C
67 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 1990 Regents of the University of California.
|
|
* All rights reserved.
|
|
*
|
|
* %sccs.include.redist.c%
|
|
*/
|
|
|
|
/*
|
|
FUNCTION
|
|
<<atexit>>---request execution of functions at program exit
|
|
|
|
INDEX
|
|
atexit
|
|
|
|
ANSI_SYNOPSIS
|
|
#include <stdlib.h>
|
|
int atexit (void (*<[function]>)(void));
|
|
|
|
TRAD_SYNOPSIS
|
|
#include <stdlib.h>
|
|
int atexit ((<[function]>)
|
|
void (*<[function]>)();
|
|
|
|
DESCRIPTION
|
|
You can use <<atexit>> to enroll functions in a list of functions that
|
|
will be called when your program terminates normally. The argument is
|
|
a pointer to a user-defined function (which must not require arguments and
|
|
must not return a result).
|
|
|
|
The functions are kept in a LIFO stack; that is, the last function
|
|
enrolled by <<atexit>> will be the first to execute when your program
|
|
exits.
|
|
|
|
There is no built-in limit to the number of functions you can enroll
|
|
in this list; however, after every group of 32 functions is enrolled,
|
|
<<atexit>> will call <<malloc>> to get space for the next part of the
|
|
list. The initial list of 32 functions is statically allocated, so
|
|
you can always count on at least that many slots available.
|
|
|
|
RETURNS
|
|
<<atexit>> returns <<0>> if it succeeds in enrolling your function,
|
|
<<-1>> if it fails (possible only if no space was available for
|
|
<<malloc>> to extend the list of functions).
|
|
|
|
PORTABILITY
|
|
<<atexit>> is required by the ANSI standard, which also specifies that
|
|
implementations must support enrolling at least 32 functions.
|
|
|
|
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
|
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include "atexit.h"
|
|
|
|
/*
|
|
* Register a function to be performed at exit.
|
|
*/
|
|
|
|
int
|
|
_DEFUN (atexit,
|
|
(fn),
|
|
_VOID _EXFUN ((*fn), (_VOID)))
|
|
{
|
|
return __register_exitproc (__et_atexit, fn, NULL, NULL);
|
|
}
|