summaryrefslogtreecommitdiff
path: root/include/setjmp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/setjmp.h')
-rw-r--r--include/setjmp.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/include/setjmp.h b/include/setjmp.h
new file mode 100644
index 00000000000..37d3a8af85d
--- /dev/null
+++ b/include/setjmp.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_ 1
+
+#ifdef CONFIG_HAVE_SETJMP
+#include <asm/setjmp.h>
+#else
+struct jmp_buf_data {
+};
+#endif
+
+/**
+ * typedef jmp_buf - information needed to restore a calling environment
+ */
+typedef struct jmp_buf_data jmp_buf[1];
+
+/**
+ * setjmp() - prepare for a long jump
+ *
+ * Registers, the stack pointer, and the return address are saved in the
+ * jump bufffer. The function returns zero afterwards. When longjmp() is
+ * executed the function returns a second time with a non-zero value.
+ *
+ * @env: jump buffer used to store register values
+ * Return: 0 after setting up jump buffer, non-zero after longjmp()
+ */
+int setjmp(jmp_buf env);
+
+/**
+ * longjmp() - long jump
+ *
+ * Jump back to the address and the register state saved by setjmp().
+ *
+ * @env: jump buffer
+ * @val: value to be returned by setjmp(), 0 is replaced by 1
+ */
+void longjmp(jmp_buf env, int val);
+
+#endif /* _SETJMP_H_ */