sigsetjmp.S revision 15634
11849Swollman/*-
21849Swollman * Copyright (c) 1990 The Regents of the University of California.
31849Swollman * All rights reserved.
41849Swollman *
51849Swollman * This code is derived from software contributed to Berkeley by
61849Swollman * William Jolitz.
71849Swollman *
81849Swollman * Redistribution and use in source and binary forms, with or without
91849Swollman * modification, are permitted provided that the following conditions
101849Swollman * are met:
111849Swollman * 1. Redistributions of source code must retain the above copyright
121849Swollman *    notice, this list of conditions and the following disclaimer.
131849Swollman * 2. Redistributions in binary form must reproduce the above copyright
141849Swollman *    notice, this list of conditions and the following disclaimer in the
151849Swollman *    documentation and/or other materials provided with the distribution.
161849Swollman * 3. All advertising materials mentioning features or use of this software
171849Swollman *    must display the following acknowledgement:
181849Swollman *	This product includes software developed by the University of
191849Swollman *	California, Berkeley and its contributors.
201849Swollman * 4. Neither the name of the University nor the names of its contributors
211849Swollman *    may be used to endorse or promote products derived from this software
221849Swollman *    without specific prior written permission.
231849Swollman *
241849Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251849Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261849Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271849Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
281849Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
291849Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
301849Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311849Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321849Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
331849Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
341849Swollman * SUCH DAMAGE.
351849Swollman *
3615634Speter *	$Id: sigsetjmp.S,v 1.6 1996/02/17 12:25:21 peter Exp $
371849Swollman */
381849Swollman
395790Sdg#if defined(LIBC_RCS) && !defined(lint)
405790Sdg	.text
4115634Speter	.asciz "$Id: sigsetjmp.S,v 1.6 1996/02/17 12:25:21 peter Exp $"
425790Sdg#endif /* LIBC_RCS and not lint */
431849Swollman
441849Swollman#include "DEFS.h"
451849Swollman#include "SYS.h"
461849Swollman
473851Sbde/*-
483851Sbde * TODO:
493851Sbde *	Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,
503851Sbde *	remove the other *jmp functions and define everything in terms
513851Sbde *	of the renamed functions.  This requires compiler support for
523851Sbde *	the renamed functions (introduced in gcc-2.5.3; previous versions
533851Sbde *	only supported *jmp with 0 or 1 leading underscores).
543851Sbde *
553851Sbde *	Use sigprocmask() instead of sigblock() and sigsetmask(), and
563851Sbde *	check for and handle errors.
573851Sbde *
583851Sbde *	Restore _all_ the registers and the signal mask atomically.  Can
593851Sbde *	use sigreturn() if sigreturn() works.
603851Sbde */
613851Sbde
6213545Sjulian#ifdef _THREAD_SAFE
6313545SjulianENTRY(_thread_sys_sigsetjmp)
6413545Sjulian#else
651849SwollmanENTRY(sigsetjmp)
6613545Sjulian#endif
671849Swollman	movl	8(%esp),%eax
681849Swollman	movl	4(%esp),%ecx
693851Sbde	movl	%eax,32(%ecx)
701849Swollman	testl	%eax,%eax
711849Swollman	jz	1f
7215634Speter	PIC_PROLOGUE
731849Swollman	pushl	$0
7413545Sjulian#ifdef _THREAD_SAFE
7515634Speter	call	PIC_PLT(CNAME(_thread_sys_sigblock))
7613545Sjulian#else
7715634Speter	call	PIC_PLT(CNAME(sigblock))
7813545Sjulian#endif
791849Swollman	addl	$4,%esp
8015634Speter	PIC_EPILOGUE
811849Swollman	movl	4(%esp),%ecx
823851Sbde	movl	%eax,24(%ecx)
831849Swollman1:	movl	0(%esp),%edx
841849Swollman	movl	%edx, 0(%ecx)
851849Swollman	movl	%ebx, 4(%ecx)
861849Swollman	movl	%esp, 8(%ecx)
871849Swollman	movl	%ebp,12(%ecx)
881849Swollman	movl	%esi,16(%ecx)
891849Swollman	movl	%edi,20(%ecx)
903851Sbde	fnstcw	28(%ecx)
911849Swollman	xorl	%eax,%eax
921849Swollman	ret
931849Swollman
9413545Sjulian#ifdef _THREAD_SAFE
9513545SjulianENTRY(_thread_sys_siglongjmp)
9613545Sjulian#else
971849SwollmanENTRY(siglongjmp)
9813545Sjulian#endif
991849Swollman	movl	4(%esp),%edx
1003851Sbde	cmpl	$0,32(%edx)
1011849Swollman	jz	1f
10215634Speter	PIC_PROLOGUE
1033851Sbde	pushl	24(%edx)
10413545Sjulian#ifdef _THREAD_SAFE
10515634Speter	call	PIC_PLT(CNAME(_thread_sys_sigsetmask))
10613545Sjulian#else
10715634Speter	call	PIC_PLT(CNAME(sigsetmask))
10813545Sjulian#endif
1091849Swollman	addl	$4,%esp
11015634Speter	PIC_EPILOGUE
1111849Swollman1:	movl	4(%esp),%edx
1121849Swollman	movl	8(%esp),%eax
1131849Swollman	movl	0(%edx),%ecx
1141849Swollman	movl	4(%edx),%ebx
1151849Swollman	movl	8(%edx),%esp
1161849Swollman	movl	12(%edx),%ebp
1171849Swollman	movl	16(%edx),%esi
1181849Swollman	movl	20(%edx),%edi
1193851Sbde	fninit
1203851Sbde	fldcw	28(%edx)
1211849Swollman	testl	%eax,%eax
1221849Swollman	jnz	2f
1231849Swollman	incl	%eax
1241849Swollman2:	movl	%ecx,0(%esp)
1251849Swollman	ret
126