Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / pnacl / support / setjmp_arm.S
1 /*
2  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 #if defined(__native_client_nonsfi__)
8
9     .text
10     .globl setjmp
11
12 /* int setjmp(jmp_buf env) */
13 setjmp:
14     stmia   r0!, {r4-r11, sp, lr}
15     vstmia  r0!, {d8-d15}
16     mov     r0, #0
17     bx      lr
18
19     .text
20     .globl longjmp
21
22 /* void longjmp(jmp_buf env, int val) */
23 longjmp:
24     ldmia   r0!, {r4-r11, sp, lr}
25     vldmia  r0!, {d8-d15}
26     /* Return the result argument if nonzero or 1 otherwise */
27     /* Note: move updates condition codes */
28     movs    r0, r1
29     moveq   r0, #1
30     bx      lr
31
32 #else
33
34 #include "nacl_arm_defs.h"
35
36 /*
37  * jump_buf is organized as follows
38  *
39  * r4, r5, r6, r7, r8, r10 (sl), r11 (fp), r12 (ip/pad), r13 (sp), r14 (lr),
40  * d8-d15.
41  *
42  * Note: We do not save/restore r9 - which pnacl uses for thread accounting.
43  * r12 is spilled to pad out the jump buf so that d8-d15 are stored at an
44  * 8-byte aligned location.
45  *
46  * This also assumes that the minimal ARM hardware has d8-d15 registers,
47  * which is checked: src/trusted/platform_qualify/arch/arm/nacl_qualify_fpu.c
48  */
49
50     .text
51     .align NACL_BLOCK_SHIFT
52     .globl setjmp
53
54 /* int setjmp(jmp_buf env) */
55 setjmp:
56     bic     r0, r0, #NACL_DATA_FLOW_MASK
57     stmia   r0!, {r4, r5, r6, r7, r8, r10, r11, r12, sp, lr}
58     bic     r0, r0, #NACL_DATA_FLOW_MASK
59     vstmia  r0!, {d8-d15}
60
61     mov     r0, #0
62     bic     lr, lr, #NACL_CONTROL_FLOW_MASK
63     bx      lr
64
65
66     .text
67     .align NACL_BLOCK_SHIFT
68     .globl longjmp
69
70 /* void longjmp(jmp_buf env, int val) */
71 longjmp:
72     bic     r0, r0, #NACL_DATA_FLOW_MASK
73     ldmia   r0!, {r4, r5, r6, r7, r8, r10, r11, r12, sp, lr}
74     bic     sp, sp, #NACL_DATA_FLOW_MASK
75     nop
76
77     bic     r0, r0, #NACL_DATA_FLOW_MASK
78     vldmia  r0!, {d8-d15}
79     /* Return the result argument if nonzero or 1 otherwise */
80     /* Note: move updates condition codes */
81     movs    r0, r1
82     moveq   r0, #1
83
84     bic     lr, lr, #NACL_CONTROL_FLOW_MASK
85     bx      lr
86
87 #endif