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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [stdlib/] [on_exit.c] - Blame information for rev 802

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

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

powered by: WebSVN 2.1.0

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