Fix another x86 sys/ucontext.h namespace issue (bug 21457).
[glibc.git] / sysdeps / unix / sysv / linux / mmap.c
blobb1f229f19c0a976e1e8b7f1028a22efc005785a8
1 /* mmap - map files or devices into memory. Linux version.
2 Copyright (C) 2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <errno.h>
20 #include <unistd.h>
21 #include <sys/mman.h>
22 #include <sysdep.h>
23 #include <stdint.h>
24 #include <mmap_internal.h>
26 #ifndef __OFF_T_MATCHES_OFF64_T
28 /* An architecture may override this. */
29 # ifndef MMAP_ADJUST_OFFSET
30 # define MMAP_ADJUST_OFFSET(offset) offset
31 # endif
33 void *
34 __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
36 MMAP_CHECK_PAGE_UNIT ();
38 if (offset & MMAP_OFF_LOW_MASK)
39 return (__ptr_t) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
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
49 weak_alias (__mmap, mmap)
51 #endif /* __OFF_T_MATCHES_OFF64_T */