/*-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 /* retval */46movq %rdx, 0(%rax) /* 0; retval */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)5960ENTRY(_longjmp)61movq %rdi,%rdx62/* Restore the mxcsr, but leave exception flags intact. */63stmxcsr -4(%rsp)64movl 68(%rdx),%eax65andl $0xffffffc0,%eax66movl -4(%rsp),%edi67andl $0x3f,%edi68xorl %eax,%edi69movl %edi,-4(%rsp)70ldmxcsr -4(%rsp)71movq %rsi,%rax /* retval */72movq 0(%rdx),%rcx73movq 8(%rdx),%rbx74movq 16(%rdx),%rsp75movq 24(%rdx),%rbp76movq 32(%rdx),%r1277movq 40(%rdx),%r1378movq 48(%rdx),%r1479movq 56(%rdx),%r1580fldcw 64(%rdx)81testq %rax,%rax82jnz 1f83incq %rax841: movq %rcx,0(%rsp)85ret86END(_longjmp)8788.section .note.GNU-stack,"",%progbits899091