From 00fba54d7ba98820d7e614e0b75adadabf086ae3 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 24 Mar 2021 17:30:49 +0300 Subject: [PATCH] C: fix exception handling semantics with longjmp --- .../resources/org/teavm/backend/c/exceptions.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/resources/org/teavm/backend/c/exceptions.h b/core/src/main/resources/org/teavm/backend/c/exceptions.h index 1e9b64fd7..54ea268f9 100644 --- a/core/src/main/resources/org/teavm/backend/c/exceptions.h +++ b/core/src/main/resources/org/teavm/backend/c/exceptions.h @@ -16,18 +16,18 @@ jmp_buf* teavm_oldTryBuffer = teavm_shadowStack.header.jmpTarget; \ teavm_shadowStack.header.jmpTarget = &teavm_tryBuffer; \ int teavm_exceptionHandler = setjmp(teavm_tryBuffer); \ - switch (teavm_exceptionHandler) { \ - case 0: { + if (teavm_exceptionHandler == 0) { #define TEAVM_CATCH \ - break; \ - } \ - default: { \ - longjmp(*teavm_oldTryBuffer, teavm_exceptionHandler); \ - break; \ - } + teavm_shadowStack.header.jmpTarget = teavm_oldTryBuffer; \ + } else { \ + teavm_shadowStack.header.jmpTarget = teavm_oldTryBuffer; \ + switch (teavm_exceptionHandler) { #define TEAVM_END_TRY \ + default: \ + longjmp(*teavm_oldTryBuffer, teavm_exceptionHandler); \ + break; \ + } \ } \ - teavm_shadowStack.header.jmpTarget = teavm_oldTryBuffer; \ } while (0); #define TEAVM_JUMP_TO_FRAME(frame, id) \