File tree Expand file tree Collapse file tree 9 files changed +73
-42
lines changed
libcxx/include/__exception Expand file tree Collapse file tree 9 files changed +73
-42
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ struct __cxa_exception;
3636_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception (
3737 void *,
3838 std::type_info*,
39- void (
39+ # if defined(__USING_WASM_EXCEPTIONS__)
40+ void *
41+ # else
42+ void
43+ # endif
44+ (
4045# if defined(_WIN32)
4146 __thiscall
4247# endif
Original file line number Diff line number Diff line change @@ -47,8 +47,12 @@ __cxa_allocate_exception(size_t thrown_size) throw();
4747extern _LIBCXXABI_FUNC_VIS void
4848__cxa_free_exception (void *thrown_exception) throw();
4949// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
50- extern _LIBCXXABI_FUNC_VIS __cxa_exception*
51- __cxa_init_primary_exception (void * object, std::type_info* tinfo, void (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw();
50+ extern _LIBCXXABI_FUNC_VIS __cxa_exception* __cxa_init_primary_exception (void * object, std::type_info* tinfo,
51+ void
52+ # ifdef __USING_WASM_EXCEPTIONS__
53+ *
54+ # endif
55+ (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw();
5256
5357// 2.4.3 Throwing the Exception Object
5458extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
Original file line number Diff line number Diff line change @@ -206,8 +206,14 @@ void __cxa_free_exception(void *thrown_object) throw() {
206206 __aligned_free_with_fallback ((void *)raw_buffer);
207207}
208208
209+ #ifdef __USING_WASM_EXCEPTIONS__
210+ __cxa_exception* __cxa_init_primary_exception (void * object, std::type_info* tinfo,
211+ void *(_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw()
212+ #else
209213__cxa_exception* __cxa_init_primary_exception (void * object, std::type_info* tinfo,
210- void (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw() {
214+ void (_LIBCXXABI_DTOR_FUNC* dest)(void *)) throw()
215+ #endif
216+ {
211217 __cxa_exception* exception_header = cxa_exception_from_thrown_object (object);
212218 exception_header->referenceCount = 0 ;
213219 exception_header->unexpectedHandler = std::get_unexpected ();
Original file line number Diff line number Diff line change 180180#endif
181181#define _LIBUNWIND_HIGHEST_DWARF_REGISTER \
182182 _LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH
183+ #elif defined(__wasm__ )
183184# else
184185# error "Unsupported architecture."
185186# endif
Original file line number Diff line number Diff line change 1515
1616#include <__libunwind_config.h>
1717
18+ #ifndef __wasm__
1819#include <stdint.h>
1920#include <stddef.h>
2021
@@ -1299,5 +1300,6 @@ enum {
12991300 UNW_LOONGARCH_F30 = 62 ,
13001301 UNW_LOONGARCH_F31 = 63 ,
13011302};
1303+ #endif
13021304
13031305#endif
Original file line number Diff line number Diff line change 11# Get sources
22
3- set (LIBUNWIND_CXX_SOURCES
4- libunwind.cpp
5- Unwind-EHABI.cpp
6- Unwind-seh.cpp
7- )
3+ if ("${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "wasm32" OR
4+ "${CMAKE_SYSTEM_PROCESSOR} " STREQUAL "wasm64" )
5+ set (LIBUNWIND_C_SOURCES
6+ Unwind-wasm.c
7+ )
8+ set (LIBUNWIND_CXX_SOURCES
9+ libunwind.cpp
10+ )
11+ else ()
12+ set (LIBUNWIND_CXX_SOURCES
13+ libunwind.cpp
14+ Unwind-EHABI.cpp
15+ Unwind-seh.cpp
16+ )
17+
18+ if (${CMAKE_SYSTEM_NAME} MATCHES "AIX" )
19+ list (APPEND LIBUNWIND_CXX_SOURCES
20+ Unwind_AIXExtras.cpp
21+ )
22+ endif ()
823
9- if ( ${CMAKE_SYSTEM_NAME} MATCHES "AIX" )
10- list ( APPEND LIBUNWIND_CXX_SOURCES
11- Unwind_AIXExtras.cpp
12- )
13- endif ( )
24+ set (LIBUNWIND_C_SOURCES
25+ UnwindLevel1.c
26+ UnwindLevel1-gcc- ext .c
27+ Unwind-sjlj.c
28+ )
1429
15- set (LIBUNWIND_C_SOURCES
16- UnwindLevel1.c
17- UnwindLevel1-gcc-ext .c
18- Unwind-sjlj.c
19- Unwind-wasm.c
20- )
21- set_source_files_properties (${LIBUNWIND_C_SOURCES}
22- PROPERTIES
23- COMPILE_FLAGS "-std=c99" )
30+ set (LIBUNWIND_ASM_SOURCES
31+ UnwindRegistersRestore.S
32+ UnwindRegistersSave.S
33+ )
2434
25- set (LIBUNWIND_ASM_SOURCES
26- UnwindRegistersRestore.S
27- UnwindRegistersSave.S
28- )
35+ set_source_files_properties ( ${LIBUNWIND_C_SOURCES}
36+ PROPERTIES
37+ COMPILE_FLAGS "-std=c99" )
38+ endif ( )
2939
3040set (LIBUNWIND_HEADERS
3141 AddressSpace.hpp
Original file line number Diff line number Diff line change 1010//
1111//===----------------------------------------------------------------------===//
1212
13+ #if __STDC_VERSION__ < 202311L
1314#include <stdbool.h>
14-
15+ #endif
1516#include "config.h"
16-
17- #ifdef __USING_WASM_EXCEPTIONS__
18-
1917#include "unwind.h"
20- #include <threads.h>
2118
2219_Unwind_Reason_Code __gxx_personality_wasm0 (int version , _Unwind_Action actions ,
2320 uint64_t exceptionClass ,
@@ -35,7 +32,12 @@ struct _Unwind_LandingPadContext {
3532
3633// Communication channel between compiler-generated user code and personality
3734// function
38- thread_local struct _Unwind_LandingPadContext __wasm_lpad_context ;
35+ #if __STDC_VERSION__ >= 202311L
36+ thread_local
37+ #else
38+ _Thread_local
39+ #endif
40+ struct _Unwind_LandingPadContext __wasm_lpad_context ;
3941
4042/// Calls to this function is in landing pads in compiler-generated user code.
4143/// In other EH schemes, stack unwinding is done by libunwind library, which
@@ -119,5 +121,3 @@ _LIBUNWIND_EXPORT uintptr_t
119121_Unwind_GetRegionStart (struct _Unwind_Context * context ) {
120122 return 0 ;
121123}
122-
123- #endif // defined(__USING_WASM_EXCEPTIONS__)
Original file line number Diff line number Diff line change 6666 #define _LIBUNWIND_EXPORT
6767 #define _LIBUNWIND_HIDDEN
6868#else
69- #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX)
70- #define _LIBUNWIND_EXPORT __declspec (dllexport)
71- #define _LIBUNWIND_HIDDEN
72- #else
73- #define _LIBUNWIND_EXPORT __attribute__ ((visibility(" default" )))
74- #define _LIBUNWIND_HIDDEN __attribute__ ((visibility(" hidden" )))
75- #endif
69+ #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) && \
70+ !defined (__wasm__)
71+ #define _LIBUNWIND_EXPORT __declspec (dllexport)
72+ #define _LIBUNWIND_HIDDEN
73+ #else
74+ #define _LIBUNWIND_EXPORT __attribute__ ((visibility(" default" )))
75+ #define _LIBUNWIND_HIDDEN __attribute__ ((visibility(" hidden" )))
76+ #endif
7677#endif
7778
7879#define STR (a ) #a
Original file line number Diff line number Diff line change 1212#include < libunwind.h>
1313
1414#include " config.h"
15+ #ifndef __wasm__
1516#include " libunwind_ext.h"
1617
1718#include < stdlib.h>
@@ -431,6 +432,7 @@ int __unw_remove_find_dynamic_unwind_sections(
431432}
432433
433434#endif // __APPLE__
435+ #endif
434436
435437// Add logging hooks in Debug builds only
436438#ifndef NDEBUG
You can’t perform that action at this time.
0 commit comments