2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
14 void longjmp (jmp_buf env, int val);
17 Save the current context so that you can return to it later.
20 env - The context/environment to restore
21 val - This value is returned by setjmp() when you return to the
22 saved context. You cannot return 0. If val is 0, then
23 setjmp() returns with 1.
26 This function doesn't return.
37 ... this code is executed after setjmp() returns ...
39 // This is no good example on how to use this function
40 // You should not do that
48 ... this code is executed if you call longjmp(env) ...
60 ******************************************************************************/
64 #define FirstArg 4 /* Skip Return-Adress */
66 #define val FirstArg+4
70 .globl AROS_CDEFNAME(longjmp)
71 .type AROS_CDEFNAME(longjmp),@function
72 AROS_CDEFNAME
(longjmp
):
74 move.
l env
(%sp
),%a0
/* save area pointer */
77 moveq.
l #1,%d0 /* make sure it isn't 0 */
79 move.
l 4(%a0
),%sp
/* restore SP */
80 move.
l 0(%a0
),(%sp
) /* restore PC */
81 movem.
l 8(%a0
),%d2-
%d7
/%a2-
%a6
/* restore remaining non-scratch regs */
84 addq.w
#4,%sp /* returns to other address */
85 move.
l (%sp
)+,%a0
/* get address of jmp_buf */
86 move.
l (%sp
)+,%d0
/* get return code */
88 moveq.
l #1,%d0 /* make sure it isn't 0 */
90 move.
l 48(%sp
),%sp
/* restore sp */
91 move.
l (%a0
)+,(%sp
) /* set return address */
92 movem.
l (%a0
),%d2-
%d7
/%a2-
%a6
/* restore all other registers */
97 The jmp_buf is filled as follows (d0/d1/a0/a1 are not saved):
99 _jmp_buf offset contents