2 * Copyright (c) 2011 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_r29_lr #0x50
30 #define JMP_fp_sp #0x60
32 #define JMP_d8_d9 #0x70
33 #define JMP_d10_d11 #0x80
34 #define JMP_d12_d13 #0x90
35 #define JMP_d14_d15 #0xA0
37 #define JMP_sigflag #0xB8
39 #include <architecture/arm/asm_help.h>
41 /* int _setjmp(jmp_buf env); */
43 add x1, sp, #0 /* can't STP from sp */
44 stp x19, x20, [x0, JMP_r19_20]
45 stp x21, x22, [x0, JMP_r21_22]
46 stp x23, x24, [x0, JMP_r23_24]
47 stp x25, x26, [x0, JMP_r25_26]
48 stp x27, x28, [x0, JMP_r27_28]
49 stp x29, lr, [x0, JMP_r29_lr]
50 stp fp, x1, [x0, JMP_fp_sp]
51 stp d8, d9, [x0, JMP_d8_d9]
52 stp d10, d11, [x0, JMP_d10_d11]
53 stp d12, d13, [x0, JMP_d12_d13]
54 stp d14, d15, [x0, JMP_d14_d15]
58 /* void _longjmp(jmp_buf env, int val); */
59 ENTRY_POINT(__longjmp)
60 ldp x19, x20, [x0, JMP_r19_20]
61 ldp x21, x22, [x0, JMP_r21_22]
62 ldp x23, x24, [x0, JMP_r23_24]
63 ldp x25, x26, [x0, JMP_r25_26]
64 ldp x27, x28, [x0, JMP_r27_28]
65 ldp x29, lr, [x0, JMP_r29_lr]
66 ldp fp, x2, [x0, JMP_fp_sp]
67 ldp d8, d9, [x0, JMP_d8_d9]
68 ldp d10, d11, [x0, JMP_d10_d11]
69 ldp d12, d13, [x0, JMP_d12_d13]
70 ldp d14, d15, [x0, JMP_d14_d15]
73 cmp x0, #0 /* longjmp returns 1 if val is 0 */
78 /* int sigsetjmp(sigjmp_buf env, int savemask); */
79 ENTRY_POINT(_sigsetjmp)
80 str x1, [x0, JMP_sigflag]
85 /* else, fall through */
87 /* int setjmp(jmp_buf env); */
95 CALL_EXTERNAL(_sigprocmask)
101 /* void siglongjmp(sigjmp_buf env, int val); */
102 ENTRY_POINT(_siglongjmp)
103 ldr x2, [x0, JMP_sigflag]
108 /* else, fall through */
110 /* void longjmp(jmp_buf env, int val); */
111 ENTRY_POINT(_longjmp)
113 mov x21, x0 // x21/x22 will be restored by __longjmp
115 ldr x0, [x21, JMP_sig] // restore the signal mask
117 add x1, sp, #8 // set
118 orr w0, wzr, #0x3 // SIG_SETMASK
120 CALL_EXTERNAL(_sigprocmask)