make the linux-ppc packags be in synch with other platforms
[tangerine.git] / arch / x86_64-all / clib / setjmp.s
blob5eb8f653e6de5bdf18414d762abfa7e31c1fb9c0
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id: setjmp.s 12741 2001-12-08 18:16:08Z chodorowski $
5 Desc: ANSI C function 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 "aros/x86_64/asm.h"
61 .text
62 _ALIGNMENT
63 .globl AROS_CDEFNAME(setjmp)
64 _FUNCTION(AROS_CDEFNAME(setjmp))
66 .set retaddr, 0
68 AROS_CDEFNAME(setjmp):
69 /* Save stack pointer and all registers into env */
70 mov %rbx,8(%rdi) /* %ebx */
71 mov %rcx,16(%rdi) /* %ecx */
72 mov %rdx,24(%rdi) /* %edx */
73 mov %rsi,32(%rdi) /* %esi */
74 mov %rdi,40(%rdi) /* %edi */
75 mov %rbp,48(%rdi) /* %ebp */
76 mov %r8,56(%rdi)
77 mov %r9,64(%rdi)
78 mov %r10,72(%rdi)
79 mov %r11,80(%rdi)
80 mov %r12,88(%rdi)
81 mov %r13,96(%rdi)
82 mov %r14,104(%rdi)
83 mov %r15,112(%rdi)
84 mov %rsp,120(%rdi) /* %esp */
86 mov retaddr(%rsp),%rax /* Save return address (%esp has changed) */
87 mov %rax,0(%rdi)
89 xor %rax,%rax /* Return 0 */
90 ret