xref: /freebsd/lib/libc/i386/gen/sigsetjmp.S (revision dc36d6f9)
12ceb2ce9SGarrett Wollman/*-
22ceb2ce9SGarrett Wollman * Copyright (c) 1990 The Regents of the University of California.
32ceb2ce9SGarrett Wollman * All rights reserved.
42ceb2ce9SGarrett Wollman *
52ceb2ce9SGarrett Wollman * This code is derived from software contributed to Berkeley by
62ceb2ce9SGarrett Wollman * William Jolitz.
72ceb2ce9SGarrett Wollman *
82ceb2ce9SGarrett Wollman * Redistribution and use in source and binary forms, with or without
92ceb2ce9SGarrett Wollman * modification, are permitted provided that the following conditions
102ceb2ce9SGarrett Wollman * are met:
112ceb2ce9SGarrett Wollman * 1. Redistributions of source code must retain the above copyright
122ceb2ce9SGarrett Wollman *    notice, this list of conditions and the following disclaimer.
132ceb2ce9SGarrett Wollman * 2. Redistributions in binary form must reproduce the above copyright
142ceb2ce9SGarrett Wollman *    notice, this list of conditions and the following disclaimer in the
152ceb2ce9SGarrett Wollman *    documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors
172ceb2ce9SGarrett Wollman *    may be used to endorse or promote products derived from this software
182ceb2ce9SGarrett Wollman *    without specific prior written permission.
192ceb2ce9SGarrett Wollman *
202ceb2ce9SGarrett Wollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
212ceb2ce9SGarrett Wollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
222ceb2ce9SGarrett Wollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
232ceb2ce9SGarrett Wollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
242ceb2ce9SGarrett Wollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
252ceb2ce9SGarrett Wollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
262ceb2ce9SGarrett Wollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
272ceb2ce9SGarrett Wollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
282ceb2ce9SGarrett Wollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
292ceb2ce9SGarrett Wollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
302ceb2ce9SGarrett Wollman * SUCH DAMAGE.
312ceb2ce9SGarrett Wollman */
322ceb2ce9SGarrett Wollman
330f4f0285SDavid E. O'Brien#if defined(LIBC_SCCS) && !defined(lint)
34717d9cddSDavid Greenman	.text
350f4f0285SDavid E. O'Brien	.asciz "$Id: sigsetjmp.S,v 1.1 1993/12/05 13:01:05 ats Exp $"
360f4f0285SDavid E. O'Brien#endif /* LIBC_SCCS and not lint */
370f4f0285SDavid E. O'Brien#include <machine/asm.h>
382ceb2ce9SGarrett Wollman#include "SYS.h"
392ceb2ce9SGarrett Wollman
401a4206ddSBruce Evans/*-
411a4206ddSBruce Evans * TODO:
421a4206ddSBruce Evans *	Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,
431a4206ddSBruce Evans *	remove the other *jmp functions and define everything in terms
441a4206ddSBruce Evans *	of the renamed functions.  This requires compiler support for
451a4206ddSBruce Evans *	the renamed functions (introduced in gcc-2.5.3; previous versions
461a4206ddSBruce Evans *	only supported *jmp with 0 or 1 leading underscores).
471a4206ddSBruce Evans *
481a4206ddSBruce Evans *	Restore _all_ the registers and the signal mask atomically.  Can
491a4206ddSBruce Evans *	use sigreturn() if sigreturn() works.
501a4206ddSBruce Evans */
511a4206ddSBruce Evans
52bafd6b2fSJason EvansENTRY(sigsetjmp)
532ceb2ce9SGarrett Wollman	movl	8(%esp),%eax
542ceb2ce9SGarrett Wollman	movl	4(%esp),%ecx
553cf3c5d9SMarcel Moolenaar	movl	%eax,44(%ecx)
562ceb2ce9SGarrett Wollman	testl	%eax,%eax
57cbdc4399SJohn Polstra	jz	2f
583cf3c5d9SMarcel Moolenaar	leal	28(%ecx), %eax
593cf3c5d9SMarcel Moolenaar	pushl	%eax			/* (sigset_t*)oset */
603cf3c5d9SMarcel Moolenaar	pushl	$0			/* (sigset_t*)set  */
613cf3c5d9SMarcel Moolenaar	pushl	$1			/* SIG_BLOCK       */
62bd6060a1SKonstantin Belousov	call	__libc_sigprocmask
633cf3c5d9SMarcel Moolenaar	addl	$12,%esp
642ceb2ce9SGarrett Wollman	movl	4(%esp),%ecx
65cbdc4399SJohn Polstra2:	movl	0(%esp),%edx
662ceb2ce9SGarrett Wollman	movl	%edx, 0(%ecx)
672ceb2ce9SGarrett Wollman	movl	%ebx, 4(%ecx)
682ceb2ce9SGarrett Wollman	movl	%esp, 8(%ecx)
692ceb2ce9SGarrett Wollman	movl	%ebp,12(%ecx)
702ceb2ce9SGarrett Wollman	movl	%esi,16(%ecx)
712ceb2ce9SGarrett Wollman	movl	%edi,20(%ecx)
723cf3c5d9SMarcel Moolenaar	fnstcw	24(%ecx)
732ceb2ce9SGarrett Wollman	xorl	%eax,%eax
742ceb2ce9SGarrett Wollman	ret
75ed820052SPeter WemmEND(sigsetjmp)
762ceb2ce9SGarrett Wollman
77646c5b48SAndreas Tobler	WEAK_REFERENCE(__siglongjmp, siglongjmp)
78ed820052SPeter WemmENTRY(__siglongjmp)
792ceb2ce9SGarrett Wollman	movl	4(%esp),%edx
803cf3c5d9SMarcel Moolenaar	cmpl	$0,44(%edx)
81cbdc4399SJohn Polstra	jz	2f
823cf3c5d9SMarcel Moolenaar	pushl	$0			/* (sigset_t*)oset */
833cf3c5d9SMarcel Moolenaar	leal	28(%edx), %eax
843cf3c5d9SMarcel Moolenaar	pushl	%eax			/* (sigset_t*)set  */
853cf3c5d9SMarcel Moolenaar	pushl	$3			/* SIG_SETMASK     */
86bd6060a1SKonstantin Belousov	call	__libc_sigprocmask
873cf3c5d9SMarcel Moolenaar	addl	$12,%esp
883cf3c5d9SMarcel Moolenaar	movl	4(%esp),%edx
893cf3c5d9SMarcel Moolenaar2:	movl	8(%esp),%eax
902ceb2ce9SGarrett Wollman	movl	0(%edx),%ecx
912ceb2ce9SGarrett Wollman	movl	4(%edx),%ebx
922ceb2ce9SGarrett Wollman	movl	8(%edx),%esp
932ceb2ce9SGarrett Wollman	movl	12(%edx),%ebp
942ceb2ce9SGarrett Wollman	movl	16(%edx),%esi
952ceb2ce9SGarrett Wollman	movl	20(%edx),%edi
963cf3c5d9SMarcel Moolenaar	fldcw	24(%edx)
972ceb2ce9SGarrett Wollman	testl	%eax,%eax
98cbdc4399SJohn Polstra	jnz	1f
992ceb2ce9SGarrett Wollman	incl	%eax
100cbdc4399SJohn Polstra1:	movl	%ecx,0(%esp)
1012ceb2ce9SGarrett Wollman	ret
102ed820052SPeter WemmEND(__siglongjmp)
10393ab7586SKonstantin Belousov
10493ab7586SKonstantin Belousov	.section .note.GNU-stack,"",%progbits
105