Reimplemented setjmp(). It no longer offsets the caller's esp.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25428 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,7 +7,6 @@ local genericSources =
|
|||||||
;
|
;
|
||||||
|
|
||||||
MergeObject posix_arch_$(TARGET_ARCH).o :
|
MergeObject posix_arch_$(TARGET_ARCH).o :
|
||||||
setjmp.S
|
|
||||||
sigsetjmp.S
|
sigsetjmp.S
|
||||||
siglongjmp.S
|
siglongjmp.S
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "setjmp_internal.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* int setjmp(jmp_buf buffer) */
|
|
||||||
FUNCTION(setjmp):
|
|
||||||
pop %eax // pop argument and return pointer from stack
|
|
||||||
pop %ecx
|
|
||||||
pushl $0 // push new argument (for saveMask) and old stuff
|
|
||||||
push %ecx // back onto the stack
|
|
||||||
push %eax
|
|
||||||
jmp __sigsetjmp // let sigsetjmp() do the actual work
|
|
||||||
|
|
||||||
#pragma weak _setjmp=setjmp
|
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -15,23 +16,45 @@
|
|||||||
* if it was asked to do this.
|
* if it was asked to do this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* int sigsetjmp(jmp_buf buffer, int saveMask) */
|
/* int sigsetjmp(jmp_buf buffer, int saveMask) */
|
||||||
FUNCTION(__sigsetjmp):
|
FUNCTION(__sigsetjmp):
|
||||||
FUNCTION(sigsetjmp):
|
FUNCTION(sigsetjmp):
|
||||||
|
// return address to %edx, stack pointer for return to %ecx (both are
|
||||||
|
// scratch registers)
|
||||||
|
mov 0(%esp), %edx
|
||||||
|
lea 4(%esp), %ecx
|
||||||
|
|
||||||
|
// buffer to %eax
|
||||||
mov 4(%esp), %eax
|
mov 4(%esp), %eax
|
||||||
|
|
||||||
// fill __jmp_buf structure with current registers (%ecx can be clobbered)
|
sigsetjmp_setjmp_entry:
|
||||||
|
// fill __jmp_buf structure with current registers
|
||||||
mov %ebx, JMP_REGS_EBX(%eax)
|
mov %ebx, JMP_REGS_EBX(%eax)
|
||||||
mov %esi, JMP_REGS_ESI(%eax)
|
mov %esi, JMP_REGS_ESI(%eax)
|
||||||
mov %edi, JMP_REGS_EDI(%eax)
|
mov %edi, JMP_REGS_EDI(%eax)
|
||||||
mov %ebp, JMP_REGS_EBP(%eax)
|
mov %ebp, JMP_REGS_EBP(%eax)
|
||||||
|
|
||||||
// save stack and return address (because that's where we intend to jump to)
|
// save stack and return address (because that's where we intend to jump to)
|
||||||
lea 4(%esp,1), %ecx
|
|
||||||
mov %ecx, JMP_REGS_ESP(%eax)
|
mov %ecx, JMP_REGS_ESP(%eax)
|
||||||
mov 0(%esp), %ecx
|
mov %edx, JMP_REGS_PC(%eax)
|
||||||
mov %ecx, JMP_REGS_PC(%eax)
|
|
||||||
|
|
||||||
jmp __setjmp_save_sigs
|
jmp __setjmp_save_sigs
|
||||||
|
|
||||||
|
|
||||||
|
/* int setjmp(jmp_buf buffer) */
|
||||||
|
FUNCTION(setjmp):
|
||||||
|
// prepare %edx, %ecx, and %eax for sigsetjmp
|
||||||
|
mov 0(%esp), %edx
|
||||||
|
lea 4(%esp), %ecx
|
||||||
|
mov (%ecx), %eax
|
||||||
|
|
||||||
|
// let sigsetjmp do the real work
|
||||||
|
pushl $0 // saveMask
|
||||||
|
push %eax // buffer
|
||||||
|
call sigsetjmp_setjmp_entry
|
||||||
|
add $8, %esp
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
#pragma weak _setjmp=setjmp
|
||||||
|
|||||||
Reference in New Issue
Block a user