Skip to content

Commit e16e5d0

Browse files
committed
lm32: Make setjmp return '1' when longjmp is passed '0'
When the application calls longjmp with '0', the library is supposed to replace that with '1' when returning from setjmp. Signed-off-by: Keith Packard <[email protected]>
1 parent 53f3610 commit e16e5d0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

newlib/libc/machine/lm32/setjmp.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
/* setjmp/longjmp for LatticeMico32. */
2626
#include <picolibc.h>
2727

28-
2928
.section .text
3029
.align 4
3130

3231
.globl setjmp
3332
.type setjmp,@function
34-
.globl longjmp
35-
.type longjmp,@function
3633

3734
/* setjmp: save all callee saves into jmp_buf
3835
r1 - Address of jmp_buf
@@ -60,6 +57,7 @@ setjmp:
6057
sw (r1+72), ra
6158
mvi r1, 0
6259
ret
60+
.size setjmp, . - setjmp
6361

6462
/* longjmp: restore all callee saves from jmp_buf
6563
r1 - Address of jmb_buf
@@ -91,6 +89,8 @@ longjmp:
9189
lw sp, (r1+68)
9290
lw ra, (r1+72)
9391
mv r1, r2
92+
# Return 1 if the argument is zero
93+
cmpe r1, r0, r2
94+
add r1, r1, r2
9495
ret
95-
96-
96+
.size longjmp, . - longjmp

0 commit comments

Comments
 (0)