]>
Commit | Line | Data |
---|---|---|
158d5fa0 AZ |
1 | /* mmap - map files or devices into memory. Linux version. |
2 | Copyright (C) 2017 Free Software Foundation, Inc. | |
83c01ab3 L |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
17 | <http://www.gnu.org/licenses/>. */ | |
18 | ||
83c01ab3 | 19 | #include <errno.h> |
158d5fa0 AZ |
20 | #include <unistd.h> |
21 | #include <sys/mman.h> | |
83c01ab3 | 22 | #include <sysdep.h> |
158d5fa0 AZ |
23 | #include <stdint.h> |
24 | #include <mmap_internal.h> | |
83c01ab3 | 25 | |
158d5fa0 | 26 | #ifndef __OFF_T_MATCHES_OFF64_T |
83c01ab3 | 27 | |
158d5fa0 AZ |
28 | /* An architecture may override this. */ |
29 | # ifndef MMAP_ADJUST_OFFSET | |
30 | # define MMAP_ADJUST_OFFSET(offset) offset | |
31 | # endif | |
32 | ||
33 | void * | |
34 | __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) | |
83c01ab3 | 35 | { |
158d5fa0 AZ |
36 | MMAP_CHECK_PAGE_UNIT (); |
37 | ||
38 | if (offset & MMAP_OFF_LOW_MASK) | |
f17a4233 | 39 | return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); |
83c01ab3 | 40 | |
158d5fa0 AZ |
41 | #ifdef __NR_mmap2 |
42 | return (void *) MMAP_CALL (mmap2, addr, len, prot, flags, fd, | |
43 | offset / (uint32_t) MMAP2_PAGE_UNIT); | |
44 | #else | |
45 | return (void *) MMAP_CALL (mmap, addr, len, prot, flags, fd, | |
46 | MMAP_ADJUST_OFFSET (offset)); | |
47 | #endif | |
48 | } | |
83c01ab3 | 49 | weak_alias (__mmap, mmap) |
fa872e1b | 50 | libc_hidden_def (__mmap) |
158d5fa0 AZ |
51 | |
52 | #endif /* __OFF_T_MATCHES_OFF64_T */ |