-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcxa.cpp
More file actions
33 lines (27 loc) · 850 Bytes
/
cxa.cpp
File metadata and controls
33 lines (27 loc) · 850 Bytes
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
#include <stdint.h>
#include "abort_message.h"
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor-runtime-api
// __int64_t
typedef int64_t __guard;
extern "C" {
[[gnu::cold]] int __cxa_guard_acquire(__guard *);
[[gnu::cold]] void __cxa_guard_release(__guard *);
[[noreturn, gnu::cold]] void __cxa_guard_abort(__guard *);
}
int __cxa_guard_acquire(__guard *guard_object) {
unsigned char const *flag = (unsigned char const *)guard_object;
if (*flag == 0) {
// initialization not yet complete
return 1;
}
// otherwise
return 0;
}
void __cxa_guard_release(__guard *guard_object) {
unsigned char *flag = (unsigned char *)guard_object;
// set to a non-zero value
*flag = 1;
}
void __cxa_guard_abort([[maybe_unused]] __guard *guard_object) {
std::__abort_message("__cxa_guard_abort");
}