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

Joel Sherrill joel@rtems.org
Thu Oct 2 22:22:19 GMT 2025


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 | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h
index a2830b275..62dd27ef4 100644
--- a/newlib/libc/include/setjmp.h
+++ b/newlib/libc/include/setjmp.h
@@ -7,17 +7,13 @@
 #define _SETJMP_H_
 
 #include "_ansi.h"
+#include <sys/cdefs.h>
 #include <machine/setjmp.h>
 
 _BEGIN_STD_C
 
-#ifdef __GNUC__
-void	longjmp (jmp_buf __jmpb, int __retval)
-			__attribute__ ((__noreturn__));
-#else
-void	longjmp (jmp_buf __jmpb, int __retval);
-#endif
-int	setjmp (jmp_buf __jmpb);
+void	longjmp (jmp_buf __jmpb, int __retval) __dead2;
+int	setjmp (jmp_buf __jmpb) __returns_twice;
 
 _END_STD_C
 
-- 
2.47.3



More information about the Newlib mailing list