Skip to content

Commit 0980f1b

Browse files
committed
corrected cxa.cpp
1 parent c870564 commit 0980f1b

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

src/libcxx/cxa.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1+
#include <stdint.h>
12
#include "abort_message.h"
23

34
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#dso-dtor-runtime-api
45

6+
// __int64_t
7+
typedef int64_t __guard;
8+
59
extern "C" {
6-
void __cxa_pure_virtual();
7-
void __cxa_deleted_virtual();
8-
int __cxa_guard_acquire(long long *);
9-
int __cxa_guard_release(long long *);
10-
int __cxa_guard_abort(long long *);
10+
[[noreturn, gnu::cold]] void __cxa_pure_virtual(void);
11+
[[noreturn, gnu::cold]] void __cxa_deleted_virtual(void);
12+
[[gnu::cold]] int __cxa_guard_acquire(__guard *);
13+
[[gnu::cold]] void __cxa_guard_release(__guard *);
14+
[[noreturn, gnu::cold]] void __cxa_guard_abort(__guard *);
1115
}
1216

13-
__attribute__((__cold__))
14-
void __cxa_pure_virtual() {
17+
void __cxa_pure_virtual(void) {
1518
__abort_message("__cxa_pure_virtual");
1619
}
1720

18-
__attribute__((__cold__))
19-
void __cxa_deleted_virtual() {
21+
void __cxa_deleted_virtual(void) {
2022
__abort_message("__cxa_deleted_virtual");
2123
}
2224

23-
__attribute__((__cold__))
24-
int __cxa_guard_acquire(long long *guard_object) {
25-
unsigned char const *ptr = (unsigned char const *)guard_object;
26-
if (*ptr == 0) {
25+
int __cxa_guard_acquire(__guard *guard_object) {
26+
unsigned char const *flag = (unsigned char const *)guard_object;
27+
if (*flag == 0) {
2728
// initialization not yet complete
2829
return 1;
2930
}
3031
// otherwise
3132
return 0;
3233
}
3334

34-
__attribute__((__cold__))
35-
int __cxa_guard_release(long long *guard_object) {
36-
unsigned char *ptr = (unsigned char *)guard_object;
35+
void __cxa_guard_release(__guard *guard_object) {
36+
unsigned char *flag = (unsigned char *)guard_object;
3737
// set to a non-zero value
38-
*ptr = 1;
39-
return 0;
38+
*flag = 1;
4039
}
4140

42-
__attribute__((__cold__))
43-
int __cxa_guard_abort(__attribute__((__unused__)) long long *guard_object) {
41+
void __cxa_guard_abort([[maybe_unused]] __guard *guard_object) {
4442
__abort_message("__cxa_guard_abort");
4543
}

0 commit comments

Comments
 (0)