[PATCH] powerpc: Add attributes for setjmp/longjmp

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE2508d LANDED

Landed in mainline as aa497d435241 on 2019-09-11.

2 messages, 2 authors, 2019-09-19 · open the first message on its own page

[PATCH] powerpc: Add attributes for setjmp/longjmp

From: Segher Boessenkool <hidden>
Date: 2019-09-04 14:24:22

The setjmp function should be declared as "returns_twice", or bad
things can happen[1].  This does not actually change generated code
in my testing.

The longjmp function should be declared as "noreturn", so that the
compiler can optimise calls to it better.  This makes the generated
code a little shorter.

Signed-off-by: Segher Boessenkool <redacted>

[1] See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005ftwice-function-attribute
---
 arch/powerpc/include/asm/setjmp.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/setjmp.h b/arch/powerpc/include/asm/setjmp.h
index d995061..e9f81bb 100644
--- a/arch/powerpc/include/asm/setjmp.h
+++ b/arch/powerpc/include/asm/setjmp.h
@@ -7,7 +7,7 @@
 
 #define JMP_BUF_LEN    23
 
-extern long setjmp(long *);
-extern void longjmp(long *, long);
+extern long setjmp(long *) __attribute__((returns_twice));
+extern void longjmp(long *, long) __attribute__((noreturn));
 
 #endif /* _ASM_POWERPC_SETJMP_H */
-- 
1.8.3.1

Re: [PATCH] powerpc: Add attributes for setjmp/longjmp

From: Michael Ellerman <hidden>
Date: 2019-09-19 10:54:33

On Wed, 2019-09-04 at 14:11:07 UTC, Segher Boessenkool wrote:
The setjmp function should be declared as "returns_twice", or bad
things can happen[1].  This does not actually change generated code
in my testing.

The longjmp function should be declared as "noreturn", so that the
compiler can optimise calls to it better.  This makes the generated
code a little shorter.

Signed-off-by: Segher Boessenkool <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/aa497d4352414aad22e792b35d0aaaa12bbc37c5

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help