small amendment
[AROS.git] / arch / i386-all / posixc / sigsetjmp.s
bloba7b7cd407e0bfffb57c25211eccb4a55123ff1ae
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ANSI C function sigsetjmp()
6 Lang: english
7 */
9 /******************************************************************************
11 NAME
12 #include <setjmp.h>
14 int sigsetjmp (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 sigsetjmp() and 1 when it returns from longjmp().
25 NOTES
27 EXAMPLE
28 jmp_buf env;
30 ... some code ...
32 if (!sigsetjmp (env))
34 ... this code is executed after sigsetjmp() 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/i386/asm.h"
61 .text
62 _ALIGNMENT
63 .globl AROS_CDEFNAME(sigsetjmp)
64 _FUNCTION(AROS_CDEFNAME(sigsetjmp))
66 .set FirstArg, 4 /* Skip Return-Adress */
67 .set env, FirstArg
69 AROS_CDEFNAME(sigsetjmp):
70 /* Fetch the address of the env-structure off the stack.
71 The address is stored in %eax which is not preserved
72 because it's contents are overwritten anyway by the
73 return code */
74 movl env(%esp),%eax
76 /* Save stack pointer and all registers into env */
77 movl %ebx,4(%eax) /* %ebx */
78 movl %ecx,8(%eax) /* %ecx */
79 movl %edx,12(%eax) /* %edx */
80 movl %esi,16(%eax) /* %esi */
81 movl %edi,20(%eax) /* %edi */
82 movl %ebp,24(%eax) /* %ebp */
83 movl %esp,28(%eax) /* %esp */
85 pushl %ebx
87 movl retaddr+4(%esp), %ebx /* Save return address (%esp has changed) */
88 movl %ebx,0(%eax)
90 popl %ebx
92 xorl %eax,%eax /* Return 0 */
93 ret