/*-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#include <machine/asm.h>33/*34* C library -- _setjmp, _longjmp35*36* _longjmp(a,v)37* will generate a "return(v)" from the last call to38* _setjmp(a)39* by restoring registers from the environment 'a'.40* The previous signal state is NOT restored.41*/4243ENTRY(_setjmp)44movq %rdi,%rax45movq 0(%rsp),%rdx /* return address */46movq %rdx, 0(%rax) /* 0; return address */47movq %rbx, 8(%rax) /* 1; rbx */48movq %rsp,16(%rax) /* 2; rsp */49movq %rbp,24(%rax) /* 3; rbp */50movq %r12,32(%rax) /* 4; r12 */51movq %r13,40(%rax) /* 5; r13 */52movq %r14,48(%rax) /* 6; r14 */53movq %r15,56(%rax) /* 7; r15 */54fnstcw 64(%rax) /* 8; fpu cw */55stmxcsr 68(%rax) /* and mxcsr */56xorq %rax,%rax57ret58END(_setjmp)5960WEAK_REFERENCE(___longjmp, _longjmp)61ENTRY(___longjmp)62movq %rdi,%rdx63/* Restore the mxcsr, but leave exception flags intact. */64stmxcsr -4(%rsp)65movl 68(%rdx),%eax66andl $0xffffffc0,%eax67movl -4(%rsp),%edi68andl $0x3f,%edi69xorl %eax,%edi70movl %edi,-4(%rsp)71ldmxcsr -4(%rsp)72movq %rsi,%rax /* retval */73movq 0(%rdx),%rcx74movq 8(%rdx),%rbx75movq 16(%rdx),%rsp76movq 24(%rdx),%rbp77movq 32(%rdx),%r1278movq 40(%rdx),%r1379movq 48(%rdx),%r1480movq 56(%rdx),%r1581fldcw 64(%rdx)82testq %rax,%rax83jnz 1f84incq %rax851: movq %rcx,0(%rsp) /* return address */86ret87END(___longjmp)8889.section .note.GNU-stack,"",%progbits909192