File tree 4 files changed +27
-3
lines changed
libcxx/include/__exception
4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,13 @@ struct __cxa_exception;
36
36
_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception (
37
37
void *,
38
38
std::type_info*,
39
- void (
40
39
# if defined(_WIN32)
41
- __thiscall
40
+ void (__thiscall*)(void *)) throw();
41
+ # elif defined(__USING_WASM_EXCEPTIONS__)
42
+ void * (*)(void *)) throw ();
43
+ # else
44
+ void (*)(void *)) throw();
42
45
# endif
43
- *)(void *)) throw();
44
46
}
45
47
46
48
} // namespace __cxxabiv1
@@ -88,8 +90,15 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
88
90
using _Ep2 = __decay_t <_Ep>;
89
91
90
92
void * __ex = __cxxabiv1::__cxa_allocate_exception (sizeof (_Ep));
93
+ # ifdef __USING_WASM_EXCEPTIONS__
94
+ (void )__cxxabiv1::__cxa_init_primary_exception (__ex, const_cast <std::type_info*>(&typeid (_Ep)), [](void * __p) -> void * {
95
+ # else
91
96
(void )__cxxabiv1::__cxa_init_primary_exception (__ex, const_cast <std::type_info*>(&typeid (_Ep)), [](void * __p) {
97
+ # endif
92
98
std::__destroy_at (static_cast <_Ep2*>(__p));
99
+ # ifdef __USING_WASM_EXCEPTIONS__
100
+ return __p;
101
+ # endif
93
102
});
94
103
95
104
try {
Original file line number Diff line number Diff line change @@ -48,7 +48,11 @@ extern _LIBCXXABI_FUNC_VIS void
48
48
__cxa_free_exception (void *thrown_exception) throw();
49
49
// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
50
50
extern _LIBCXXABI_FUNC_VIS __cxa_exception*
51
+ #ifdef __USING_WASM_EXCEPTIONS__
52
+ __cxa_init_primary_exception (void * object, std::type_info* tinfo, void *(_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw();
53
+ #else
51
54
__cxa_init_primary_exception (void * object, std::type_info* tinfo, void (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw();
55
+ #endif
52
56
53
57
// 2.4.3 Throwing the Exception Object
54
58
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
Original file line number Diff line number Diff line change @@ -207,7 +207,12 @@ void __cxa_free_exception(void *thrown_object) throw() {
207
207
}
208
208
209
209
__cxa_exception* __cxa_init_primary_exception (void * object, std::type_info* tinfo,
210
+ #ifdef __USING_WASM_EXCEPTIONS__
211
+ // In Wasm, a destructor returns its argument
212
+ void *(_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw () {
213
+ #else
210
214
void (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw () {
215
+ #endif
211
216
__cxa_exception* exception_header = cxa_exception_from_thrown_object (object);
212
217
exception_header->referenceCount = 0 ;
213
218
exception_header->unexpectedHandler = std::get_unexpected ();
Original file line number Diff line number Diff line change @@ -1619,6 +1619,12 @@ class libcxx(NoExceptLibrary, MTLibrary):
1619
1619
'libdispatch.cpp' ,
1620
1620
]
1621
1621
1622
+ def get_cflags (self ):
1623
+ cflags = super ().get_cflags ()
1624
+ if self .eh_mode == Exceptions .WASM :
1625
+ cflags .append ('-D__USING_WASM_EXCEPTIONS__' )
1626
+ return cflags
1627
+
1622
1628
1623
1629
class libunwind (NoExceptLibrary , MTLibrary ):
1624
1630
name = 'libunwind'
You can’t perform that action at this time.
0 commit comments