File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < stdint.h>
2+ #include " abort_message.h"
3+
4+ // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor-runtime-api
5+
6+ // __int64_t
7+ typedef int64_t __guard;
8+
9+ extern " C" {
10+ [[gnu::cold]] int __cxa_guard_acquire (__guard *);
11+ [[gnu::cold]] void __cxa_guard_release (__guard *);
12+ [[noreturn, gnu::cold]] void __cxa_guard_abort (__guard *);
13+ }
14+
15+ int __cxa_guard_acquire (__guard *guard_object) {
16+ unsigned char const *flag = (unsigned char const *)guard_object;
17+ if (*flag == 0 ) {
18+ // initialization not yet complete
19+ return 1 ;
20+ }
21+ // otherwise
22+ return 0 ;
23+ }
24+
25+ void __cxa_guard_release (__guard *guard_object) {
26+ unsigned char *flag = (unsigned char *)guard_object;
27+ // set to a non-zero value
28+ *flag = 1 ;
29+ }
30+
31+ void __cxa_guard_abort ([[maybe_unused]] __guard *guard_object) {
32+ std::__abort_message (" __cxa_guard_abort" );
33+ }
You can’t perform that action at this time.
0 commit comments