2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
14 int setjmp (jmp_buf env);
17 Save the current context so that you can return to it later.
20 env - The context/environment is saved here for later restoring
23 0 if it returns from setjmp() and 1 when it returns from longjmp().
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
45 ... this code is executed if you call longjmp(env) ...
57 ******************************************************************************/
59 #include "../include/aros/machine.i"
65 .set FirstArg, 4 /* Skip Return-Adress */
71 move.
l env
(%sp
),%a0
/* save area pointer */
72 move.
l retaddr
(%sp
),(%a0
)+ /* save old PC (return address) */
73 lea 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 */
79 /* New version adapted from libnix instead of ixemul.
80 * Note the slightly different register save order.
82 move.
l 4(%sp
),%a0
/* get address of jmp_buf */
83 move.
l (%sp
),(%a0
)+ /* store return address */
84 movem.
l %d2-
%d7
/%a2-
%a6
/%sp
,(%a0
) /* store all registers except scratch */
85 moveq.
l #0,%d0 /* return 0 */
90 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
92 _jmp_buf offset contents