mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[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:
parent
12139bcde7
commit
478317abcb
5 changed files with 13 additions and 11 deletions
|
@ -5,10 +5,6 @@
|
|||
#endif /* _INC_WINDOWS */
|
||||
#endif
|
||||
|
||||
#if defined(__USE_PSEH2__) && !defined(RC_INVOKED)
|
||||
#include <pseh/pseh2.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RPC_H__
|
||||
#define __RPC_H__
|
||||
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
|
||||
#include <setjmp.h>
|
||||
#include <intrin.h>
|
||||
#ifdef __USE_PSEH2__
|
||||
# include <pseh/pseh2.h>
|
||||
# include <pseh/excpt.h>
|
||||
#endif
|
||||
#include <excpt.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -63,7 +60,7 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD
|
|||
#define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
|
||||
#define __EXCEPT_CTX(func, ctx) _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx))
|
||||
#define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
|
||||
#define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER)
|
||||
#define __EXCEPT_ALL _SEH2_EXCEPT(1)
|
||||
#define __ENDTRY _SEH2_END
|
||||
#define __FINALLY(func) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); }
|
||||
#define __FINALLY_CTX(func, ctx) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination(), ctx); }; _SEH2_END
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef enum _EXCEPTION_DISPOSITION
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))
|
||||
#if (defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))) && !defined(_exception_code)
|
||||
unsigned long __cdecl _exception_code(void);
|
||||
void *__cdecl _exception_info(void);
|
||||
int __cdecl _abnormal_termination(void);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue