2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4 * Distributed under the terms of the MIT License.
7 #include "setjmp_internal.h"
10 /** This is a BeOS compatible __sigsetjmp() implementation; there,
11 * setjmp() and sigsetjmp() are both macros to this function.
13 * It first saves the register/stack environment of the running thread,
14 * and then calls __setjmp_save_sigs() which will save the signal state
15 * if it was asked to do this.
18 /* int sigsetjmp(jmp_buf buffer, int saveMask) */
19 FUNCTION(__sigsetjmp):
21 // return address to %edx, stack pointer for return to %ecx (both are
29 sigsetjmp_setjmp_entry:
30 // fill __jmp_buf structure with current registers
31 mov %ebx, JMP_REGS_EBX(%eax)
32 mov %esi, JMP_REGS_ESI(%eax)
33 mov %edi, JMP_REGS_EDI(%eax)
34 mov %ebp, JMP_REGS_EBP(%eax)
36 // save stack and return address (because that's where we intend to jump to)
37 mov %ecx, JMP_REGS_ESP(%eax)
38 mov %edx, JMP_REGS_PC(%eax)
40 jmp __setjmp_save_sigs
41 FUNCTION_END(sigsetjmp)
44 /* int setjmp(jmp_buf buffer) */
46 // prepare %edx, %ecx, and %eax for sigsetjmp
51 // let sigsetjmp do the real work
54 call sigsetjmp_setjmp_entry
61 #pragma weak _setjmp=setjmp