[PSEH] Fix SEH compatibility macros for dummy PSEH

This is used with Clang, which does have native SEH, but it's broken and can cause the compiler to crash. Previously some code was not handling this and instead used native SEH for clang. Fix this by always using _SEH2_* macros instead of relying on __USE_PSEH2__ to be defined.

Try to improve things
This commit is contained in:
Timo Kreuzer 2024-11-28 12:25:46 +02:00
parent 12139bcde7
commit 478317abcb
5 changed files with 13 additions and 11 deletions

View file

@ -57,5 +57,4 @@ target_include_directories(pseh INTERFACE include)
# Make it clear that we are using PSEH2
if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT (ARCH STREQUAL "amd64"))))
target_compile_definitions(pseh INTERFACE __USE_PSEH2__)
endif()

View file

@ -23,6 +23,8 @@
#ifndef KJK_PSEH2_H_
#define KJK_PSEH2_H_
#define __USE_PSEH2__
#if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64)))
#define _SEH2_TRY __try
@ -86,6 +88,14 @@ _Pragma("GCC diagnostic pop")
#define _SEH2_LEAVE goto __seh2_scope_end__;
#define _SEH2_VOLATILE volatile
#define __try _SEH2_TRY
#define __except _SEH2_EXCEPT
#define __finally _SEH2_FINALLY
#define __endtry _SEH2_END
#define __leave _SEH2_LEAVE
#define _exception_code() 0
#define _exception_info() ((void*)0)
#elif defined(_USE_PSEH3)
#include "pseh3.h"