Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / i386 / mmap.S
blob923c51b5b709cda16aaf4827719e02b1df0ffd8a
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
24         .text
26 ENTRY (__mmap)
28         /* Save registers.  */
29         pushl %ebp
30         cfi_adjust_cfa_offset (4)
31         pushl %ebx
32         cfi_adjust_cfa_offset (4)
33         pushl %esi
34         cfi_adjust_cfa_offset (4)
35         pushl %edi
36         cfi_adjust_cfa_offset (4)
38         movl 20(%esp), %ebx
39         cfi_rel_offset (ebx, 8)
40         movl 24(%esp), %ecx
41         movl 28(%esp), %edx
42         movl 32(%esp), %esi
43         cfi_rel_offset (esi, 4)
44         movl 36(%esp), %edi
45         cfi_rel_offset (edi, 0)
46         movl 40(%esp), %ebp
47         cfi_rel_offset (ebp, 12)
48         testl $0xfff, %ebp
49         movl $-EINVAL, %eax
50         jne L(skip)
51         shrl $12, %ebp                  /* mmap2 takes the offset in pages.  */
53         movl $SYS_ify(mmap2), %eax      /* System call number in %eax.  */
55         /* Do the system call trap.  */
56         ENTER_KERNEL
57 L(skip):
58         /* Restore registers.  */
59         popl %edi
60         cfi_adjust_cfa_offset (-4)
61         cfi_restore (edi)
62         popl %esi
63         cfi_adjust_cfa_offset (-4)
64         cfi_restore (esi)
65         popl %ebx
66         cfi_adjust_cfa_offset (-4)
67         cfi_restore (ebx)
68         popl %ebp
69         cfi_adjust_cfa_offset (-4)
70         cfi_restore (ebp)
72         /* If 0 > %eax > -4096 there was an error.  */
73         cmpl $-4096, %eax
74         ja SYSCALL_ERROR_LABEL
76         /* Successful; return the syscall's value.  */
77         ret
79 PSEUDO_END (__mmap)
81 weak_alias (__mmap, mmap)