@@ -32,9 +32,6 @@ __gxx_personality_v0(int version,
3232}
3333#endif // !defined(__USING_WASM_EXCEPTIONS__)
3434
35- #if defined(__USING_EMSCRIPTEN_EXCEPTIONS__) || \
36- defined (__USING_WASM_EXCEPTIONS__)
37-
3835using namespace __cxxabiv1 ;
3936
4037// Some utility routines are copied from cxa_exception.cpp
@@ -50,6 +47,9 @@ thrown_object_from_cxa_exception(__cxa_exception* exception_header) {
5047 return static_cast <void *>(exception_header + 1 );
5148}
5249
50+ #if defined(__USING_EMSCRIPTEN_EXCEPTIONS__) || \
51+ defined (__USING_WASM_EXCEPTIONS__)
52+
5353// Get the exception object from the unwind pointer.
5454// Relies on the structure layout, where the unwind pointer is right in
5555// front of the user's exception object
@@ -130,3 +130,21 @@ char* __get_exception_terminate_message(void* thrown_object) {
130130}
131131
132132#endif // __USING_EMSCRIPTEN_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
133+
134+ #ifndef __USING_WASM_EXCEPTIONS__
135+
136+ namespace __cxxabiv1 {
137+
138+ void * __cxa_allocate_exception (size_t size) _NOEXCEPT {
139+ // Thrown object is prepended by exception metadata block
140+ __cxa_exception* ex = (__cxa_exception*)malloc (size + sizeof (__cxa_exception));
141+ return thrown_object_from_cxa_exception (ex);
142+ }
143+
144+ void __cxa_free_exception (void *thrown_object) _NOEXCEPT {
145+ free (cxa_exception_from_thrown_object (thrown_object));
146+ }
147+
148+ }
149+
150+ #endif // !__USING_WASM_EXCEPTIONS__
0 commit comments