1 /* Copyright JS Foundation and other contributors, http://js.foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 .syntax unified
17 
18 .macro func _name
19 .global \_name
20 .type \_name, %function
21 \_name:
22 .endm
23 .macro endfunc _name
24 .size \_name, .-\_name
25 .endm
26 
27 /**
28  * setjmp (jmp_buf env)
29  *
30  * See also:
31  *          longjmp
32  *
33  * @return 0 - if returns from direct call,
34  *         nonzero - if returns after longjmp.
35  */
36 func setjmp
37   stmia r0!, {r4 - r11, lr}
38   str sp, [r0], #4
39   vstm r0, {s16 - s31}
40   mov r0, #0
41   bx lr
42 endfunc setjmp
43 
44 /**
45  * longjmp (jmp_buf env, int val)
46  *
47  * Note:
48  *      if val is not 0, then it would be returned from setjmp,
49  *      otherwise - 0 would be returned.
50  *
51  * See also:
52  *          setjmp
53  */
54 func longjmp
55   ldmia r0!, {r4 - r11, lr}
56   ldr sp, [r0]
57   add r0, r0, #4
58   vldm r0, {s16 - s31}
59   mov r0, r1
60   cmp r0, #0
61   bne 1f
62   mov r0, #1
63   1:
64   bx lr
65 endfunc longjmp
66