sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libast / common / comp / atexit.c
blob541ef0aac1e528a19e294ef6a47b3681be92909e
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 #pragma prototyped
25 * ANSI C atexit()
26 * arrange for func to be called LIFO on exit()
29 #include <ast.h>
31 #if _lib_atexit
33 NoN(atexit)
35 #else
37 #if _lib_onexit || _lib_on_exit
39 #if !_lib_onexit
40 #define onexit on_exit
41 #endif
43 extern int onexit(void(*)(void));
45 int
46 atexit(void (*func)(void))
48 return(onexit(func));
51 #else
53 struct list
55 struct list* next;
56 void (*func)(void);
59 static struct list* funclist;
61 extern void _exit(int);
63 int
64 atexit(void (*func)(void))
66 register struct list* p;
68 if (!(p = newof(0, struct list, 1, 0))) return(-1);
69 p->func = func;
70 p->next = funclist;
71 funclist = p;
72 return(0);
75 void
76 _ast_atexit(void)
78 register struct list* p;
80 while (p = funclist)
82 funclist = p->next;
83 (*p->func)();
87 #if _std_cleanup
89 #if _lib__cleanup
90 extern void _cleanup(void);
91 #endif
93 void
94 exit(int code)
96 _ast_atexit();
97 #if _lib__cleanup
98 _cleanup();
99 #endif
100 _exit(code);
103 #else
105 void
106 _cleanup(void)
108 _ast_atexit();
111 #endif
113 #endif
115 #endif