Skip to content

Commit 53f498c

Browse files
committed
[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.
1 parent 3a61dd7 commit 53f498c

File tree

7 files changed

+36
-13
lines changed

7 files changed

+36
-13
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
324324
sdk/include/ddk
325325
sdk/include/ndk
326326
sdk/include/reactos
327-
sdk/include/reactos/libs)
327+
sdk/include/reactos/libs
328+
sdk/lib/pseh/include)
328329

329330
if(ARCH STREQUAL "arm")
330331
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/arm)
@@ -341,7 +342,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
341342
add_subdirectory(sdk/include/asm)
342343

343344
if(ARCH MATCHES "64$")
344-
include(sdk/cmake/baseaddress64.cmake)
345+
include(sdk/cmake/baseaddress64.cmake)
345346
elseif(NO_ROSSYM)
346347
include(sdk/cmake/baseaddress_dwarf.cmake)
347348
elseif(MSVC)

base/setup/lib/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ if(_WINKD_)
55
endif()
66

77
include_directories(spapisup utils)
8-
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/pseh/include)
98

109
list(APPEND SOURCE
1110
spapisup/fileqsup.c

modules/rostests/apitests/compiler/ms/seh/seh.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#define leave _SEH2_LEAVE
2424
#define endtry _SEH2_END
2525
#define abnormal_termination _abnormal_termination
26-
#define GetExceptionInformation() _SEH2_GetExceptionInformation()
27-
#define GetExceptionCode() _SEH2_GetExceptionCode()
28-
#define AbnormalTermination() _SEH2_AbnormalTermination()
2926
#define gcc_volatile volatile
3027

3128
#endif

sdk/include/vcruntime/excpt.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
#include <vcruntime.h>
1010

11+
#if !defined(RC_INVOKED)
12+
#include <pseh/pseh2.h>
13+
#endif
14+
1115
#pragma pack(push,_CRT_PACKING)
1216

1317
#ifdef __cplusplus
@@ -71,16 +75,17 @@ typedef enum _EXCEPTION_DISPOSITION
7175
#endif
7276

7377
#if defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))
78+
unsigned long __cdecl _exception_code(void);
79+
void *__cdecl _exception_info(void);
80+
int __cdecl _abnormal_termination(void);
81+
#endif
82+
7483
#define GetExceptionCode _exception_code
7584
#define exception_code _exception_code
7685
#define GetExceptionInformation (struct _EXCEPTION_POINTERS *)_exception_info
7786
#define exception_info (struct _EXCEPTION_POINTERS *)_exception_info
7887
#define AbnormalTermination _abnormal_termination
7988
#define abnormal_termination _abnormal_termination
80-
unsigned long __cdecl _exception_code(void);
81-
void *__cdecl _exception_info(void);
82-
int __cdecl _abnormal_termination(void);
83-
#endif
8489

8590
#define EXCEPTION_EXECUTE_HANDLER 1
8691
#define EXCEPTION_CONTINUE_SEARCH 0

sdk/lib/pseh/i386/pseh3.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
* |-----------|
3131
*/
3232

33+
/* We need the full structure with all non-volatile */
34+
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
35+
3336
#include <stdarg.h>
3437
#include <windef.h>
3538
#include <winnt.h>
3639

37-
/* We need the full structure with all non-volatile */
38-
#define _SEH3$_FRAME_ALL_NONVOLATILES 1
3940
#include "pseh3.h"
4041
#include "pseh3_asmdef.h"
4142

sdk/lib/pseh/include/pseh/pseh2.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64)))
2727

28-
#include <excpt.h>
2928
#define _SEH2_TRY __try
3029
#define _SEH2_FINALLY __finally
3130
#define _SEH2_EXCEPT(...) __except(__VA_ARGS__)
@@ -37,6 +36,8 @@
3736
#define _SEH2_LEAVE __leave
3837
#define _SEH2_VOLATILE
3938

39+
#define __endtry
40+
4041
#elif defined(__GNUC__) && !defined(__clang__) && defined(_M_AMD64)
4142

4243
#include "pseh2_64.h"
@@ -101,6 +102,14 @@ _Pragma("GCC diagnostic pop")
101102
#define _SEH2_YIELD(x) x
102103
#define _SEH2_VOLATILE volatile
103104

105+
#ifndef __try // Conflict with GCC's STL
106+
#define __try _SEH3_TRY
107+
#define __except _SEH3_EXCEPT
108+
#define __finally _SEH3_FINALLY
109+
#define __endtry _SEH3_END
110+
#define __leave _SEH3_LEAVE
111+
#endif
112+
104113
#elif defined(__GNUC__)
105114

106115
struct _EXCEPTION_RECORD;

sdk/lib/pseh/include/pseh/pseh2_64.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,14 @@ __seh2$$begin_except__: __MINGW_ATTRIB_UNUSED;
173173
#define _SEH2_LEAVE goto __seh2$$leave_scope__
174174
#define _SEH2_YIELD(__stmt) __stmt
175175
#define _SEH2_VOLATILE volatile
176+
177+
#ifndef __try // Conflict with GCC's STL
178+
#define __try _SEH2_TRY
179+
#define __except _SEH2_EXCEPT
180+
#define __finally _SEH2_FINALLY
181+
#define __endtry _SEH2_END
182+
#define __leave goto __seh2$$leave_scope__
183+
#define _exception_info() __seh2$$exception_ptr__
184+
#define _exception_code() __seh2$$exception_code__
185+
#define _abnormal_termination() __seh2$$abnormal_termination__
186+
#endif

0 commit comments

Comments
 (0)