2.9
[glibc/nacl-glibc.git] / sysdeps / x86_64 / __longjmp.S
bloba68e7a8a4f1e6d0a9544d52c19248706d2336279
1 /* Copyright (C) 2001,2004,2005,2006 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
19 #include <sysdep.h>
20 #include <jmpbuf-offsets.h>
21 #include <asm-syntax.h>
23 /* Jump to the position specified by ENV, causing the
24    setjmp call there to return VAL, or 1 if VAL is 0.
25    void __longjmp (__jmp_buf env, int val).  */
26 ENTRY(__longjmp)
27         /* Restore registers.  */
28         movq (JB_RSP*8)(%rdi),%r8
29         movq (JB_RBP*8)(%rdi),%r9
30         movq (JB_PC*8)(%rdi),%rdx
31 #ifdef PTR_DEMANGLE
32         PTR_DEMANGLE (%r8)
33         PTR_DEMANGLE (%r9)
34         PTR_DEMANGLE (%rdx)
35 #endif
36         /* We add unwind information for the target here.  */
37         cfi_def_cfa(%rdi, 0)
38         cfi_register(%rsp,%r8)
39         cfi_register(%rbp,%r9)
40         cfi_register(%rip,%rdx)
41         cfi_offset(%rbx,JB_RBX*8)
42         cfi_offset(%rbp,JB_RBP*8)
43         cfi_offset(%r12,JB_R12*8)
44         cfi_offset(%r13,JB_R13*8)
45         cfi_offset(%r14,JB_R14*8)
46         cfi_offset(%r15,JB_R15*8)
47         movq (JB_RBX*8)(%rdi),%rbx
48         movq (JB_R12*8)(%rdi),%r12
49         movq (JB_R13*8)(%rdi),%r13
50         movq (JB_R14*8)(%rdi),%r14
51         movq (JB_R15*8)(%rdi),%r15
52         /* Set return value for setjmp.  */
53         mov %esi, %eax
54         movq %r8,%rsp
55         movq %r9,%rbp
56         jmpq *%rdx
57 END (BP_SYM (__longjmp))