aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2019-02-08 13:20:37 +0000
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2019-02-08 13:42:38 +0000
commit70b0f2789e93f253bec5cbd2986d0de023c1bdf4 (patch)
tree4de89a2865b8412b3061567f40ee497b45851904
parente05663051671bdec38056a2da5ddebd390b4abca (diff)
downloadtrusted-firmware-a-70b0f2789e93f253bec5cbd2986d0de023c1bdf4.tar.gz
libc: Move setjmp to libc folder
Now that setjmp() and longjmp() are compliant with the standard they can be moved with the other libc files. Change-Id: Iea3b91c34eb353ace5e171e72f331602d57774d5 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
-rw-r--r--bl31/bl31.mk1
-rw-r--r--include/lib/libc/aarch64/setjmp_.h (renamed from include/arch/aarch64/setjmp.h)11
-rw-r--r--include/lib/libc/setjmp.h20
-rw-r--r--lib/libc/aarch64/setjmp.S (renamed from lib/aarch64/setjmp.S)0
-rw-r--r--lib/libc/libc.mk9
-rw-r--r--make_helpers/build_macros.mk24
6 files changed, 53 insertions, 12 deletions
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index 89f5896ac0..c9ba926c59 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -31,7 +31,6 @@ BL31_SOURCES += bl31/bl31_main.c \
bl31/aarch64/runtime_exceptions.S \
bl31/bl31_context_mgmt.c \
common/runtime_svc.c \
- lib/aarch64/setjmp.S \
lib/cpus/aarch64/dsu_helpers.S \
plat/common/aarch64/platform_mp_stack.S \
services/arm_arch_svc/arm_arch_svc_setup.c \
diff --git a/include/arch/aarch64/setjmp.h b/include/lib/libc/aarch64/setjmp_.h
index f7991fddbd..174b3eb180 100644
--- a/include/arch/aarch64/setjmp.h
+++ b/include/lib/libc/aarch64/setjmp_.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef SETJMP_H
-#define SETJMP_H
+#ifndef SETJMP__H
+#define SETJMP__H
#define JMP_CTX_X19 0x0
#define JMP_CTX_X21 0x10
@@ -21,13 +21,10 @@
#ifndef __ASSEMBLY__
#include <cdefs.h>
-#include <stdint.h>
/* Jump buffer hosting x18 - x30 and sp_el0 registers */
typedef uint64_t jmp_buf[JMP_SIZE] __aligned(16);
-int setjmp(jmp_buf env);
-__dead2 void longjmp(jmp_buf env, int val);
-
#endif /* __ASSEMBLY__ */
-#endif /* SETJMP_H */
+
+#endif /* SETJMP__H */
diff --git a/include/lib/libc/setjmp.h b/include/lib/libc/setjmp.h
new file mode 100644
index 0000000000..5661201a0b
--- /dev/null
+++ b/include/lib/libc/setjmp.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef SETJMP_H
+#define SETJMP_H
+
+#include <setjmp_.h>
+
+#ifndef __ASSEMBLY__
+
+#include <cdefs.h>
+
+int setjmp(jmp_buf env);
+__dead2 void longjmp(jmp_buf env, int val);
+
+#endif /* __ASSEMBLY__ */
+#endif /* SETJMP_H */
diff --git a/lib/aarch64/setjmp.S b/lib/libc/aarch64/setjmp.S
index 9d9eb49ba4..9d9eb49ba4 100644
--- a/lib/aarch64/setjmp.S
+++ b/lib/libc/aarch64/setjmp.S
diff --git a/lib/libc/libc.mk b/lib/libc/libc.mk
index 1276f5c82b..e1b5560f84 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) \
diff --git a/make_helpers/build_macros.mk b/make_helpers/build_macros.mk
index 73b84c38a3..4a264d7eeb 100644
--- a/make_helpers/build_macros.mk
+++ b/make_helpers/build_macros.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -206,6 +206,22 @@ $(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs
endef
+# MAKE_S_LIB builds an assembly source file and generates the dependency file
+# $(1) = output directory
+# $(2) = source file (%.S)
+# $(3) = library name
+define MAKE_S_LIB
+$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
+$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
+
+$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs
+ $$(ECHO) " AS $$<"
+ $$(Q)$$(AS) $$(ASFLAGS) $(MAKE_DEP) -c $$< -o $$@
+
+-include $(DEP)
+
+endef
+
# MAKE_C builds a C source file and generates the dependency file
# $(1) = output directory
@@ -263,7 +279,7 @@ $(1): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs
endef
-# MAKE_LIB_OBJS builds both C source files
+# MAKE_LIB_OBJS builds both C and assembly source files
# $(1) = output directory
# $(2) = list of source files
# $(3) = name of the library
@@ -272,6 +288,10 @@ define MAKE_LIB_OBJS
$(eval REMAIN := $(filter-out %.c,$(2)))
$(eval $(foreach obj,$(C_OBJS),$(call MAKE_C_LIB,$(1),$(obj),$(3))))
+ $(eval S_OBJS := $(filter %.S,$(REMAIN)))
+ $(eval REMAIN := $(filter-out %.S,$(REMAIN)))
+ $(eval $(foreach obj,$(S_OBJS),$(call MAKE_S_LIB,$(1),$(obj),$(3))))
+
$(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
endef