Wanderer/Info: fix compilation
[AROS.git] / arch / .unmaintained / m68k-linux / clib / setjmp.s
blob1bd7617dec398fee23e3955e75588aeea0777436
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: setjmp
6 Lang: english
7 */
9 /******************************************************************************
11 NAME
12 #include <setjmp.h>
14 int setjmp (jmp_buf env);
16 FUNCTION
17 Save the current context so that you can return to it later.
19 INPUTS
20 env - The context/environment is saved here for later restoring
22 RESULT
23 0 if it returns from setjmp() and 1 when it returns from longjmp().
25 NOTES
27 EXAMPLE
28 jmp_buf env;
30 ... some code ...
32 if (!setjmp (env))
34 ... this code is executed after setjmp() returns ...
36 // This is no good example on how to use this function
37 // You should not do that
38 if (error)
39 longjmp (env, 5);
41 ... some code ...
43 else
45 ... this code is executed if you call longjmp(env) ...
48 BUGS
50 SEE ALSO
51 longjmp()
53 INTERNALS
55 HISTORY
57 ******************************************************************************/
59 #include "machine.i"
61 #define FirstArg 4 /* Skip Return-Address */
62 #define env FirstArg
63 #define retaddr 0
65 .text
66 .balign 16
67 .globl AROS_CDEFNAME(setjmp)
68 .type AROS_CDEFNAME(setjmp),@function
69 AROS_CDEFNAME(setjmp):
70 #ifdef OLDJMP
71 move.l env(%sp),%a0 /* save area pointer */
72 move.l retaddr(%sp),(%a0)+ /* save old PC */
73 lea.l env(%sp),%a1 /* adjust saved SP since we won't rts */
74 move.l %a1,(%a0)+ /* save old SP */
75 movem.l %d2-%d7/%a2-%a6,(%a0) /* save remaining non-scratch regs */
76 clr.l %d0 /* return 0 */
77 rts
78 #else
79 move.l env(%sp),%a0 /* get address of jmp_buf */
80 move.l (%sp),(%a0)+ /* store return address */
81 movem.l %d2-%d7/%a2-%a6/%sp,(%a0) /* store all registers except scratch */
82 moveq.l #0,%d0 /* return 0 */
83 rts
84 #endif
87 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
89 _jmp_buf offset contents
90 [0] 0 old pc
91 [1] 4 d2
92 [2] 8 d3
93 [3] 12 d4
94 [4] 16 d5
95 [5] 20 d6
96 [6] 24 d7
97 [7] 28 a2
98 [8] 32 a3
99 [9] 36 a4
100 [10] 40 a5
101 [11] 44 a6
102 [12] 48 old sp