From 73d6b2eb7ccf24faa273877683f8f2566b31f4f0 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sat, 29 May 2021 11:16:23 +0200 Subject: [PATCH] setjmp: do not disable interrupts (#1) (DONE) SR.BL=1 could cause problems if setjmp or longjmp is loader over a page boundary and the second page is not loaded when interrupts are masked. SR.IMASK=15 is another option, but it seems unnecessary per #1. Blocking interrupts in longjmp did not make too much sense because the blocked SR was immediately replaced by the restored one. --- STATUS | 5 +++-- src/libc/setjmp/target/sh-generic/longjmp.S | 9 --------- src/libc/setjmp/target/sh-generic/setjmp.S | 13 ++----------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/STATUS b/STATUS index 9cb6e0e..6109988 100644 --- a/STATUS +++ b/STATUS @@ -68,8 +68,8 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested 7.12 => OpenLibm 7.13 -! 7.13.1 setjmp: TEST -! 7.13.2 longjmp: TEST + 7.13.1 setjmp: DONE + 7.13.2 longjmp: DONE 7.14 ! 7.14.1 Macros and stuff: TODO @@ -95,6 +95,7 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested ! 7.19.10 Error-handling functions: TODO 7.20 + 7.20 RAND_MAX, MB_CUR_MAX: TODO 7.20.1.1 atof: DONE 7.20.1.2 atoi, atol, atoll: DONE 7.20.1.3 strtod, strtof, strtold: DONE diff --git a/src/libc/setjmp/target/sh-generic/longjmp.S b/src/libc/setjmp/target/sh-generic/longjmp.S index 6da0532..5c251a9 100644 --- a/src/libc/setjmp/target/sh-generic/longjmp.S +++ b/src/libc/setjmp/target/sh-generic/longjmp.S @@ -18,15 +18,6 @@ _longjmp: movt r9 add r5, r9 - ! block interrupt -int_block: - stc sr, r1 - mov #0x10, r2 - shll8 r2 - shll16 r2 - or r2, r1 - ldc r1, sr - context_switch: ! load the old SR register first to force register bank switch ! (if needed) then move the context and the returned value into diff --git a/src/libc/setjmp/target/sh-generic/setjmp.S b/src/libc/setjmp/target/sh-generic/setjmp.S index 596231c..53bf37a 100644 --- a/src/libc/setjmp/target/sh-generic/setjmp.S +++ b/src/libc/setjmp/target/sh-generic/setjmp.S @@ -5,18 +5,12 @@ .align 2 /* ** int setjmp(jmp_buf env) -** Store the calling environment in ENV, also saving the signal mask. +** Store the calling environment in ENV. ** Return 0. */ _setjmp: ! block interrupt - stc sr, r1 - mov r1, r3 - mov #0x10, r2 - shll8 r2 - shll16 r2 - or r2, r1 - ldc r1, sr + stc sr, r3 ! save current context ! @note: r3 is the saved SR regsiter @@ -35,9 +29,6 @@ _setjmp: mov.l r8, @-r4 mov.l r3, @-r4 - ! restore sr - ldc r3, sr - ! return rts mov #0, r0