Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libast/vmalloc/vmexit.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1985-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* David Korn <[email protected]> *
19
* Phong Vo <[email protected]> *
20
* *
21
***********************************************************************/
22
#if defined(_UWIN) && defined(_BLD_ast)
23
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, [email protected] (05/25/93).
33
*/
34
#if _PACKAGE_ast || _lib_atexit
35
36
void _STUB_vmexit(){}
37
38
#else
39
40
#if _lib_onexit
41
42
#if __STD_C
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
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
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
102