source: trunk/libs/newlib/src/newlib/libc/stdlib/atexit.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.6 KB
Line 
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8/*
9FUNCTION
10<<atexit>>---request execution of functions at program exit
11
12INDEX
13        atexit
14
15SYNOPSIS
16        #include <stdlib.h>
17        int atexit (void (*<[function]>)(void));
18
19DESCRIPTION
20You can use <<atexit>> to enroll functions in a list of functions that
21will be called when your program terminates normally.  The argument is
22a pointer to a user-defined function (which must not require arguments and
23must not return a result).
24
25The functions are kept in a LIFO stack; that is, the last function
26enrolled by <<atexit>> will be the first to execute when your program
27exits.
28
29There is no built-in limit to the number of functions you can enroll
30in this list; however, after every group of 32 functions is enrolled,
31<<atexit>> will call <<malloc>> to get space for the next part of the
32list.   The initial list of 32 functions is statically allocated, so
33you can always count on at least that many slots available.
34
35RETURNS
36<<atexit>> returns <<0>> if it succeeds in enrolling your function,
37<<-1>> if it fails (possible only if no space was available for
38<<malloc>> to extend the list of functions).
39
40PORTABILITY
41<<atexit>> is required by the ANSI standard, which also specifies that
42implementations must support enrolling at least 32 functions.
43
44Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
45<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
46*/
47
48#include <stdlib.h>
49#include "atexit.h"
50
51/*
52 * Register a function to be performed at exit.
53 */
54
55int
56atexit (void (*fn) (void))
57{
58  return __register_exitproc (__et_atexit, fn, NULL, NULL);
59}
Note: See TracBrowser for help on using the repository browser.