summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/cpu.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-05-16 18:42:22 +0300
committerAlexander Graf <agraf@suse.de>2018-06-03 16:27:21 +0300
commit30eef21fa041635fb8327ef9001d78cb187c359f (patch)
tree0945455a7afbc64b4636329b50ac62d58db979cb /arch/sandbox/cpu/cpu.c
parent0864c565a274ddbc23dda667d71524e7efbbef8f (diff)
downloadu-boot-30eef21fa041635fb8327ef9001d78cb187c359f.tar.xz
sandbox: Add a setjmp() implementation
Add an implementation of setjmp() and longjmp() which rely on the underlying host C library. Since we cannot know how large the jump buffer needs to be, pick something that should be suitable and check it at runtime. At present we need access to the underlying struct as well. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/sandbox/cpu/cpu.c')
-rw-r--r--arch/sandbox/cpu/cpu.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index d4ad020012..cde0b055a6 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -9,6 +9,7 @@
#include <linux/libfdt.h>
#include <os.h>
#include <asm/io.h>
+#include <asm/setjmp.h>
#include <asm/state.h>
#include <dm/root.h>
@@ -164,3 +165,15 @@ ulong timer_get_boot_us(void)
return (count - base_count) / 1000;
}
+
+int setjmp(jmp_buf jmp)
+{
+ return os_setjmp((ulong *)jmp, sizeof(*jmp));
+}
+
+void longjmp(jmp_buf jmp, int ret)
+{
+ os_longjmp((ulong *)jmp, ret);
+ while (1)
+ ;
+}