Skip to content

Commit be6df7f

Browse files
aheejincopybara-github
authored andcommitted
[WebAssembly] Upstream misc. EH changes (#92990)
This upstreams more recent, mostly EH changes from libcxx and libcxxabi: - `__cxa_init_primary_exception`-related changes made when updating to LLVM 18.1.2 (emscripten-core/emscripten#21638) - Removes ctype macros (emscripten-core/emscripten#20960) - Guard destructor changes with `__wasm__` (emscripten-core/emscripten#21974) NOKEYCHECK=True GitOrigin-RevId: 271eb0686b7b0f9d2e016751399b948ccbbe7925
1 parent d8ff78a commit be6df7f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

include/__exception/exception_ptr.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ struct __cxa_exception;
3838
_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
3939
void*,
4040
std::type_info*,
41-
void(
4241
# if defined(_WIN32)
43-
__thiscall
42+
void(__thiscall*)(void*)) throw();
43+
# elif defined(__wasm__)
44+
// In Wasm, a destructor returns its argument
45+
void* (*)(void*)) throw();
46+
# else
47+
void (*)(void*)) throw();
4448
# endif
45-
*)(void*)) throw();
4649
}
4750

4851
} // namespace __cxxabiv1
@@ -92,8 +95,16 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
9295
using _Ep2 = __decay_t<_Ep>;
9396

9497
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
98+
# ifdef __wasm__
99+
// In Wasm, a destructor returns its argument
100+
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* {
101+
# else
95102
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
103+
# endif
96104
std::__destroy_at(static_cast<_Ep2*>(__p));
105+
# ifdef __wasm__
106+
return __p;
107+
# endif
97108
});
98109

99110
try {

include/__locale

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ public:
343343
static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
344344
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
345345
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
346-
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
346+
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
347347
# ifdef __APPLE__
348348
typedef __uint32_t mask;
349349
# elif defined(__FreeBSD__)
350350
typedef unsigned long mask;
351-
# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
351+
# elif defined(__NetBSD__)
352352
typedef unsigned short mask;
353353
# endif
354354
static const mask space = _CTYPE_S;

0 commit comments

Comments
 (0)