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 * 4. Neither the name of the University nor the names of its contributors 171849Swollman * may be used to endorse or promote products derived from this software 181849Swollman * without specific prior written permission. 191849Swollman * 201849Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211849Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221849Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231849Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241849Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251849Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261849Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271849Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281849Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291849Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301849Swollman * SUCH DAMAGE. 3192999Sobrien * 3292999Sobrien * @(#)setjmp.s 5.1 (Berkeley) 4/23/90" 331849Swollman */ 341849Swollman 3592999Sobrien#if defined(LIBC_SCCS) && !defined(lint) 365790Sdg .text 3792999Sobrien .asciz "$Id: sigsetjmp.S,v 1.1 1993/12/05 13:01:05 ats Exp $" 3892999Sobrien#endif /* LIBC_SCCS and not lint */ 3992999Sobrien#include <machine/asm.h> 4092999Sobrien__FBSDID("$FreeBSD$"); 411849Swollman 421849Swollman#include "SYS.h" 431849Swollman 443851Sbde/*- 453851Sbde * TODO: 463851Sbde * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, 473851Sbde * remove the other *jmp functions and define everything in terms 483851Sbde * of the renamed functions. This requires compiler support for 493851Sbde * the renamed functions (introduced in gcc-2.5.3; previous versions 503851Sbde * only supported *jmp with 0 or 1 leading underscores). 513851Sbde * 523851Sbde * Restore _all_ the registers and the signal mask atomically. Can 533851Sbde * use sigreturn() if sigreturn() works. 543851Sbde */ 553851Sbde 5656345SjasoneENTRY(sigsetjmp) 571849Swollman movl 8(%esp),%eax 5851794Smarcel movl 4(%esp),%ecx 5951794Smarcel movl %eax,44(%ecx) 601849Swollman testl %eax,%eax 6115731Sjdp jz 2f 6215634Speter PIC_PROLOGUE 63227024Skib#ifdef PIC 64227024Skib subl $12,%esp /* make the stack 16-byte aligned */ 65227024Skib#endif 6651794Smarcel leal 28(%ecx), %eax 6751794Smarcel pushl %eax /* (sigset_t*)oset */ 6851794Smarcel pushl $0 /* (sigset_t*)set */ 6951794Smarcel pushl $1 /* SIG_BLOCK */ 7071579Sdeischen call PIC_PLT(CNAME(_sigprocmask)) 71227024Skib#ifdef PIC 72227024Skib addl $24,%esp 73227024Skib#else 7451794Smarcel addl $12,%esp 75227024Skib#endif 7615634Speter PIC_EPILOGUE 7751794Smarcel movl 4(%esp),%ecx 7815731Sjdp2: movl 0(%esp),%edx 791849Swollman movl %edx, 0(%ecx) 801849Swollman movl %ebx, 4(%ecx) 811849Swollman movl %esp, 8(%ecx) 821849Swollman movl %ebp,12(%ecx) 831849Swollman movl %esi,16(%ecx) 841849Swollman movl %edi,20(%ecx) 8551794Smarcel fnstcw 24(%ecx) 861849Swollman xorl %eax,%eax 871849Swollman ret 88184548SpeterEND(sigsetjmp) 891849Swollman 9071579Sdeischen .weak CNAME(siglongjmp); 91184548Speter .set CNAME(siglongjmp),CNAME(__siglongjmp) 92184548SpeterENTRY(__siglongjmp) 931849Swollman movl 4(%esp),%edx 9451794Smarcel cmpl $0,44(%edx) 9515731Sjdp jz 2f 9615634Speter PIC_PROLOGUE 97227024Skib#ifdef PIC 98227024Skib subl $12,%esp /* make the stack 16-byte aligned */ 99227024Skib#endif 10051794Smarcel pushl $0 /* (sigset_t*)oset */ 10151794Smarcel leal 28(%edx), %eax 10251794Smarcel pushl %eax /* (sigset_t*)set */ 10351794Smarcel pushl $3 /* SIG_SETMASK */ 10471579Sdeischen call PIC_PLT(CNAME(_sigprocmask)) 105227024Skib#ifdef PIC 106227024Skib addl $24,%esp 107227024Skib#else 10851794Smarcel addl $12,%esp 109227024Skib#endif 11015634Speter PIC_EPILOGUE 11151794Smarcel movl 4(%esp),%edx 11251794Smarcel2: 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 12051794Smarcel fldcw 24(%edx) 1211849Swollman testl %eax,%eax 12215731Sjdp jnz 1f 1231849Swollman incl %eax 12415731Sjdp1: movl %ecx,0(%esp) 1251849Swollman ret 126184548SpeterEND(__siglongjmp) 127217106Skib 128217106Skib .section .note.GNU-stack,"",%progbits 129