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 ******************************************************************************/
63 .globl AROS_CDEFNAME(setjmp)
64 .type AROS_CDEFNAME(setjmp),@function
66 .set FirstArg, 4 /* Skip Return-Adress */
70 AROS_CDEFNAME
(setjmp
):
72 move.
l env
(sp
),a0
/* save area pointer */
73 move.
l retaddr
(sp
),(a0
)+ /* save old PC (return address) */
74 lea env
(sp
),a1
/* adjust saved SP since we won't rts */
75 move.
l a1
,(a0
)+ /* save old SP */
76 movem.
l d2-d7
/a2-a6
,(a0
) /* save remaining non-scratch regs */
77 clr.
l d0
/* return 0 */
80 /* New version adapted from libnix instead of ixemul.
81 * Note the slightly different register save order.
83 move.
l 4(sp
),a0
/* get address of jmp_buf */
84 move.
l (sp
),(a0
)+ /* store return address */
85 movem.
l d2-d7
/a2-a6
/sp
,(a0
) /* store all registers except scratch */
86 moveq.
l #0,d0 /* return 0 */
91 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
93 _jmp_buf offset contents