sigsetjmp.S revision 92999
1214921Scognet/*-
2214921Scognet * Copyright (c) 1990 The Regents of the University of California.
3214921Scognet * All rights reserved.
4214921Scognet *
5214921Scognet * This code is derived from software contributed to Berkeley by
6214921Scognet * William Jolitz.
7214921Scognet *
8214921Scognet * Redistribution and use in source and binary forms, with or without
9214921Scognet * modification, are permitted provided that the following conditions
10214921Scognet * are met:
11214921Scognet * 1. Redistributions of source code must retain the above copyright
12214921Scognet *    notice, this list of conditions and the following disclaimer.
13214921Scognet * 2. Redistributions in binary form must reproduce the above copyright
14214921Scognet *    notice, this list of conditions and the following disclaimer in the
15214921Scognet *    documentation and/or other materials provided with the distribution.
16214921Scognet * 3. All advertising materials mentioning features or use of this software
17214921Scognet *    must display the following acknowledgement:
18214921Scognet *	This product includes software developed by the University of
19214921Scognet *	California, Berkeley and its contributors.
20214921Scognet * 4. Neither the name of the University nor the names of its contributors
21214921Scognet *    may be used to endorse or promote products derived from this software
22214921Scognet *    without specific prior written permission.
23214921Scognet *
24214921Scognet * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25214921Scognet * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26214921Scognet * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27214921Scognet * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28214921Scognet * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29214921Scognet * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30214921Scognet * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31214921Scognet * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32214921Scognet * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33214921Scognet * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34214921Scognet * SUCH DAMAGE.
35214921Scognet *
36214921Scognet *	@(#)setjmp.s	5.1 (Berkeley) 4/23/90"
37214921Scognet */
38214921Scognet
39214921Scognet#if defined(LIBC_SCCS) && !defined(lint)
40214921Scognet	.text
41214921Scognet	.asciz "$Id: sigsetjmp.S,v 1.1 1993/12/05 13:01:05 ats Exp $"
42214921Scognet#endif /* LIBC_SCCS and not lint */
43214921Scognet#include <machine/asm.h>
44214921Scognet__FBSDID("$FreeBSD: head/lib/libc/amd64/gen/sigsetjmp.S 92999 2002-03-23 02:10:28Z obrien $");
45214921Scognet
46214921Scognet#include "SYS.h"
47214921Scognet
48214921Scognet/*-
49214921Scognet * TODO:
50214921Scognet *	Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,
51214921Scognet *	remove the other *jmp functions and define everything in terms
52214921Scognet *	of the renamed functions.  This requires compiler support for
53214921Scognet *	the renamed functions (introduced in gcc-2.5.3; previous versions
54214921Scognet *	only supported *jmp with 0 or 1 leading underscores).
55214921Scognet *
56214921Scognet *	Restore _all_ the registers and the signal mask atomically.  Can
57214921Scognet *	use sigreturn() if sigreturn() works.
58214921Scognet */
59214921Scognet
60214921ScognetENTRY(sigsetjmp)
61214921Scognet	movl	8(%esp),%eax
62214921Scognet	movl	4(%esp),%ecx
63214921Scognet	movl	%eax,44(%ecx)
64214921Scognet	testl	%eax,%eax
65214921Scognet	jz	2f
66214921Scognet	PIC_PROLOGUE
67214921Scognet	leal	28(%ecx), %eax
68214921Scognet	pushl	%eax			/* (sigset_t*)oset */
69214921Scognet	pushl	$0			/* (sigset_t*)set  */
70214921Scognet	pushl	$1			/* SIG_BLOCK       */
71214921Scognet	call	PIC_PLT(CNAME(_sigprocmask))
72214921Scognet	addl	$12,%esp
73214921Scognet	PIC_EPILOGUE
74214921Scognet	movl	4(%esp),%ecx
75214921Scognet2:	movl	0(%esp),%edx
76214921Scognet	movl	%edx, 0(%ecx)
77214921Scognet	movl	%ebx, 4(%ecx)
78214921Scognet	movl	%esp, 8(%ecx)
79214921Scognet	movl	%ebp,12(%ecx)
80214921Scognet	movl	%esi,16(%ecx)
81214921Scognet	movl	%edi,20(%ecx)
82214921Scognet	fnstcw	24(%ecx)
83214921Scognet	xorl	%eax,%eax
84214921Scognet	ret
85214921Scognet
86214921Scognet	.weak CNAME(siglongjmp);
87214921Scognet	.set CNAME(siglongjmp),CNAME(__siglongjmp);
88214921ScognetENTRY(__siglongjmp);
89214921Scognet	movl	4(%esp),%edx
90214921Scognet	cmpl	$0,44(%edx)
91214921Scognet	jz	2f
92214921Scognet	PIC_PROLOGUE
93214921Scognet	pushl	$0			/* (sigset_t*)oset */
94214921Scognet	leal	28(%edx), %eax
95214921Scognet	pushl	%eax			/* (sigset_t*)set  */
96214921Scognet	pushl	$3			/* SIG_SETMASK     */
97214921Scognet	call	PIC_PLT(CNAME(_sigprocmask))
98214921Scognet	addl	$12,%esp
99214921Scognet	PIC_EPILOGUE
100214921Scognet	movl	4(%esp),%edx
101214921Scognet2:	movl	8(%esp),%eax
102214921Scognet	movl	0(%edx),%ecx
103214921Scognet	movl	4(%edx),%ebx
104214921Scognet	movl	8(%edx),%esp
105214921Scognet	movl	12(%edx),%ebp
106214921Scognet	movl	16(%edx),%esi
107214921Scognet	movl	20(%edx),%edi
108214921Scognet	fninit
109214921Scognet	fldcw	24(%edx)
110214921Scognet	testl	%eax,%eax
111214921Scognet	jnz	1f
112214921Scognet	incl	%eax
113214921Scognet1:	movl	%ecx,0(%esp)
114214921Scognet	ret
115214921Scognet