[PATCH] sparc: Improve setjmp()

Sebastian Huber sebastian.huber@embedded-brains.de
Fri Oct 6 05:31:06 GMT 2023


Flush the windows in setjmp().  This helps if the stack is changed after
the setjmp() and we want to jump back to the original stack using
longjmp().
---
 newlib/libc/machine/sparc/setjmp.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newlib/libc/machine/sparc/setjmp.S b/newlib/libc/machine/sparc/setjmp.S
index 613df2ba2..d7185be4c 100644
--- a/newlib/libc/machine/sparc/setjmp.S
+++ b/newlib/libc/machine/sparc/setjmp.S
@@ -110,6 +110,8 @@
 
 ENTRY(setjmp)
 ENTRY(_setjmp)
+        ta      0x03            /* Flush registers, just in case another stack
+                                   is used after the setjmp().  */
         st      %sp, [%o0]      /* caller's stack pointer */
         st      %i7, [%o0+4]    /* caller's return pc */
         st      %fp, [%o0+8]    /* store caller's frame pointer */
-- 
2.35.3



More information about the Newlib mailing list