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