1 | //===-- Implementation of sigsetjmp ---------------------------------------===// |
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 | #include "src/setjmp/sigsetjmp.h" |
10 | #include "hdr/offsetof_macros.h" |
11 | #include "src/__support/common.h" |
12 | #include "src/__support/macros/config.h" |
13 | #include "src/setjmp/setjmp_impl.h" |
14 | #include "src/setjmp/sigsetjmp_epilogue.h" |
15 | |
16 | namespace LIBC_NAMESPACE_DECL { |
17 | [[gnu::naked]] |
18 | LLVM_LIBC_FUNCTION(int, sigsetjmp, (sigjmp_buf, int)) { |
19 | asm(R"( |
20 | cbz w1, %c[setjmp] |
21 | |
22 | str x30, [x0, %c[retaddr]] |
23 | str x19, [x0, %c[extra]] |
24 | mov x19, x0 |
25 | bl %c[setjmp] |
26 | |
27 | mov w1, w0 |
28 | mov x0, x19 |
29 | ldr x30, [x0, %c[retaddr]] |
30 | ldr x19, [x0, %c[extra]] |
31 | b %c[epilogue])" ::[retaddr] "i" (offsetof(__jmp_buf, sig_retaddr)), |
32 | [extra] "i" (offsetof(__jmp_buf, sig_extra)), [setjmp] "i" (setjmp), |
33 | [epilogue] "i" (sigsetjmp_epilogue) |
34 | : "x0" , "x1" , "x19" , "x30" ); |
35 | } |
36 | } // namespace LIBC_NAMESPACE_DECL |
37 | |