xref: /haiku/src/system/libroot/posix/arch/x86/sigsetjmp.S (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
1/*
2 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "setjmp_internal.h"
8
9
10/**	This is a BeOS compatible __sigsetjmp() implementation; there,
11 *	setjmp() and sigsetjmp() are both macros to this function.
12 *
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.
16 */
17
18
19/* int sigsetjmp(jmp_buf buffer, int saveMask) */
20FUNCTION(__sigsetjmp):
21FUNCTION(sigsetjmp):
22	mov		4(%esp), %eax
23
24	// fill __jmp_buf structure with current registers (%ecx can be clobbered)
25	mov		%ebx, JMP_REGS_EBX(%eax)
26	mov		%esi, JMP_REGS_ESI(%eax)
27	mov		%edi, JMP_REGS_EDI(%eax)
28	mov		%ebp, JMP_REGS_EBP(%eax)
29
30	// save stack and return address (because that's where we intend to jump to)
31	lea		4(%esp,1), %ecx
32	mov		%ecx, JMP_REGS_ESP(%eax)
33	mov		0(%esp), %ecx
34	mov		%ecx, JMP_REGS_PC(%eax)
35
36	jmp		__setjmp_save_sigs
37
38