Wanderer/Info: fix compilation
[AROS.git] / arch / .unmaintained / m68k-emul / clib / setjmp.s
blob4edada93828722b8b9b6d7d969af719715e6efde
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 move.l env(%sp),%a0 /* save area pointer */
71 move.l retaddr(%sp),(%a0)+ /* save old PC */
72 lea.l env(%sp),%a1 /* adjust saved SP since we won't rts */
73 move.l %a1,(%a0)+ /* save old SP */
74 movem.l %d2-%d7/%a2-%a6,(%a0) /* save remaining non-scratch regs */
75 clr.l %d0 /* return 0 */
76 rts
79 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
81 _jmp_buf offset contents
82 [0] 0 old pc
83 [1] 4 old sp
84 [2] 8 d2
85 [3] 12 d3
86 [4] 16 d4
87 [5] 20 d5
88 [6] 24 d6
89 [7] 28 d7
90 [8] 32 a2
91 [9] 36 a3
92 [10] 40 a4
93 [11] 44 a5
94 [12] 48 a6