Reactos

[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

+13 -11
-4
sdk/include/psdk/rpc.h
··· 5 5 #endif /* _INC_WINDOWS */ 6 6 #endif 7 7 8 - #if defined(__USE_PSEH2__) && !defined(RC_INVOKED) 9 - #include <pseh/pseh2.h> 10 - #endif 11 - 12 8 #ifndef __RPC_H__ 13 9 #define __RPC_H__ 14 10
+2 -5
sdk/include/reactos/wine/exception.h
··· 3 3 4 4 #include <setjmp.h> 5 5 #include <intrin.h> 6 - #ifdef __USE_PSEH2__ 7 - # include <pseh/pseh2.h> 8 - # include <pseh/excpt.h> 9 - #endif 6 + #include <excpt.h> 10 7 11 8 #ifdef __cplusplus 12 9 extern "C" { ··· 63 60 #define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation())) 64 61 #define __EXCEPT_CTX(func, ctx) _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx)) 65 62 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION) 66 - #define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER) 63 + #define __EXCEPT_ALL _SEH2_EXCEPT(1) 67 64 #define __ENDTRY _SEH2_END 68 65 #define __FINALLY(func) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); } 69 66 #define __FINALLY_CTX(func, ctx) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination(), ctx); }; _SEH2_END
+1 -1
sdk/include/vcruntime/excpt.h
··· 74 74 75 75 #endif 76 76 77 - #if defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__)) 77 + #if (defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))) && !defined(_exception_code) 78 78 unsigned long __cdecl _exception_code(void); 79 79 void *__cdecl _exception_info(void); 80 80 int __cdecl _abnormal_termination(void);
-1
sdk/lib/pseh/CMakeLists.txt
··· 57 57 # Make it clear that we are using PSEH2 58 58 if ((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR 59 59 ((CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT (ARCH STREQUAL "amd64")))) 60 - target_compile_definitions(pseh INTERFACE __USE_PSEH2__) 61 60 endif()
+10
sdk/lib/pseh/include/pseh/pseh2.h
··· 23 23 #ifndef KJK_PSEH2_H_ 24 24 #define KJK_PSEH2_H_ 25 25 26 + #define __USE_PSEH2__ 27 + 26 28 #if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64))) 27 29 28 30 #define _SEH2_TRY __try ··· 85 87 #define _SEH2_YIELD(STMT_) STMT_ 86 88 #define _SEH2_LEAVE goto __seh2_scope_end__; 87 89 #define _SEH2_VOLATILE volatile 90 + 91 + #define __try _SEH2_TRY 92 + #define __except _SEH2_EXCEPT 93 + #define __finally _SEH2_FINALLY 94 + #define __endtry _SEH2_END 95 + #define __leave _SEH2_LEAVE 96 + #define _exception_code() 0 97 + #define _exception_info() ((void*)0) 88 98 89 99 #elif defined(_USE_PSEH3) 90 100