OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [atexit.c] - Blame information for rev 158

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.