sigsetjmp.S revision 14118
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 3392999Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3492999Sobrien * SUCH DAMAGE. 3592999Sobrien * 3692999Sobrien * $Id: sigsetjmp.S,v 1.5 1996/01/22 00:00:54 julian Exp $ 3792999Sobrien */ 381849Swollman 391849Swollman#if defined(LIBC_RCS) && !defined(lint) 401849Swollman .text 41101536Skan .asciz "$Id: sigsetjmp.S,v 1.5 1996/01/22 00:00:54 julian Exp $" 4215634Speter#endif /* LIBC_RCS and not lint */ 4315634Speter 441849Swollman#include "DEFS.h" 451849Swollman#include "SYS.h" 46101536Skan 47101536Skan/*- 481849Swollman * TODO: 491849Swollman * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, 501849Swollman * remove the other *jmp functions and define everything in terms 511849Swollman * of the renamed functions. This requires compiler support for 521849Swollman * the renamed functions (introduced in gcc-2.5.3; previous versions 531849Swollman * only supported *jmp with 0 or 1 leading underscores). 5415634Speter * 551849Swollman * Use sigprocmask() instead of sigblock() and sigsetmask(), and 561849Swollman * check for and handle errors. 5711183Sphk * 5811183Sphk * Restore _all_ the registers and the signal mask atomically. Can 591849Swollman * use sigreturn() if sigreturn() works. 6087006Sjhb */ 6115634Speter 621849Swollman#ifdef _THREAD_SAFE 631849SwollmanENTRY(_thread_sys_sigsetjmp) 6415634Speter#else 651849SwollmanENTRY(sigsetjmp) 661849Swollman#endif 671849Swollman movl 8(%esp),%eax 6811183Sphk movl 4(%esp),%ecx 691849Swollman movl %eax,32(%ecx) 701849Swollman testl %eax,%eax 7115634Speter jz 1f 7215634Speter pushl $0 731849Swollman#ifdef _THREAD_SAFE 7411183Sphk call PIC_PLT(__thread_sys_sigblock) 751849Swollman#else 761849Swollman call PIC_PLT(_sigblock) 7715634Speter#endif 7811183Sphk addl $4,%esp 7911183Sphk movl 4(%esp),%ecx 801849Swollman movl %eax,24(%ecx) 8187006Sjhb1: movl 0(%esp),%edx 8215634Speter movl %edx, 0(%ecx) 831849Swollman movl %ebx, 4(%ecx) 8415634Speter movl %esp, 8(%ecx) 8515634Speter movl %ebp,12(%ecx) 8611183Sphk movl %esi,16(%ecx) 871849Swollman movl %edi,20(%ecx) 881849Swollman fnstcw 28(%ecx) 8915634Speter xorl %eax,%eax 9011183Sphk ret 91184548Speter 92217106Skib#ifdef _THREAD_SAFE 93217106SkibENTRY(_thread_sys_siglongjmp) 94#else 95ENTRY(siglongjmp) 96#endif 97 movl 4(%esp),%edx 98 cmpl $0,32(%edx) 99 jz 1f 100 pushl 24(%edx) 101#ifdef _THREAD_SAFE 102 call PIC_PLT(__thread_sys_sigsetmask) 103#else 104 call PIC_PLT(_sigsetmask) 105#endif 106 addl $4,%esp 1071: movl 4(%esp),%edx 108 movl 8(%esp),%eax 109 movl 0(%edx),%ecx 110 movl 4(%edx),%ebx 111 movl 8(%edx),%esp 112 movl 12(%edx),%ebp 113 movl 16(%edx),%esi 114 movl 20(%edx),%edi 115 fninit 116 fldcw 28(%edx) 117 testl %eax,%eax 118 jnz 2f 119 incl %eax 1202: movl %ecx,0(%esp) 121 ret 122