git: a82b1ca60381 - stable/13 - libc: Fix longjmp/_longjmp(buf, 0) for MIPS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 31 Jan 2023 01:47:13 UTC
The branch stable/13 has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=a82b1ca6038152eb5740552507534842acebede2
commit a82b1ca6038152eb5740552507534842acebede2
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-01-30 23:55:03 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2023-01-31 01:46:18 +0000
libc: Fix longjmp/_longjmp(buf, 0) for MIPS
Like AArch64 and RISC-V in the past, MIPS fails to handle this special
case, and will cause the corresponding setjmp/_setjmp to return 0 rather
than 1. Fix this so the newly-added regression tests pass.
This is a direct commit to stable/13 as mips no longer exists in main.
Reviewed by: arichardson, jhb
Differential Revision: https://reviews.freebsd.org/D29363
---
lib/libc/mips/gen/_setjmp.S | 3 +++
lib/libc/mips/gen/setjmp.S | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/libc/mips/gen/_setjmp.S b/lib/libc/mips/gen/_setjmp.S
index 10c4cda5e0c1..ba9b89f208c4 100644
--- a/lib/libc/mips/gen/_setjmp.S
+++ b/lib/libc/mips/gen/_setjmp.S
@@ -183,7 +183,10 @@ LEAF(_longjmp)
#endif /* ! __mips_soft_float */
REG_EPILOGUE
+ bne a1, zero, 1f
move v0, a1 # get return value in 1st arg
+ REG_LI v0, 1 # return 1 if arg is 0
+1:
j ra
nop
diff --git a/lib/libc/mips/gen/setjmp.S b/lib/libc/mips/gen/setjmp.S
index 3ef6878bb608..6b8f196735c4 100644
--- a/lib/libc/mips/gen/setjmp.S
+++ b/lib/libc/mips/gen/setjmp.S
@@ -220,7 +220,10 @@ NESTED(longjmp, LONGJMP_FRAME_SIZE, ra)
#endif
#endif /* ! __mips_soft_float */
- move v0, a1
+ move v0, a1 # get return value in 1st arg
+ bne a1, zero, 1f # NB: no .set noreorder
+ REG_LI v0, 1 # return 1 if arg is 0
+1:
j ra
nop