aboutsummaryrefslogtreecommitdiff
path: root/src/lj_err.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_err.c')
-rw-r--r--src/lj_err.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lj_err.c b/src/lj_err.c
index 8ff0a455..7ae87a82 100644
--- a/src/lj_err.c
+++ b/src/lj_err.c
@@ -386,12 +386,17 @@ typedef struct UndocumentedDispatcherContext {
386 ULONG Fill0; 386 ULONG Fill0;
387} UndocumentedDispatcherContext; 387} UndocumentedDispatcherContext;
388 388
389#ifdef _MSC_VER
390/* Another wild guess. */ 389/* Another wild guess. */
391extern __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow); 390extern void __DestructExceptionObject(EXCEPTION_RECORD *rec, int nothrow);
391
392#ifdef MINGW_SDK_INIT
393/* Workaround for broken MinGW64 declaration. */
394VOID RtlUnwindEx_FIXED(PVOID,PVOID,PVOID,PVOID,PVOID,PVOID) asm("RtlUnwindEx");
395#define RtlUnwindEx RtlUnwindEx_FIXED
392#endif 396#endif
393 397
394#define LJ_MSVC_EXCODE ((DWORD)0xe06d7363) 398#define LJ_MSVC_EXCODE ((DWORD)0xe06d7363)
399#define LJ_GCC_EXCODE ((DWORD)0x20474343)
395 400
396#define LJ_EXCODE ((DWORD)0xe24c4a00) 401#define LJ_EXCODE ((DWORD)0xe24c4a00)
397#define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c)) 402#define LJ_EXCODE_MAKE(c) (LJ_EXCODE | (DWORD)(c))
@@ -411,10 +416,9 @@ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec,
411 } else { 416 } else {
412 void *cf2 = err_unwind(L, cf, 0); 417 void *cf2 = err_unwind(L, cf, 0);
413 if (cf2) { /* We catch it, so start unwinding the upper frames. */ 418 if (cf2) { /* We catch it, so start unwinding the upper frames. */
414 if (rec->ExceptionCode == LJ_MSVC_EXCODE) { 419 if (rec->ExceptionCode == LJ_MSVC_EXCODE ||
415#ifdef _MSC_VER 420 rec->ExceptionCode == LJ_GCC_EXCODE) {
416 __DestructExceptionObject(rec, 1); 421 __DestructExceptionObject(rec, 1);
417#endif
418 setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP)); 422 setstrV(L, L->top++, lj_err_str(L, LJ_ERR_ERRCPP));
419 } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) { 423 } else if (!LJ_EXCODE_CHECK(rec->ExceptionCode)) {
420 /* Don't catch access violations etc. */ 424 /* Don't catch access violations etc. */
@@ -427,7 +431,7 @@ LJ_FUNCA EXCEPTION_DISPOSITION lj_err_unwind_win64(EXCEPTION_RECORD *rec,
427 RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ? 431 RtlUnwindEx(cf, (void *)((cframe_unwind_ff(cf2) && errcode != LUA_YIELD) ?
428 lj_vm_unwind_ff_eh : 432 lj_vm_unwind_ff_eh :
429 lj_vm_unwind_c_eh), 433 lj_vm_unwind_c_eh),
430 rec, (void *)errcode, ctx, dispatch->HistoryTable); 434 rec, (void *)(uintptr_t)errcode, ctx, dispatch->HistoryTable);
431 /* RtlUnwindEx should never return. */ 435 /* RtlUnwindEx should never return. */
432 } 436 }
433 } 437 }