Add <sys/auxv.h> and getauxval.
[glibc.git] / sysdeps / i386 / __longjmp.S
blob264eb7e0d2a4e3adc3b3553f0f61ddca19f9e11f
1 /* longjmp for i386.
2    Copyright (C) 1995-1998,2000,2002,2005,2006,2009
3    Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
21 #include <jmpbuf-offsets.h>
22 #include <asm-syntax.h>
24         .text
25 ENTRY (__longjmp)
26 #ifdef PTR_DEMANGLE
27         movl 4(%esp), %eax      /* User's jmp_buf in %eax.  */
29         /* Save the return address now.  */
30         movl (JB_PC*4)(%eax), %edx
31         /* Get the stack pointer.  */
32         movl (JB_SP*4)(%eax), %ecx
33         PTR_DEMANGLE (%edx)
34         PTR_DEMANGLE (%ecx)
35         cfi_def_cfa(%eax, 0)
36         cfi_register(%eip, %edx)
37         cfi_register(%esp, %ecx)
38         cfi_offset(%ebx, JB_BX*4)
39         cfi_offset(%esi, JB_SI*4)
40         cfi_offset(%edi, JB_DI*4)
41         cfi_offset(%ebp, JB_BP*4)
42         /* Restore registers.  */
43         movl (JB_BX*4)(%eax), %ebx
44         movl (JB_SI*4)(%eax), %esi
45         movl (JB_DI*4)(%eax), %edi
46         movl (JB_BP*4)(%eax), %ebp
47         cfi_restore(%ebx)
48         cfi_restore(%esi)
49         cfi_restore(%edi)
50         cfi_restore(%ebp)
52         movl 8(%esp), %eax      /* Second argument is return value.  */
53         movl %ecx, %esp
54 #else
55         movl 4(%esp), %ecx      /* User's jmp_buf in %ecx.  */
56         movl 8(%esp), %eax      /* Second argument is return value.  */
57         /* Save the return address now.  */
58         movl (JB_PC*4)(%ecx), %edx
59         /* Restore registers.  */
60         movl (JB_BX*4)(%ecx), %ebx
61         movl (JB_SI*4)(%ecx), %esi
62         movl (JB_DI*4)(%ecx), %edi
63         movl (JB_BP*4)(%ecx), %ebp
64         movl (JB_SP*4)(%ecx), %esp
65 #endif
66         /* Jump to saved PC.  */
67         jmp *%edx
68 END (__longjmp)