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

Message ID 20251002222219.1996190-2-joel@rtems.org
State New
Headers
Series Add attribute to setjmp() |

Commit Message

Joel Sherrill Oct. 2, 2025, 10:22 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 | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
  

Comments

Joel Sherrill Oct. 13, 2025, 7:08 p.m. UTC | #1
This has been unanswered since Oct 2. I think all feedback has been
incorporated.

It is certainly simpler now.

OK to commit?

Thanks.

--joel

On Thu, Oct 2, 2025 at 5:23 PM Joel Sherrill <joel@rtems.org> wrote:

> 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
>
>
  

Patch

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