-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicxxabi.cpp
85 lines (72 loc) · 1.49 KB
/
icxxabi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stddef.h>
#include <stdlib.h>
#include "icxxabi.h"
extern "C" void __cxa_pure_virtual()
{
// Do nothing or print an error message.
}
atexitFuncEntry_t __atexitFuncs[ATEXIT_FUNC_MAX];
uarch_t __atexitFuncCount = 0;
#ifdef __KERNEL
void *__dso_handle = 0;
#endif
void *__gxx_personality_v0;
int __cxa_atexit(void (*f)(void *), void *objptr, void *dso)
{
if (__atexitFuncCount >= ATEXIT_FUNC_MAX)
{
return -1;
}
__atexitFuncs[__atexitFuncCount].destructorFunc = f;
__atexitFuncs[__atexitFuncCount].objPtr = objptr;
__atexitFuncs[__atexitFuncCount].dsoHandle = dso;
__atexitFuncCount++;
return 0;
}
void __cxa_finalize(void *f)
{
signed i = __atexitFuncCount;
if (!f)
{
while (i--)
{
if (__atexitFuncs[i].destructorFunc)
{
(*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr);
}
}
return;
}
for (; i >= 0; i--)
{
if (__atexitFuncs[i].destructorFunc == f)
{
(*__atexitFuncs[i].destructorFunc)(__atexitFuncs[i].objPtr);
__atexitFuncs[i].destructorFunc = 0;
}
}
}
void *operator new(size_t size)
{
return malloc(size);
}
void *operator new[](size_t size)
{
return malloc(size);
}
void operator delete(void *p)
{
free(p);
}
void operator delete(void *p, size_t)
{
free(p);
}
void operator delete[](void *p)
{
free(p);
}
void operator delete[](void *p, size_t)
{
free(p);
}