]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/mmap_internal.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / mmap_internal.h
1 /* Common mmap definition for Linux implementation.
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
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 <https://www.gnu.org/licenses/>. */
18
19 #ifndef MMAP_INTERNAL_LINUX_H
20 #define MMAP_INTERNAL_LINUX_H 1
21
22 /* This is the minimum mmap2 unit size accept by the kernel. An architecture
23 with multiple minimum page sizes (such as m68k) might define it as -1 and
24 thus it will queried at runtime. */
25 #ifndef MMAP2_PAGE_UNIT
26 # define MMAP2_PAGE_UNIT 4096ULL
27 #endif
28
29 #if MMAP2_PAGE_UNIT == -1
30 static uint64_t page_unit;
31 # define MMAP_CHECK_PAGE_UNIT() \
32 if (page_unit == 0) \
33 page_unit = __getpagesize ();
34 # undef MMAP2_PAGE_UNIT
35 # define MMAP2_PAGE_UNIT page_unit
36 #else
37 # define MMAP_CHECK_PAGE_UNIT()
38 #endif
39
40 /* Do not accept offset not multiple of page size. */
41 #define MMAP_OFF_LOW_MASK (MMAP2_PAGE_UNIT - 1)
42
43 /* An architecture may override this. */
44 #ifndef MMAP_CALL
45 # define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \
46 INLINE_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset)
47 #endif
48
49 #endif /* MMAP_INTERNAL_LINUX_H */