1 /* Copyright (C) 1995-2012 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/>. */
22 #include <kernel-features.h>
27 #define SVRSP 16 /* saved register space */
28 #define PARMS LINKAGE+SVRSP /* space for 4 saved regs */
30 #define LEN ADDR+PTR_SIZE
38 ENTRY (BP_SYM (__mmap64))
44 cfi_adjust_cfa_offset (4)
46 cfi_adjust_cfa_offset (4)
48 cfi_adjust_cfa_offset (4)
50 cfi_adjust_cfa_offset (4)
52 movl OFFLO(%esp), %edx
53 movl OFFHI(%esp), %ecx
56 shrdl $12, %ecx, %edx /* mmap2 takes the offset in pages. */
60 cfi_rel_offset (ebp, 12)
63 cfi_rel_offset (ebx, 8)
66 movl FLAGS(%esp), %esi
67 cfi_rel_offset (esi, 4)
69 cfi_rel_offset (edi, 0)
71 movl $SYS_ify(mmap2), %eax /* System call number in %eax. */
73 /* Do the system call trap. */
77 /* Restore registers. */
79 cfi_adjust_cfa_offset (-4)
82 cfi_adjust_cfa_offset (-4)
85 cfi_adjust_cfa_offset (-4)
88 cfi_adjust_cfa_offset (-4)
91 #ifndef __ASSUME_MMAP2_SYSCALL
97 /* If 0 > %eax > -4096 there was an error. */
99 ja SYSCALL_ERROR_LABEL
101 /* Successful; return the syscall's value. */
104 cfi_adjust_cfa_offset (16)
105 cfi_rel_offset (ebp, 12)
106 cfi_rel_offset (ebx, 8)
107 cfi_rel_offset (esi, 4)
108 cfi_rel_offset (edi, 0)
109 /* This means the offset value is too large. */
112 cfi_adjust_cfa_offset (-4)
115 cfi_adjust_cfa_offset (-4)
118 cfi_adjust_cfa_offset (-4)
121 cfi_adjust_cfa_offset (-4)
124 jmp SYSCALL_ERROR_LABEL
127 #if !defined __ASSUME_MMAP2_SYSCALL || !defined __NR_mmap2
129 /* Save registers. */
131 cfi_register (ebx, edx)
133 cmpl $0, OFFHI-SVRSP(%esp)
136 movl $SYS_ify(mmap), %eax /* System call number in %eax. */
138 lea ADDR-SVRSP(%esp), %ebx /* Address of args is 1st arg. */
140 /* Do the system call trap. */
143 /* Restore registers. */
147 /* If 0 > %eax > -4096 there was an error. */
149 ja SYSCALL_ERROR_LABEL
151 /* Successful; return the syscall's value. */
154 cfi_register (ebx, edx)
159 jmp SYSCALL_ERROR_LABEL
162 PSEUDO_END (BP_SYM (__mmap64))
164 weak_alias (BP_SYM (__mmap64), BP_SYM (mmap64))