aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAntonio Niño Díaz <antonio.ninodiaz@arm.com>2019-02-11 09:58:53 +0000
committerGitHub <noreply@github.com>2019-02-11 09:58:53 +0000
commit873e394b3bf93214a441f9f98237b58fbbea55aa (patch)
tree9502a299d22c782c284d604a5fada651c2680c91 /lib
parent9beee98acc6af787b4e56a2b34a6545b0c36f829 (diff)
parent70b0f2789e93f253bec5cbd2986d0de023c1bdf4 (diff)
downloadplatform_external_arm-trusted-firmware-873e394b3bf93214a441f9f98237b58fbbea55aa.tar.gz
platform_external_arm-trusted-firmware-873e394b3bf93214a441f9f98237b58fbbea55aa.tar.bz2
platform_external_arm-trusted-firmware-873e394b3bf93214a441f9f98237b58fbbea55aa.zip
Merge pull request #1810 from antonio-nino-diaz-arm/an/setjmp
Make setjmp/longjmp compliant with the C standard and move them to libc
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/aarch64/setjmp.S (renamed from lib/aarch64/setjmp.S)14
-rw-r--r--lib/libc/libc.mk9
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/aarch64/setjmp.S b/lib/libc/aarch64/setjmp.S
index 9060cb756..9d9eb49ba 100644
--- a/lib/aarch64/setjmp.S
+++ b/lib/libc/aarch64/setjmp.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,10 +12,7 @@
.globl longjmp
/*
- * int setjmp(struct jmpbuf *buf);
- *
- * Sets a jump point in the buffer specified in x0. Returns 0 to the caller when
- * when setting up the jump, and 1 when returning from the jump.
+ * int setjmp(jmp_buf env);
*/
func setjmp
mov x7, sp
@@ -34,9 +31,7 @@ endfunc setjmp
/*
- * void longjmp(struct jmpbuf *buf);
- *
- * Return to a jump point setup by setjmp()
+ * void longjmp(jmp_buf env, int val);
*/
func longjmp
ldp x7, xzr, [x0, #JMP_CTX_SP]
@@ -60,6 +55,7 @@ func longjmp
mov sp, x7
- mov x0, #1
+ ands x0, x1, x1 /* Move val to x0 and set flags */
+ cinc x0, x0, eq /* If val is 0, return 1 */
ret
endfunc longjmp
diff --git a/lib/libc/libc.mk b/lib/libc/libc.mk
index 1276f5c82..e1b5560f8 100644
--- a/lib/libc/libc.mk
+++ b/lib/libc/libc.mk
@@ -1,10 +1,10 @@
#
-# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
-LIBC_SRCS := $(addprefix lib/libc/, \
+LIBC_SRCS := $(addprefix lib/libc/, \
abort.c \
assert.c \
exit.c \
@@ -25,5 +25,10 @@ LIBC_SRCS := $(addprefix lib/libc/, \
strnlen.c \
strrchr.c)
+ifeq (${ARCH},aarch64)
+LIBC_SRCS += $(addprefix lib/libc/aarch64/, \
+ setjmp.S)
+endif
+
INCLUDES += -Iinclude/lib/libc \
-Iinclude/lib/libc/$(ARCH) \