/*-1* Copyright (c) 1990 The Regents of the University of California.2* All rights reserved.3*4* This code is derived from software contributed to Berkeley by5* William Jolitz.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15* 3. Neither the name of the University nor the names of its contributors16* may be used to endorse or promote products derived from this software17* without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*/3132#if defined(LIBC_SCCS) && !defined(lint)33.text34.asciz "$Id: sigsetjmp.S,v 1.1 1993/12/05 13:01:05 ats Exp $"35#endif /* LIBC_SCCS and not lint */36#include <machine/asm.h>37#include "SYS.h"3839/*-40* TODO:41* Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,42* remove the other *jmp functions and define everything in terms43* of the renamed functions. This requires compiler support for44* the renamed functions (introduced in gcc-2.5.3; previous versions45* only supported *jmp with 0 or 1 leading underscores).46*47* Restore _all_ the registers and the signal mask atomically. Can48* use sigreturn() if sigreturn() works.49*/5051ENTRY(sigsetjmp)52movl %esi,88(%rdi) /* 11; savemask */53testl %esi,%esi54jz 2f55pushq %rdi56movq %rdi,%rcx57movq $1,%rdi /* SIG_BLOCK */58movq $0,%rsi /* (sigset_t*)set */59leaq 72(%rcx),%rdx /* 9,10 (sigset_t*)oset */60/* stack is 16-byte aligned */61call __libc_sigprocmask62popq %rdi632: movq %rdi,%rcx64movq 0(%rsp),%rdx /* return address */65movq %rdx, 0(%rcx) /* 0; return address */66movq %rbx, 8(%rcx) /* 1; rbx */67movq %rsp,16(%rcx) /* 2; rsp */68movq %rbp,24(%rcx) /* 3; rbp */69movq %r12,32(%rcx) /* 4; r12 */70movq %r13,40(%rcx) /* 5; r13 */71movq %r14,48(%rcx) /* 6; r14 */72movq %r15,56(%rcx) /* 7; r15 */73fnstcw 64(%rcx) /* 8; fpu cw */74xorq %rax,%rax75ret76END(sigsetjmp)7778WEAK_REFERENCE(__siglongjmp, siglongjmp)79ENTRY(__siglongjmp)80cmpl $0,88(%rdi)81jz 2f82movq %rdi,%rdx83pushq %rdi84pushq %rsi85movq $3,%rdi /* SIG_SETMASK */86leaq 72(%rdx),%rsi /* (sigset_t*)set */87movq $0,%rdx /* (sigset_t*)oset */88subq $0x8,%rsp /* make the stack 16-byte aligned */89call __libc_sigprocmask90addq $0x8,%rsp91popq %rsi92popq %rdi /* jmpbuf */932: movq %rdi,%rdx94movq %rsi,%rax /* retval */95movq 0(%rdx),%rcx96movq 8(%rdx),%rbx97movq 16(%rdx),%rsp98movq 24(%rdx),%rbp99movq 32(%rdx),%r12100movq 40(%rdx),%r13101movq 48(%rdx),%r14102movq 56(%rdx),%r15103fldcw 64(%rdx)104testq %rax,%rax105jnz 1f106incq %rax1071: movq %rcx,0(%rsp) /* return address */108ret109END(__siglongjmp)110111.section .note.GNU-stack,"",%progbits112113114