summaryrefslogtreecommitdiff
path: root/libc/include
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2022-11-01 06:18:12 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2022-11-01 22:58:35 +0000
commit3b82b4fbd50ac15584ac88075f356f3ebf946515 (patch)
tree696ec354bdb5a6d0bb395ea9a4b6ba1d9154a917 /libc/include
parenteb877006a61733a87257c1c999f5a0b880ccf3cd (diff)
downloadllvm-3b82b4fbd50ac15584ac88075f356f3ebf946515.tar.gz
[libc] Add x86_64 implementation of setjmp and longjmp.
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D137147
Diffstat (limited to 'libc/include')
-rw-r--r--libc/include/CMakeLists.txt9
-rw-r--r--libc/include/llvm-libc-types/CMakeLists.txt1
-rw-r--r--libc/include/llvm-libc-types/jmp_buf.h29
-rw-r--r--libc/include/setjmp.h.def16
4 files changed, 55 insertions, 0 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 3e63695e12a2..066c7783d82a 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -77,6 +77,15 @@ add_gen_header(
)
add_gen_header(
+ setjmp
+ DEF_FILE setjmp.h.def
+ GEN_HDR setjmp.h
+ DEPENDS
+ .llvm_libc_common_h
+ .llvm-libc-types.jmp_buf
+)
+
+add_gen_header(
string
DEF_FILE string.h.def
GEN_HDR string.h
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index e4e9567d5fdc..4bd69be95cfe 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -36,6 +36,7 @@ add_header(gid_t HDR gid_t.h)
add_header(uid_t HDR uid_t.h)
add_header(imaxdiv_t HDR imaxdiv_t.h)
add_header(ino_t HDR ino_t.h)
+add_header(jmp_buf HDR jmp_buf.h)
add_header(mode_t HDR mode_t.h)
add_header(mtx_t HDR mtx_t.h DEPENDS .__futex_word .__mutex_type)
add_header(nlink_t HDR nlink_t.h)
diff --git a/libc/include/llvm-libc-types/jmp_buf.h b/libc/include/llvm-libc-types/jmp_buf.h
new file mode 100644
index 000000000000..e948a7f42248
--- /dev/null
+++ b/libc/include/llvm-libc-types/jmp_buf.h
@@ -0,0 +1,29 @@
+//===-- Definition of type jmp_buf ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_JMP_BUF_H__
+#define __LLVM_LIBC_TYPES_JMP_BUF_H__
+
+typedef struct {
+#ifdef __x86_64__
+ __UINT64_TYPE__ rbx;
+ __UINT64_TYPE__ rbp;
+ __UINT64_TYPE__ r12;
+ __UINT64_TYPE__ r13;
+ __UINT64_TYPE__ r14;
+ __UINT64_TYPE__ r15;
+ __UINTPTR_TYPE__ rsp;
+ __UINTPTR_TYPE__ rip;
+#else
+#error "__jmp_buf not available for your target architecture."
+#endif
+} __jmp_buf;
+
+typedef __jmp_buf jmp_buf[1];
+
+#endif // __LLVM_LIBC_TYPES_JMP_BUF_H__
diff --git a/libc/include/setjmp.h.def b/libc/include/setjmp.h.def
new file mode 100644
index 000000000000..7447be2415bd
--- /dev/null
+++ b/libc/include/setjmp.h.def
@@ -0,0 +1,16 @@
+//===-- C standard library header setjmp.h --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SETJMP_H
+#define LLVM_LIBC_SETJMP_H
+
+#include <__llvm-libc-common.h>
+
+%%public_api()
+
+#endif // LLVM_LIBC_SETJMP_H