[1/3] setjmp: fix x86-64 longjmp argument adjustment

Submitted by Szabolcs Nagy on Aug. 12, 2020, 10:13 p.m.

Details

Message ID 20200812221311.GF879655@port70.net
State New
Series "Series without cover letter"
Headers show

Commit Message

Szabolcs Nagy Aug. 12, 2020, 10:13 p.m.
* Szabolcs Nagy <nsz@port70.net> [2020-08-12 23:44:05 +0200]:
> diff --git a/src/setjmp/aarch64/longjmp.s b/src/setjmp/aarch64/longjmp.s
> index 7c4655fa..b22042a2 100644
> --- a/src/setjmp/aarch64/longjmp.s
> +++ b/src/setjmp/aarch64/longjmp.s
> @@ -18,7 +18,6 @@ longjmp:
>  	ldp d12, d13, [x0,#144]
>  	ldp d14, d15, [x0,#160]
>  
> -	mov x0, x1
> -	cbnz x1, 1f
> -	mov x0, #1
> +	cmp w1, 0
> +	csinc w0, w1, wzr, ne
>  1:	br x30

v2 because the 1: label is no longer used

Patch hide | download patch | download mbox

From 5a842cde8974b6927fd7199e713f89852fc467cd Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Wed, 12 Aug 2020 21:00:26 +0000
Subject: [PATCH v2] aarch64: fix setjmp return value

longjmp should set the return value of setjmp, but 64bit
registers were used for the 0 check while the type is int.

use the code that gcc generates for return val ? val : 1;
---
 src/setjmp/aarch64/longjmp.s | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/setjmp/aarch64/longjmp.s b/src/setjmp/aarch64/longjmp.s
index 7c4655fa..0af9c50e 100644
--- a/src/setjmp/aarch64/longjmp.s
+++ b/src/setjmp/aarch64/longjmp.s
@@ -18,7 +18,6 @@  longjmp:
 	ldp d12, d13, [x0,#144]
 	ldp d14, d15, [x0,#160]
 
-	mov x0, x1
-	cbnz x1, 1f
-	mov x0, #1
-1:	br x30
+	cmp w1, 0
+	csinc w0, w1, wzr, ne
+	br x30
-- 
2.28.0