sigsetjmp.S revision 85437
166550Snyan/*-
266550Snyan * Copyright (c) 1990 The Regents of the University of California.
366550Snyan * All rights reserved.
4139749Simp *
5139749Simp * This code is derived from software contributed to Berkeley by
666550Snyan * William Jolitz.
766550Snyan *
866550Snyan * Redistribution and use in source and binary forms, with or without
966550Snyan * modification, are permitted provided that the following conditions
1066550Snyan * are met:
1166550Snyan * 1. Redistributions of source code must retain the above copyright
1266550Snyan *    notice, this list of conditions and the following disclaimer.
1366550Snyan * 2. Redistributions in binary form must reproduce the above copyright
1466550Snyan *    notice, this list of conditions and the following disclaimer in the
1566550Snyan *    documentation and/or other materials provided with the distribution.
1666550Snyan * 3. All advertising materials mentioning features or use of this software
1766550Snyan *    must display the following acknowledgement:
1866550Snyan *	This product includes software developed by the University of
1966550Snyan *	California, Berkeley and its contributors.
2066550Snyan * 4. Neither the name of the University nor the names of its contributors
2166550Snyan *    may be used to endorse or promote products derived from this software
2266550Snyan *    without specific prior written permission.
2366550Snyan *
2466550Snyan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2566550Snyan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2666550Snyan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2766550Snyan * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2866550Snyan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2966550Snyan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3066550Snyan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3166550Snyan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3266550Snyan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3366550Snyan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3466550Snyan * SUCH DAMAGE.
3566550Snyan */
3666550Snyan
3766550Snyan#if defined(LIBC_RCS) && !defined(lint)
3866550Snyan	.text
3966550Snyan	.asciz "$FreeBSD: head/lib/libc/amd64/gen/sigsetjmp.S 85437 2001-10-24 20:29:14Z peter $"
4066550Snyan#endif /* LIBC_RCS and not lint */
4166550Snyan
4266550Snyan#include "SYS.h"
4392739Salfred
4466550Snyan/*-
4592739Salfred * TODO:
4692739Salfred *	Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,
4792739Salfred *	remove the other *jmp functions and define everything in terms
4892739Salfred *	of the renamed functions.  This requires compiler support for
4966550Snyan *	the renamed functions (introduced in gcc-2.5.3; previous versions
5092739Salfred *	only supported *jmp with 0 or 1 leading underscores).
5192739Salfred *
5266550Snyan *	Restore _all_ the registers and the signal mask atomically.  Can
5366550Snyan *	use sigreturn() if sigreturn() works.
5466550Snyan */
5592739Salfred
5666550SnyanENTRY(sigsetjmp)
5792739Salfred	movl	8(%esp),%eax
5866550Snyan	movl	4(%esp),%ecx
5992739Salfred	movl	%eax,44(%ecx)
6092739Salfred	testl	%eax,%eax
6192739Salfred	jz	2f
6266550Snyan	PIC_PROLOGUE
6366550Snyan	leal	28(%ecx), %eax
6492739Salfred	pushl	%eax			/* (sigset_t*)oset */
6592739Salfred	pushl	$0			/* (sigset_t*)set  */
6666550Snyan	pushl	$1			/* SIG_BLOCK       */
6792739Salfred	call	PIC_PLT(CNAME(_sigprocmask))
6892739Salfred	addl	$12,%esp
6966550Snyan	PIC_EPILOGUE
7066550Snyan	movl	4(%esp),%ecx
7192739Salfred2:	movl	0(%esp),%edx
7292739Salfred	movl	%edx, 0(%ecx)
7366550Snyan	movl	%ebx, 4(%ecx)
7492739Salfred	movl	%esp, 8(%ecx)
7566550Snyan	movl	%ebp,12(%ecx)
7666550Snyan	movl	%esi,16(%ecx)
7792739Salfred	movl	%edi,20(%ecx)
7866550Snyan	fnstcw	24(%ecx)
79	xorl	%eax,%eax
80	ret
81
82	.weak CNAME(siglongjmp);
83	.set CNAME(siglongjmp),CNAME(__siglongjmp);
84ENTRY(__siglongjmp);
85	movl	4(%esp),%edx
86	cmpl	$0,44(%edx)
87	jz	2f
88	PIC_PROLOGUE
89	pushl	$0			/* (sigset_t*)oset */
90	leal	28(%edx), %eax
91	pushl	%eax			/* (sigset_t*)set  */
92	pushl	$3			/* SIG_SETMASK     */
93	call	PIC_PLT(CNAME(_sigprocmask))
94	addl	$12,%esp
95	PIC_EPILOGUE
96	movl	4(%esp),%edx
972:	movl	8(%esp),%eax
98	movl	0(%edx),%ecx
99	movl	4(%edx),%ebx
100	movl	8(%edx),%esp
101	movl	12(%edx),%ebp
102	movl	16(%edx),%esi
103	movl	20(%edx),%edi
104	fninit
105	fldcw	24(%edx)
106	testl	%eax,%eax
107	jnz	1f
108	incl	%eax
1091:	movl	%ecx,0(%esp)
110	ret
111