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