26#if defined(_USE_NATIVE_SEH) || (defined(_MSC_VER) && !(defined(__clang__) && defined(_M_AMD64)))
29#define _SEH2_TRY __try
30#define _SEH2_FINALLY __finally
31#define _SEH2_EXCEPT(...) __except(__VA_ARGS__)
33#define _SEH2_GetExceptionInformation() (GetExceptionInformation())
34#define _SEH2_GetExceptionCode() (GetExceptionCode())
35#define _SEH2_AbnormalTermination() (AbnormalTermination())
36#define _SEH2_YIELD(STMT_) STMT_
37#define _SEH2_LEAVE __leave
40#elif defined(__GNUC__) && !defined(__clang__) && defined(_M_AMD64)
44#elif defined(_USE_DUMMY_PSEH) || defined (__arm__) || defined(_M_AMD64)
57_Pragma("GCC diagnostic push") \
58_Pragma("GCC diagnostic ignored \"-Wunused-label\"")\
60 __label__ __seh2_scope_end__;
62#define _SEH2_FINALLY \
63 __seh2_scope_end__:; \
67 __label__ __seh2_scope_end__;
69#define _SEH2_EXCEPT(...) \
70 __seh2_scope_end__:; \
72 if (_SEH2_Volatile0 || (0 && (__VA_ARGS__))) \
74 __label__ __seh2_scope_end__;
77 __seh2_scope_end__:; \
79_Pragma("GCC diagnostic pop")
81#define _SEH2_GetExceptionInformation() ((struct _EXCEPTION_POINTERS*)0)
82#define _SEH2_GetExceptionCode() _SEH2_VolatileExceptionCode
83#define _SEH2_AbnormalTermination() (0)
84#define _SEH2_YIELD(STMT_) STMT_
85#define _SEH2_LEAVE goto __seh2_scope_end__;
86#define _SEH2_VOLATILE volatile
88#elif defined(_USE_PSEH3)
93#define _SEH2_TRY _SEH3_TRY
94#define _SEH2_EXCEPT _SEH3_EXCEPT
95#define _SEH2_FINALLY _SEH3_FINALLY
96#define _SEH2_END _SEH3_END
97#define _SEH2_GetExceptionInformation() ((struct _EXCEPTION_POINTERS*)_exception_info())
98#define _SEH2_GetExceptionCode _exception_code
99#define _SEH2_AbnormalTermination _abnormal_termination
100#define _SEH2_LEAVE _SEH3_LEAVE
101#define _SEH2_YIELD(x) x
102#define _SEH2_VOLATILE volatile
104#elif defined(__GNUC__)
118typedef struct __SEH2Registration
120 struct __SEH2Registration * SER_Prev;
121 _SEH2FrameHandler_t SER_Handler;
125typedef struct __SEH2Frame
127 _SEH2Registration_t SF_Registration;
128 volatile struct __SEH2TryLevel *
volatile SF_TopTryLevel;
129 volatile unsigned long SF_Code;
133typedef struct __SEH2TryLevel
135 volatile struct __SEH2TryLevel * ST_Next;
141typedef struct __SEH2HandleTryLevel
143 _SEH2TryLevel_t SHT_Common;
144 void *
volatile SHT_Esp;
145 void *
volatile SHT_Ebp;
146 void *
volatile SHT_Ebx;
147 void *
volatile SHT_Esi;
148 void *
volatile SHT_Edi;
150_SEH2HandleTryLevel_t;
157extern __attribute__((returns_twice))
int __cdecl _SEH2EnterFrameAndHandleTrylevel(_SEH2Frame_t *,
volatile _SEH2HandleTryLevel_t *,
void *);
158extern __attribute__((returns_twice))
int __cdecl _SEH2EnterHandleTrylevel(_SEH2Frame_t *,
volatile _SEH2HandleTryLevel_t *,
void *);
167#if ((__GNUC__ >= 4) && (__GNUC_MINOR__ >= 7))
169#define __PREVENT_GCC_FROM_INLINING_SEH_FUNCTIONS() _SEH_DontInline();
171#define __PREVENT_GCC_FROM_INLINING_SEH_FUNCTIONS()
175#define __SEH_SIDE_EFFECT __asm__ __volatile__("#")
178#define __SEH_PRETEND_SIDE_EFFECT (void)0
181#define __SEH_USE_LABEL(L_) if(__SEH_VOLATILE_FALSE) goto L_;
184#define __SEH_PRETEND_USE_LABEL(L_) (void)(&&L_)
187#define __SEH_BARRIER __asm__ __volatile__("#":::"memory")
190#define __SEH_VOLATILE_ZERO ({ int zero = 0; __asm__ __volatile__("#" : "+g" (zero)); zero; })
192#define __SEH_VOLATILE_FALSE __builtin_expect(__SEH_VOLATILE_ZERO, 0)
193#define __SEH_VOLATILE_TRUE __builtin_expect(!__SEH_VOLATILE_ZERO, 1)
195#define ___SEH_STRINGIFY(X_) # X_
196#define __SEH_STRINGIFY(X_) ___SEH_STRINGIFY(X_)
198#define __SEH_EXCEPT_RET long
199#define __SEH_EXCEPT_ARGS __attribute__((unused)) _SEH2Frame_t * _SEH2FrameP, __attribute__((unused)) struct _EXCEPTION_POINTERS * _SEHExceptionInformation
200#define __SEH_EXCEPT_ARGS_ , __SEH_EXCEPT_ARGS
201#define __SEH_EXCEPT_PFN __SEH_DECLARE_EXCEPT_PFN
202#define __SEH_DECLARE_EXCEPT_PFN(NAME_) __SEH_EXCEPT_RET (__cdecl * NAME_)(__SEH_EXCEPT_ARGS)
203#define __SEH_DECLARE_EXCEPT(NAME_) __SEH_EXCEPT_RET __cdecl NAME_(__SEH_EXCEPT_ARGS)
204#define __SEH_DEFINE_EXCEPT(NAME_) __SEH_EXCEPT_RET __cdecl NAME_(__SEH_EXCEPT_ARGS)
206#define __SEH_FINALLY_RET void
207#define __SEH_FINALLY_ARGS void
208#define __SEH_FINALLY_ARGS_
209#define __SEH_FINALLY_PFN __SEH_DECLARE_FINALLY_PFN
210#define __SEH_DECLARE_FINALLY_PFN(NAME_) __SEH_FINALLY_RET (__cdecl * NAME_)(__SEH_FINALLY_ARGS)
211#define __SEH_DECLARE_FINALLY(NAME_) __SEH_FINALLY_RET __cdecl NAME_(__SEH_FINALLY_ARGS)
212#define __SEH_DEFINE_FINALLY(NAME_) __SEH_FINALLY_RET __cdecl NAME_(__SEH_FINALLY_ARGS)
214#define __SEH_RETURN_EXCEPT(R_) return (long)(R_)
215#define __SEH_RETURN_FINALLY() return
217#define __SEH_BEGIN_TRY \
219 __label__ _SEHEndTry; \
221 __SEH_PRETEND_USE_LABEL(_SEHEndTry); \
226#define __SEH_END_TRY \
232#define __SEH_SET_TRYLEVEL(TRYLEVEL_) \
234 __SEH_BARRIER; _SEH2FrameP->SF_TopTryLevel = (TRYLEVEL_); __SEH_BARRIER; \
237#define __SEH_ENTER_FRAME_AND_TRYLEVEL(TRYLEVEL_) (_SEH2EnterFrameAndTrylevel(_SEH2FrameP, (TRYLEVEL_)))
238#define __SEH_ENTER_TRYLEVEL(TRYLEVEL_) ((__SEH_SET_TRYLEVEL((TRYLEVEL_))), 0)
240#define __SEH_ENTER_FRAME_AND_HANDLE_TRYLEVEL(TRYLEVEL_, HANDLE_) _SEH2EnterFrameAndHandleTrylevel(_SEH2FrameP, (TRYLEVEL_), (HANDLE_))
241#define __SEH_ENTER_HANDLE_TRYLEVEL(TRYLEVEL_, HANDLE_) _SEH2EnterHandleTrylevel(_SEH2FrameP, (TRYLEVEL_), (HANDLE_))
243#define __SEH_ENTER_SCOPE(TRYLEVEL_) (_SEHTopTryLevel ? __SEH_ENTER_FRAME_AND_TRYLEVEL(TRYLEVEL_) : __SEH_ENTER_TRYLEVEL(TRYLEVEL_))
244#define __SEH_ENTER_HANDLE_SCOPE(TRYLEVEL_, HANDLE_) (({ __SEH_BARRIER; __asm__ __volatile__("mov %%esp, %0" : "=m" ((TRYLEVEL_)->SHT_Esp)); __SEH_BARRIER; }), (_SEHTopTryLevel ? __SEH_ENTER_FRAME_AND_HANDLE_TRYLEVEL((TRYLEVEL_), (HANDLE_)) : __SEH_ENTER_HANDLE_TRYLEVEL((TRYLEVEL_), (HANDLE_))))
246#define __SEH_LEAVE_TRYLEVEL() \
247 if(!_SEHTopTryLevel) \
249 __SEH_SET_TRYLEVEL(_SEHPrevTryLevelP); \
252#define __SEH_LEAVE_FRAME() \
253 if(_SEHTopTryLevel) \
258#define __SEH_END_SCOPE_CHAIN \
259 static __attribute__((unused)) const int _SEH2ScopeKind = 1; \
260 static __attribute__((unused)) _SEH2Frame_t * const _SEH2FrameP = 0; \
261 static __attribute__((unused)) _SEH2TryLevel_t * const _SEH2TryLevelP = 0;
263#define __SEH_BEGIN_SCOPE \
266 const int _SEHTopTryLevel = (_SEH2ScopeKind != 0); \
267 _SEH2Frame_t * const _SEHCurFrameP = _SEH2FrameP; \
268 volatile _SEH2TryLevel_t * const _SEHPrevTryLevelP = _SEH2TryLevelP; \
269 __attribute__((unused)) int _SEHAbnormalTermination; \
271 (void)_SEHTopTryLevel; \
272 (void)_SEHCurFrameP; \
273 (void)_SEHPrevTryLevelP; \
276 __label__ _SEHBeforeTry; \
277 __label__ _SEHDoTry; \
278 __label__ _SEHAfterTry; \
279 static const int _SEH2ScopeKind = 0; \
280 volatile _SEH2TryLevel_t _SEHTryLevel; \
281 volatile _SEH2HandleTryLevel_t _SEHHandleTryLevel; \
282 _SEH2Frame_t _SEH2Frame[_SEHTopTryLevel ? 1 : 0]; \
283 volatile _SEH2TryLevel_t * _SEH2TryLevelP; \
284 _SEH2Frame_t * const _SEH2FrameP = _SEHTopTryLevel ? \
285 _SEH2Frame : _SEHCurFrameP; \
287 (void)_SEH2ScopeKind; \
288 (void)_SEHTryLevel; \
289 (void)_SEHHandleTryLevel; \
291 (void)_SEH2TryLevelP; \
293 goto _SEHBeforeTry; \
297#define __SEH_END_SCOPE \
303#define __SEH_SCOPE_LOCALS \
304 __label__ _SEHBeginExcept; \
305 __label__ _SEHEndExcept; \
307 auto __SEH_DECLARE_FINALLY(_SEHFinally);
310 __PREVENT_GCC_FROM_INLINING_SEH_FUNCTIONS() \
313 __SEH_SCOPE_LOCALS; \
318#define _SEH2_FINALLY \
325 __SEH_PRETEND_USE_LABEL(_SEHBeginExcept); \
326 __SEH_PRETEND_USE_LABEL(_SEHEndExcept); \
328 _SEHTryLevel.ST_Filter = 0; \
329 _SEHTryLevel.ST_Body = &_SEHFinally; \
330 _SEHTryLevel.ST_Next = _SEHPrevTryLevelP; \
331 __SEH_ENTER_SCOPE(&_SEHTryLevel); \
332 _SEH2TryLevelP = &_SEHTryLevel; \
334 _SEHAbnormalTermination = 1; \
339 _SEHAbnormalTermination = 0; \
341 __SEH_LEAVE_TRYLEVEL(); \
344 goto _SEHEndExcept; \
348 __attribute__((noinline)) __SEH_DEFINE_FINALLY(_SEHFinally) \
350 __SEH_END_SCOPE_CHAIN; \
352 (void)_SEH2ScopeKind; \
354 (void)_SEH2TryLevelP; \
356 for(;; ({ __SEH_RETURN_FINALLY(); })) \
359#define _SEH2_EXCEPT(...) \
368 __attribute__((unused)) struct _EXCEPTION_POINTERS * volatile _SEHExceptionInformation; \
370 if(__builtin_constant_p((__VA_ARGS__)) && (__VA_ARGS__) <= 0) \
372 if((__VA_ARGS__) < 0) \
374 _SEHTryLevel.ST_Filter = (void *)-1; \
375 _SEHTryLevel.ST_Body = 0; \
379 _SEHTryLevel.ST_Filter = (void *)0; \
380 _SEHTryLevel.ST_Body = 0; \
383 _SEHTryLevel.ST_Next = _SEHPrevTryLevelP; \
384 __SEH_ENTER_SCOPE(&_SEHTryLevel); \
385 _SEH2TryLevelP = &_SEHTryLevel; \
389 if(__builtin_constant_p((__VA_ARGS__)) && (__VA_ARGS__) > 0) \
390 _SEHHandleTryLevel.SHT_Common.ST_Filter = (void *)1; \
393 __SEH_DEFINE_EXCEPT(_SEHExcept) \
395 __SEH_RETURN_EXCEPT((__VA_ARGS__)); \
398 _SEHHandleTryLevel.SHT_Common.ST_Filter = &_SEHExcept; \
401 _SEHHandleTryLevel.SHT_Common.ST_Next = _SEHPrevTryLevelP; \
402 _SEH2TryLevelP = &_SEHHandleTryLevel.SHT_Common; \
404 if(__builtin_expect(__SEH_ENTER_HANDLE_SCOPE(&_SEHHandleTryLevel, &&_SEHBeginExcept), 0)) \
405 goto _SEHBeginExcept; \
411 __attribute__((unused)) __SEH_DEFINE_FINALLY(_SEHFinally) { __SEH_RETURN_FINALLY(); } \
414 __SEH_LEAVE_TRYLEVEL(); \
416 goto _SEHEndExcept; \
430 __SEH_LEAVE_FRAME(); \
434#define _SEH2_GetExceptionInformation() (_SEHExceptionInformation)
435#define _SEH2_GetExceptionCode() ((_SEH2FrameP)->SF_Code)
436#define _SEH2_AbnormalTermination() (_SEHAbnormalTermination)
438#define _SEH2_YIELD(STMT_) \
441 if(!_SEH2ScopeKind) \
447#define _SEH2_LEAVE goto _SEHEndTry
449__SEH_END_SCOPE_CHAIN;
451#define _SEH2_VOLATILE volatile
454#error no PSEH support
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
int _SEH2_VolatileExceptionCode
int __cdecl _SEH2EnterFrameAndTrylevel(_SEH2Frame_t *frame, volatile _SEH2TryLevel_t *trylevel)
void __cdecl _SEH2Return(void)
void __cdecl _SEH2LeaveFrame(void)