xref: /llvm-project/libc/include/llvm-libc-types/jmp_buf.h (revision b1320d36339e38b073088fd45013a3c692adb301)
1 //===-- Definition of type jmp_buf ----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_TYPES_JMP_BUF_H
10 #define LLVM_LIBC_TYPES_JMP_BUF_H
11 
12 typedef struct {
13 #ifdef __x86_64__
14   __UINT64_TYPE__ rbx;
15   __UINT64_TYPE__ rbp;
16   __UINT64_TYPE__ r12;
17   __UINT64_TYPE__ r13;
18   __UINT64_TYPE__ r14;
19   __UINT64_TYPE__ r15;
20   __UINTPTR_TYPE__ rsp;
21   __UINTPTR_TYPE__ rip;
22 #elif defined(__i386__)
23   long ebx;
24   long esi;
25   long edi;
26   long ebp;
27   long esp;
28   long eip;
29 #elif defined(__riscv)
30   /* Program counter.  */
31   long int __pc;
32   /* Callee-saved registers.  */
33   long int __regs[12];
34   /* Stack pointer.  */
35   long int __sp;
36   /* Callee-saved floating point registers.  */
37 #if __riscv_float_abi_double
38   double __fpregs[12];
39 #elif defined(__riscv_float_abi_single)
40 #error "__jmp_buf not available for your target architecture."
41 #endif
42 #elif defined(__arm__)
43   // r4, r5, r6, r7, r8, r9, r10, r11, r12, lr
44   long opaque[10];
45 #elif defined(__aarch64__)
46   long opaque[14]; // x19-x29, lr, sp, optional x18
47 #if __ARM_FP
48   long fopaque[8]; // d8-d15
49 #endif
50 #else
51 #error "__jmp_buf not available for your target architecture."
52 #endif
53 } __jmp_buf;
54 
55 typedef __jmp_buf jmp_buf[1];
56 
57 #endif // LLVM_LIBC_TYPES_JMP_BUF_H
58