]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/i386/mmap64.S
Remove __ASSUME_MMAP2_SYSCALL.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / mmap64.S
1 /* Copyright (C) 1995-2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
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/>. */
17
18 #include <sysdep.h>
19 #include <bp-sym.h>
20 #include <bp-asm.h>
21
22 #include <kernel-features.h>
23
24 #define EINVAL 22
25 #define ENOSYS 38
26
27 #define SVRSP 16 /* saved register space */
28 #define PARMS LINKAGE+SVRSP /* space for 4 saved regs */
29 #define ADDR PARMS
30 #define LEN ADDR+PTR_SIZE
31 #define PROT LEN+4
32 #define FLAGS PROT+4
33 #define FD FLAGS+4
34 #define OFFLO FD+4
35 #define OFFHI OFFLO+4
36
37 .text
38 ENTRY (BP_SYM (__mmap64))
39
40 /* Save registers. */
41 pushl %ebp
42 cfi_adjust_cfa_offset (4)
43 pushl %ebx
44 cfi_adjust_cfa_offset (4)
45 pushl %esi
46 cfi_adjust_cfa_offset (4)
47 pushl %edi
48 cfi_adjust_cfa_offset (4)
49
50 movl OFFLO(%esp), %edx
51 movl OFFHI(%esp), %ecx
52 testl $0xfff, %edx
53 jne L(einval)
54 shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */
55 shrl $12, %ecx
56 jne L(einval)
57 movl %edx, %ebp
58 cfi_rel_offset (ebp, 12)
59
60 movl ADDR(%esp), %ebx
61 cfi_rel_offset (ebx, 8)
62 movl LEN(%esp), %ecx
63 movl PROT(%esp), %edx
64 movl FLAGS(%esp), %esi
65 cfi_rel_offset (esi, 4)
66 movl FD(%esp), %edi
67 cfi_rel_offset (edi, 0)
68
69 movl $SYS_ify(mmap2), %eax /* System call number in %eax. */
70
71 /* Do the system call trap. */
72 L(do_syscall):
73 ENTER_KERNEL
74
75 /* Restore registers. */
76 popl %edi
77 cfi_adjust_cfa_offset (-4)
78 cfi_restore (edi)
79 popl %esi
80 cfi_adjust_cfa_offset (-4)
81 cfi_restore (esi)
82 popl %ebx
83 cfi_adjust_cfa_offset (-4)
84 cfi_restore (ebx)
85 popl %ebp
86 cfi_adjust_cfa_offset (-4)
87 cfi_restore (ebp)
88
89 /* If 0 > %eax > -4096 there was an error. */
90 cmpl $-4096, %eax
91 ja SYSCALL_ERROR_LABEL
92
93 /* Successful; return the syscall's value. */
94 ret
95
96 cfi_adjust_cfa_offset (16)
97 cfi_rel_offset (ebp, 12)
98 cfi_rel_offset (ebx, 8)
99 cfi_rel_offset (esi, 4)
100 cfi_rel_offset (edi, 0)
101 /* This means the offset value is too large. */
102 L(einval):
103 popl %edi
104 cfi_adjust_cfa_offset (-4)
105 cfi_restore (edi)
106 popl %esi
107 cfi_adjust_cfa_offset (-4)
108 cfi_restore (esi)
109 popl %ebx
110 cfi_adjust_cfa_offset (-4)
111 cfi_restore (ebx)
112 popl %ebp
113 cfi_adjust_cfa_offset (-4)
114 cfi_restore (ebp)
115 movl $-EINVAL, %eax
116 jmp SYSCALL_ERROR_LABEL
117
118 PSEUDO_END (BP_SYM (__mmap64))
119
120 weak_alias (BP_SYM (__mmap64), BP_SYM (mmap64))