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