setjmp/longjmp: Also store *(SysBase->ThisTask->tc_SPLower) in jmpbuf
[AROS.git] / arch / i386-all / clib / vfork_longjmp.s
blobc18b3a55a2500b59cf3ddeca5c8069ea9fa74d74
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* This function works the same as longjmp() except it lacks the argument
7 check. It's used only by vfork() implementation. */
9 #include "aros/i386/asm.h"
11 .text
12 _ALIGNMENT
13 .globl AROS_CDEFNAME(vfork_longjmp)
14 _FUNCTION(AROS_CDEFNAME(vfork_longjmp))
16 .set FirstArg, 4 /* Skip Return-Adress */
17 .set env, FirstArg
18 .set val, env+4
19 .set retaddr, 0
21 AROS_CDEFNAME(vfork_longjmp):
22 /* Fetch the address of the env-structure off the stack.
23 The address is stored in %eax which is not preserved
24 because it's contents are overwritten anyway by the
25 return code */
26 movl env(%esp),%eax
27 movl val(%esp),%ebx
29 /* Restore stack pointer and all registers from env */
30 movl 28(%eax),%esp /* Restore original stack */
32 movl 0(%eax),%ecx
33 movl %ecx,retaddr(%esp) /* Restore return address */
35 pushl %ebx /* Save return value on new stack */
37 /* Restore *(SysBase->ThisTask->tc_SPLower) */
38 movl SysBase,%ebx
39 movl ThisTask(%ebx),%ebx
40 movl tc_SPLower(%ebx),%ebx
41 movl 32(%eax),%edx
42 movl %edx,(%ebx)
43 /* Restore all registers */
44 movl 4(%eax),%ebx /* %ebx */
45 movl 8(%eax),%ecx /* %ecx */
46 movl 12(%eax),%edx /* %edx */
47 movl 16(%eax),%esi /* %esi */
48 movl 20(%eax),%edi /* %edi */
49 movl 24(%eax),%ebp /* %ebp */
51 popl %eax /* Fetch return value */
52 ret