2 * Copyright (c) 2011-2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #define JMP_r19_20 #0x00
25 #define JMP_r21_22 #0x10
26 #define JMP_r23_24 #0x20
27 #define JMP_r25_26 #0x30
28 #define JMP_r27_28 #0x40
29 #define JMP_fp_lr #0x50
30 #define JMP_sp_rsvd #0x60 /* second field is reserved/unused */
31 #define JMP_d8_d9 #0x70
32 #define JMP_d10_d11 #0x80
33 #define JMP_d12_d13 #0x90
34 #define JMP_d14_d15 #0xA0
36 #define JMP_sigflag #0xB8
38 #include <architecture/arm/asm_help.h>
42 /* int _setjmp(jmp_buf env); */
44 _OS_PTR_MUNGE_TOKEN(x16, x16)
45 _OS_PTR_MUNGE(x10, fp, x16)
46 _OS_PTR_MUNGE(x11, lr, x16)
48 _OS_PTR_MUNGE(x12, x12, x16)
49 stp x19, x20, [x0, JMP_r19_20]
50 stp x21, x22, [x0, JMP_r21_22]
51 stp x23, x24, [x0, JMP_r23_24]
52 stp x25, x26, [x0, JMP_r25_26]
53 stp x27, x28, [x0, JMP_r27_28]
54 stp x10, x11, [x0, JMP_fp_lr]
55 str x12, [x0, JMP_sp_rsvd]
56 stp d8, d9, [x0, JMP_d8_d9]
57 stp d10, d11, [x0, JMP_d10_d11]
58 stp d12, d13, [x0, JMP_d12_d13]
59 stp d14, d15, [x0, JMP_d14_d15]
63 /* void _longjmp(jmp_buf env, int val); */
64 ENTRY_POINT(__longjmp)
65 _OS_PTR_MUNGE_TOKEN(x16, x16)
66 ldp x19, x20, [x0, JMP_r19_20]
67 ldp x21, x22, [x0, JMP_r21_22]
68 ldp x23, x24, [x0, JMP_r23_24]
69 ldp x25, x26, [x0, JMP_r25_26]
70 ldp x27, x28, [x0, JMP_r27_28]
71 ldp x10, x11, [x0, JMP_fp_lr]
72 ldr x12, [x0, JMP_sp_rsvd]
73 ldp d8, d9, [x0, JMP_d8_d9]
74 ldp d10, d11, [x0, JMP_d10_d11]
75 ldp d12, d13, [x0, JMP_d12_d13]
76 ldp d14, d15, [x0, JMP_d14_d15]
77 _OS_PTR_UNMUNGE(fp, x10, x16)
78 _OS_PTR_UNMUNGE(lr, x11, x16)
79 _OS_PTR_UNMUNGE(x12, x12, x16)
85 /* int sigsetjmp(sigjmp_buf env, int savemask); */
86 ENTRY_POINT(_sigsetjmp)
87 str w1, [x0, JMP_sigflag]
91 /* else, fall through */
93 /* int setjmp(jmp_buf env); */
101 CALL_EXTERNAL(_sigprocmask)
108 /* void siglongjmp(sigjmp_buf env, int val); */
109 ENTRY_POINT(_siglongjmp)
110 ldr w8, [x0, JMP_sigflag]
114 /* else, fall through */
116 /* void longjmp(jmp_buf env, int val); */
117 ENTRY_POINT(_longjmp)
119 mov x21, x0 // x21/x22 will be restored by __longjmp
121 ldr x8, [x21, JMP_sig] // restore the signal mask
123 orr w0, wzr, #0x3 // SIG_SETMASK
124 add x1, sp, #8 // set
126 CALL_EXTERNAL(_sigprocmask)