[v2] newlib/libc/include/setjmp.h: Add returns_twice attribute to setjmp()

Message ID 20251002143026.2289073-1-joel@rtems.org
State New
Headers
Series [v2] newlib/libc/include/setjmp.h: Add returns_twice attribute to setjmp() |

Commit Message

Joel Sherrill Oct. 2, 2025, 2:30 p.m. UTC
  The setjmp() function needs this attribute to help GCC avoid false
positives for the -Wclobbered warning. The -Wclobbered warning is
part of -Wextra.
---
 newlib/libc/include/setjmp.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
  

Patch

diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h
index a2830b275..9e9138162 100644
--- a/newlib/libc/include/setjmp.h
+++ b/newlib/libc/include/setjmp.h
@@ -11,13 +11,17 @@ 
 
 _BEGIN_STD_C
 
-#ifdef __GNUC__
 void	longjmp (jmp_buf __jmpb, int __retval)
-			__attribute__ ((__noreturn__));
-#else
-void	longjmp (jmp_buf __jmpb, int __retval);
+#ifdef __GNUC__
+		__attribute__ ((__noreturn__))
+#endif
+	;
+
+int	setjmp (jmp_buf __jmpb)
+#ifdef __GNUC__
+		__attribute__ ((returns_twice))
 #endif
-int	setjmp (jmp_buf __jmpb);
+	;
 
 _END_STD_C