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. 162ceb2ce9SGarrett Wollman * 3. All advertising materials mentioning features or use of this software 172ceb2ce9SGarrett Wollman * must display the following acknowledgement: 182ceb2ce9SGarrett Wollman * This product includes software developed by the University of 192ceb2ce9SGarrett Wollman * California, Berkeley and its contributors. 202ceb2ce9SGarrett Wollman * 4. Neither the name of the University nor the names of its contributors 212ceb2ce9SGarrett Wollman * may be used to endorse or promote products derived from this software 222ceb2ce9SGarrett Wollman * without specific prior written permission. 232ceb2ce9SGarrett Wollman * 242ceb2ce9SGarrett Wollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 252ceb2ce9SGarrett Wollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 262ceb2ce9SGarrett Wollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 272ceb2ce9SGarrett Wollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 282ceb2ce9SGarrett Wollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 292ceb2ce9SGarrett Wollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 302ceb2ce9SGarrett Wollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 312ceb2ce9SGarrett Wollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 322ceb2ce9SGarrett Wollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 332ceb2ce9SGarrett Wollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 342ceb2ce9SGarrett Wollman * SUCH DAMAGE. 352ceb2ce9SGarrett Wollman * 36cbdc4399SJohn Polstra * $Id: sigsetjmp.S,v 1.7 1996/05/05 07:56:07 peter Exp $ 372ceb2ce9SGarrett Wollman */ 382ceb2ce9SGarrett Wollman 39717d9cddSDavid Greenman#if defined(LIBC_RCS) && !defined(lint) 40717d9cddSDavid Greenman .text 41cbdc4399SJohn Polstra .asciz "$Id: sigsetjmp.S,v 1.7 1996/05/05 07:56:07 peter Exp $" 42717d9cddSDavid Greenman#endif /* LIBC_RCS and not lint */ 432ceb2ce9SGarrett Wollman 442ceb2ce9SGarrett Wollman#include "DEFS.h" 452ceb2ce9SGarrett Wollman#include "SYS.h" 462ceb2ce9SGarrett Wollman 471a4206ddSBruce Evans/*- 481a4206ddSBruce Evans * TODO: 491a4206ddSBruce Evans * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, 501a4206ddSBruce Evans * remove the other *jmp functions and define everything in terms 511a4206ddSBruce Evans * of the renamed functions. This requires compiler support for 521a4206ddSBruce Evans * the renamed functions (introduced in gcc-2.5.3; previous versions 531a4206ddSBruce Evans * only supported *jmp with 0 or 1 leading underscores). 541a4206ddSBruce Evans * 551a4206ddSBruce Evans * Use sigprocmask() instead of sigblock() and sigsetmask(), and 561a4206ddSBruce Evans * check for and handle errors. 571a4206ddSBruce Evans * 581a4206ddSBruce Evans * Restore _all_ the registers and the signal mask atomically. Can 591a4206ddSBruce Evans * use sigreturn() if sigreturn() works. 601a4206ddSBruce Evans */ 611a4206ddSBruce Evans 62f70177e7SJulian Elischer#ifdef _THREAD_SAFE 63f70177e7SJulian ElischerENTRY(_thread_sys_sigsetjmp) 64f70177e7SJulian Elischer#else 652ceb2ce9SGarrett WollmanENTRY(sigsetjmp) 66f70177e7SJulian Elischer#endif 672ceb2ce9SGarrett Wollman movl 8(%esp),%eax 682ceb2ce9SGarrett Wollman movl 4(%esp),%ecx 691a4206ddSBruce Evans movl %eax,32(%ecx) 702ceb2ce9SGarrett Wollman testl %eax,%eax 71cbdc4399SJohn Polstra jz 2f 72f1703dfbSPeter Wemm PIC_PROLOGUE 732ceb2ce9SGarrett Wollman pushl $0 74f70177e7SJulian Elischer#ifdef _THREAD_SAFE 75f1703dfbSPeter Wemm call PIC_PLT(CNAME(_thread_sys_sigblock)) 76f70177e7SJulian Elischer#else 77f1703dfbSPeter Wemm call PIC_PLT(CNAME(sigblock)) 78f70177e7SJulian Elischer#endif 792ceb2ce9SGarrett Wollman addl $4,%esp 80f1703dfbSPeter Wemm PIC_EPILOGUE 812ceb2ce9SGarrett Wollman movl 4(%esp),%ecx 821a4206ddSBruce Evans movl %eax,24(%ecx) 83cbdc4399SJohn Polstra2: movl 0(%esp),%edx 842ceb2ce9SGarrett Wollman movl %edx, 0(%ecx) 852ceb2ce9SGarrett Wollman movl %ebx, 4(%ecx) 862ceb2ce9SGarrett Wollman movl %esp, 8(%ecx) 872ceb2ce9SGarrett Wollman movl %ebp,12(%ecx) 882ceb2ce9SGarrett Wollman movl %esi,16(%ecx) 892ceb2ce9SGarrett Wollman movl %edi,20(%ecx) 901a4206ddSBruce Evans fnstcw 28(%ecx) 912ceb2ce9SGarrett Wollman xorl %eax,%eax 922ceb2ce9SGarrett Wollman ret 932ceb2ce9SGarrett Wollman 94f70177e7SJulian Elischer#ifdef _THREAD_SAFE 95f70177e7SJulian ElischerENTRY(_thread_sys_siglongjmp) 96f70177e7SJulian Elischer#else 972ceb2ce9SGarrett WollmanENTRY(siglongjmp) 98f70177e7SJulian Elischer#endif 992ceb2ce9SGarrett Wollman movl 4(%esp),%edx 1001a4206ddSBruce Evans cmpl $0,32(%edx) 101cbdc4399SJohn Polstra jz 2f 102f1703dfbSPeter Wemm PIC_PROLOGUE 1031a4206ddSBruce Evans pushl 24(%edx) 104f70177e7SJulian Elischer#ifdef _THREAD_SAFE 105f1703dfbSPeter Wemm call PIC_PLT(CNAME(_thread_sys_sigsetmask)) 106f70177e7SJulian Elischer#else 107f1703dfbSPeter Wemm call PIC_PLT(CNAME(sigsetmask)) 108f70177e7SJulian Elischer#endif 1092ceb2ce9SGarrett Wollman addl $4,%esp 110f1703dfbSPeter Wemm PIC_EPILOGUE 111cbdc4399SJohn Polstra2: movl 4(%esp),%edx 1122ceb2ce9SGarrett Wollman movl 8(%esp),%eax 1132ceb2ce9SGarrett Wollman movl 0(%edx),%ecx 1142ceb2ce9SGarrett Wollman movl 4(%edx),%ebx 1152ceb2ce9SGarrett Wollman movl 8(%edx),%esp 1162ceb2ce9SGarrett Wollman movl 12(%edx),%ebp 1172ceb2ce9SGarrett Wollman movl 16(%edx),%esi 1182ceb2ce9SGarrett Wollman movl 20(%edx),%edi 1191a4206ddSBruce Evans fninit 1201a4206ddSBruce Evans fldcw 28(%edx) 1212ceb2ce9SGarrett Wollman testl %eax,%eax 122cbdc4399SJohn Polstra jnz 1f 1232ceb2ce9SGarrett Wollman incl %eax 124cbdc4399SJohn Polstra1: movl %ecx,0(%esp) 1252ceb2ce9SGarrett Wollman ret 126