Browse Source

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.
master
Lephenixnoir 8 months ago
parent
commit
73d6b2eb7c
Signed by: Lephenixnoir GPG Key ID: 1BBA026E13FC0495
  1. 5
      STATUS
  2. 9
      src/libc/setjmp/target/sh-generic/longjmp.S
  3. 13
      src/libc/setjmp/target/sh-generic/setjmp.S

5
STATUS

@ -68,8 +68,8 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested
7.12 <math.h> => OpenLibm
7.13 <setjmp.h>
! 7.13.1 setjmp: TEST
! 7.13.2 longjmp: TEST
7.13.1 setjmp: DONE
7.13.2 longjmp: DONE
7.14 <signal.h>
! 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 <stdlib.h>
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

9
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

13
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

Loading…
Cancel
Save