Subversion Repositories Kolibri OS

Rev

Rev 4872 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4866 Serge 1
/*
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
<>---request execution of functions at program exit
11
 
12
INDEX
13
	atexit
14
 
15
ANSI_SYNOPSIS
16
	#include 
17
	int atexit (void (*<[function]>)(void));
18
 
19
TRAD_SYNOPSIS
20
	#include 
21
	int atexit ((<[function]>)
22
	  void (*<[function]>)();
23
 
24
DESCRIPTION
25
You can use <> 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 <> 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
<> will call <> 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
<> returns <<0>> if it succeeds in enrolling your function,
42
<<-1>> if it fails (possible only if no space was available for
43
<> to extend the list of functions).
44
 
45
PORTABILITY
46
<> 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: <>, <>, <>,
50
<>, <>, <>, <>.
51
*/
52
 
53
#include 
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 _EXFNPTR(fn, (_VOID)))
64
{
65
  return __register_exitproc (__et_atexit, fn, NULL, NULL);
66
}