2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: ANSI C function longjmp()
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 ******************************************************************************/
62 #include "aros/x86_64/asm.h"
66 .globl AROS_CDEFNAME(longjmp)
67 _FUNCTION
(AROS_CDEFNAME
(longjmp
))
69 .set FirstArg, 8 /* Skip Return-Adress */
74 AROS_CDEFNAME
(longjmp
):
75 /* Make sure return value is not 0 */
82 /* Get the location of the bottom of the stack */
83 mov SysBase
(%rip
),%rax
84 mov ThisTask
(%rax
),%rax
85 mov tc_SPLower
(%rax
),%rax
87 /* Restore top of altstack */
93 /* Restore stack pointer and all registers from env */
94 mov
120(%rax
),%rsp
/* Restore original stack */
97 mov
%rcx
,retaddr
(%rsp
) /* Restore return address */
99 push
%rsi
/* Save return value on new stack */
101 /* Restore all registers */
102 mov
8(%rax
),%rbx
/* %ebx */
103 mov
16(%rax
),%rcx
/* %ecx */
104 mov
24(%rax
),%rdx
/* %edx */
105 mov
32(%rax
),%rsi
/* %esi */
106 mov
40(%rax
),%rdi
/* %edi */
107 mov
48(%rax
),%rbp
/* %ebp */
117 pop
%rax
/* Fetch return value */