Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / i386 / mmap64.S
blob3cf6eb9a354cfd1618d719dd5cc005a9d8b179ca
1 /* Copyright (C) 1995-2015 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, see
16    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
20 #define EINVAL  22
21 #define ENOSYS  38
23 #define SVRSP   16              /* saved register space */
24 #define PARMS   4+SVRSP /* space for 4 saved regs */
25 #define ADDR    PARMS
26 #define LEN     ADDR+4
27 #define PROT    LEN+4
28 #define FLAGS   PROT+4
29 #define FD      FLAGS+4
30 #define OFFLO   FD+4
31 #define OFFHI   OFFLO+4
33         .text
34 ENTRY (__mmap64)
36         /* Save registers.  */
37         pushl %ebp
38         cfi_adjust_cfa_offset (4)
39         pushl %ebx
40         cfi_adjust_cfa_offset (4)
41         pushl %esi
42         cfi_adjust_cfa_offset (4)
43         pushl %edi
44         cfi_adjust_cfa_offset (4)
46         movl OFFLO(%esp), %edx
47         movl OFFHI(%esp), %ecx
48         testl $0xfff, %edx
49         jne L(einval)
50         shrdl $12, %ecx, %edx           /* mmap2 takes the offset in pages.  */
51         shrl $12, %ecx
52         jne L(einval)
53         movl %edx, %ebp
54         cfi_rel_offset (ebp, 12)
56         movl ADDR(%esp), %ebx
57         cfi_rel_offset (ebx, 8)
58         movl LEN(%esp), %ecx
59         movl PROT(%esp), %edx
60         movl FLAGS(%esp), %esi
61         cfi_rel_offset (esi, 4)
62         movl FD(%esp), %edi
63         cfi_rel_offset (edi, 0)
65         movl $SYS_ify(mmap2), %eax      /* System call number in %eax.  */
67         /* Do the system call trap.  */
68 L(do_syscall):
69         ENTER_KERNEL
71         /* Restore registers.  */
72         popl %edi
73         cfi_adjust_cfa_offset (-4)
74         cfi_restore (edi)
75         popl %esi
76         cfi_adjust_cfa_offset (-4)
77         cfi_restore (esi)
78         popl %ebx
79         cfi_adjust_cfa_offset (-4)
80         cfi_restore (ebx)
81         popl %ebp
82         cfi_adjust_cfa_offset (-4)
83         cfi_restore (ebp)
85         /* If 0 > %eax > -4096 there was an error.  */
86         cmpl $-4096, %eax
87         ja SYSCALL_ERROR_LABEL
89         /* Successful; return the syscall's value.  */
90         ret
92         cfi_adjust_cfa_offset (16)
93         cfi_rel_offset (ebp, 12)
94         cfi_rel_offset (ebx, 8)
95         cfi_rel_offset (esi, 4)
96         cfi_rel_offset (edi, 0)
97         /* This means the offset value is too large.  */
98 L(einval):
99         popl %edi
100         cfi_adjust_cfa_offset (-4)
101         cfi_restore (edi)
102         popl %esi
103         cfi_adjust_cfa_offset (-4)
104         cfi_restore (esi)
105         popl %ebx
106         cfi_adjust_cfa_offset (-4)
107         cfi_restore (ebx)
108         popl %ebp
109         cfi_adjust_cfa_offset (-4)
110         cfi_restore (ebp)
111         movl $-EINVAL, %eax
112         jmp SYSCALL_ERROR_LABEL
114 PSEUDO_END (__mmap64)
116 weak_alias (__mmap64, mmap64)