sigsetjmp.S revision 92999
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. 3592999Sobrien * 3692999Sobrien * @(#)setjmp.s 5.1 (Berkeley) 4/23/90" 371849Swollman */ 381849Swollman 3992999Sobrien#if defined(LIBC_SCCS) && !defined(lint) 405790Sdg .text 4192999Sobrien .asciz "$Id: sigsetjmp.S,v 1.1 1993/12/05 13:01:05 ats Exp $" 4292999Sobrien#endif /* LIBC_SCCS and not lint */ 4392999Sobrien#include <machine/asm.h> 4492999Sobrien__FBSDID("$FreeBSD: head/lib/libc/amd64/gen/sigsetjmp.S 92999 2002-03-23 02:10:28Z obrien $"); 451849Swollman 461849Swollman#include "SYS.h" 471849Swollman 483851Sbde/*- 493851Sbde * TODO: 503851Sbde * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, 513851Sbde * remove the other *jmp functions and define everything in terms 523851Sbde * of the renamed functions. This requires compiler support for 533851Sbde * the renamed functions (introduced in gcc-2.5.3; previous versions 543851Sbde * only supported *jmp with 0 or 1 leading underscores). 553851Sbde * 563851Sbde * Restore _all_ the registers and the signal mask atomically. Can 573851Sbde * use sigreturn() if sigreturn() works. 583851Sbde */ 593851Sbde 6056345SjasoneENTRY(sigsetjmp) 611849Swollman movl 8(%esp),%eax 6251794Smarcel movl 4(%esp),%ecx 6351794Smarcel movl %eax,44(%ecx) 641849Swollman testl %eax,%eax 6515731Sjdp jz 2f 6615634Speter PIC_PROLOGUE 6751794Smarcel leal 28(%ecx), %eax 6851794Smarcel pushl %eax /* (sigset_t*)oset */ 6951794Smarcel pushl $0 /* (sigset_t*)set */ 7051794Smarcel pushl $1 /* SIG_BLOCK */ 7171579Sdeischen call PIC_PLT(CNAME(_sigprocmask)) 7251794Smarcel addl $12,%esp 7315634Speter PIC_EPILOGUE 7451794Smarcel movl 4(%esp),%ecx 7515731Sjdp2: movl 0(%esp),%edx 761849Swollman movl %edx, 0(%ecx) 771849Swollman movl %ebx, 4(%ecx) 781849Swollman movl %esp, 8(%ecx) 791849Swollman movl %ebp,12(%ecx) 801849Swollman movl %esi,16(%ecx) 811849Swollman movl %edi,20(%ecx) 8251794Smarcel fnstcw 24(%ecx) 831849Swollman xorl %eax,%eax 841849Swollman ret 851849Swollman 8671579Sdeischen .weak CNAME(siglongjmp); 8771579Sdeischen .set CNAME(siglongjmp),CNAME(__siglongjmp); 8859933SjasoneENTRY(__siglongjmp); 891849Swollman movl 4(%esp),%edx 9051794Smarcel cmpl $0,44(%edx) 9115731Sjdp jz 2f 9215634Speter PIC_PROLOGUE 9351794Smarcel pushl $0 /* (sigset_t*)oset */ 9451794Smarcel leal 28(%edx), %eax 9551794Smarcel pushl %eax /* (sigset_t*)set */ 9651794Smarcel pushl $3 /* SIG_SETMASK */ 9771579Sdeischen call PIC_PLT(CNAME(_sigprocmask)) 9851794Smarcel addl $12,%esp 9915634Speter PIC_EPILOGUE 10051794Smarcel movl 4(%esp),%edx 10151794Smarcel2: movl 8(%esp),%eax 1021849Swollman movl 0(%edx),%ecx 1031849Swollman movl 4(%edx),%ebx 1041849Swollman movl 8(%edx),%esp 1051849Swollman movl 12(%edx),%ebp 1061849Swollman movl 16(%edx),%esi 1071849Swollman movl 20(%edx),%edi 1083851Sbde fninit 10951794Smarcel fldcw 24(%edx) 1101849Swollman testl %eax,%eax 11115731Sjdp jnz 1f 1121849Swollman incl %eax 11315731Sjdp1: movl %ecx,0(%esp) 1141849Swollman ret 115