[SDK][PSEH] Improve PSEH a bit

Add PSEH include dir globally, include pseh2.h from excpt.h and add compatibility macros to reduce hacks in 3rd-perty code.
This commit is contained in:
Timo Kreuzer 2024-11-16 21:48:13 +02:00
parent 3a61dd7fe7
commit 53f498c968
7 changed files with 36 additions and 13 deletions

View file

@ -30,12 +30,13 @@
* |-----------|
*/
/* We need the full structure with all non-volatile */
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
#include <stdarg.h>
#include <windef.h>
#include <winnt.h>
/* We need the full structure with all non-volatile */
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
#include "pseh3.h"
#include "pseh3_asmdef.h"

View file

@ -25,7 +25,6 @@
#if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64)))
#include <excpt.h>
#define _SEH2_TRY __try
#define _SEH2_FINALLY __finally
#define _SEH2_EXCEPT(...) __except(__VA_ARGS__)
@ -37,6 +36,8 @@
#define _SEH2_LEAVE __leave
#define _SEH2_VOLATILE
#define __endtry
#elif defined(__GNUC__) && !defined(__clang__) && defined(_M_AMD64)
#include "pseh2_64.h"
@ -101,6 +102,14 @@ _Pragma("GCC diagnostic pop")
#define _SEH2_YIELD(x) x
#define _SEH2_VOLATILE volatile
#ifndef __try // Conflict with GCC's STL
#define __try _SEH3_TRY
#define __except _SEH3_EXCEPT
#define __finally _SEH3_FINALLY
#define __endtry _SEH3_END
#define __leave _SEH3_LEAVE
#endif
#elif defined(__GNUC__)
struct _EXCEPTION_RECORD;

View file

@ -173,3 +173,14 @@ __seh2$$begin_except__: __MINGW_ATTRIB_UNUSED;
#define _SEH2_LEAVE goto __seh2$$leave_scope__
#define _SEH2_YIELD(__stmt) __stmt
#define _SEH2_VOLATILE volatile
#ifndef __try // Conflict with GCC's STL
#define __try _SEH2_TRY
#define __except _SEH2_EXCEPT
#define __finally _SEH2_FINALLY
#define __endtry _SEH2_END
#define __leave goto __seh2$$leave_scope__
#define _exception_info() __seh2$$exception_ptr__
#define _exception_code() __seh2$$exception_code__
#define _abnormal_termination() __seh2$$abnormal_termination__
#endif