1*4887Schin /***********************************************************************
2*4887Schin *                                                                      *
3*4887Schin *               This software is part of the ast package               *
4*4887Schin *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5*4887Schin *                      and is licensed under the                       *
6*4887Schin *                  Common Public License, Version 1.0                  *
7*4887Schin *                      by AT&T Knowledge Ventures                      *
8*4887Schin *                                                                      *
9*4887Schin *                A copy of the License is available at                 *
10*4887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
11*4887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12*4887Schin *                                                                      *
13*4887Schin *              Information and Software Systems Research               *
14*4887Schin *                            AT&T Research                             *
15*4887Schin *                           Florham Park NJ                            *
16*4887Schin *                                                                      *
17*4887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
18*4887Schin *                  David Korn <dgk@research.att.com>                   *
19*4887Schin *                   Phong Vo <kpv@research.att.com>                    *
20*4887Schin *                                                                      *
21*4887Schin ***********************************************************************/
22*4887Schin #if defined(_UWIN)
23*4887Schin 
24*4887Schin void _STUB_vmexit(){}
25*4887Schin 
26*4887Schin #else
27*4887Schin 
28*4887Schin #include	"vmhdr.h"
29*4887Schin 
30*4887Schin /*
31*4887Schin **	Any required functions for process exiting.
32*4887Schin **	Written by Kiem-Phong Vo, kpv@research.att.com (05/25/93).
33*4887Schin */
34*4887Schin #if _PACKAGE_ast || _lib_atexit
35*4887Schin 
36*4887Schin void _STUB_vmexit(){}
37*4887Schin 
38*4887Schin #else
39*4887Schin 
40*4887Schin #if _lib_onexit
41*4887Schin 
42*4887Schin #if __STD_C
43*4887Schin int atexit(void (*exitf)(void))
44*4887Schin #else
45*4887Schin int atexit(exitf)
46*4887Schin void	(*exitf)();
47*4887Schin #endif
48*4887Schin {
49*4887Schin 	return onexit(exitf);
50*4887Schin }
51*4887Schin 
52*4887Schin #else /*!_lib_onexit*/
53*4887Schin 
54*4887Schin typedef struct _exit_s
55*4887Schin {	struct _exit_s*	next;
56*4887Schin 	void(*		exitf)_ARG_((void));
57*4887Schin } Exit_t;
58*4887Schin static Exit_t*	Exit;
59*4887Schin 
60*4887Schin #if __STD_C
61*4887Schin atexit(void (*exitf)(void))
62*4887Schin #else
63*4887Schin atexit(exitf)
64*4887Schin void	(*exitf)();
65*4887Schin #endif
66*4887Schin {	Exit_t*	e;
67*4887Schin 
68*4887Schin 	if(!(e = (Exit_t*)malloc(sizeof(Exit_t))) )
69*4887Schin 		return -1;
70*4887Schin 	e->exitf = exitf;
71*4887Schin 	e->next = Exit;
72*4887Schin 	Exit = e;
73*4887Schin 	return 0;
74*4887Schin }
75*4887Schin 
76*4887Schin #if __STD_C
77*4887Schin void exit(int type)
78*4887Schin #else
79*4887Schin void exit(type)
80*4887Schin int	type;
81*4887Schin #endif
82*4887Schin {
83*4887Schin 	Exit_t*	e;
84*4887Schin 
85*4887Schin 	for(e = Exit; e; e = e->next)
86*4887Schin 		(*e->exitf)();
87*4887Schin 
88*4887Schin #if _exit_cleanup
89*4887Schin 	_cleanup();
90*4887Schin #endif
91*4887Schin 
92*4887Schin 	_exit(type);
93*4887Schin 	return type;
94*4887Schin }
95*4887Schin 
96*4887Schin #endif	/* _lib_onexit || _lib_on_exit */
97*4887Schin 
98*4887Schin #endif /*!PACKAGE_ast*/
99*4887Schin 
100*4887Schin #endif
101