1 | /* Common mmap definition for Linux implementation. |
2 | Copyright (C) 2017-2022 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 | #include <stdint.h> |
23 | |
24 | /* This is the minimum mmap2 unit size accept by the kernel. An architecture |
25 | with multiple minimum page sizes (such as m68k) might define it as -1 and |
26 | thus it will queried at runtime. */ |
27 | #ifndef MMAP2_PAGE_UNIT |
28 | # define MMAP2_PAGE_UNIT 4096ULL |
29 | #endif |
30 | |
31 | #if MMAP2_PAGE_UNIT == -1 |
32 | static uint64_t page_unit; |
33 | # define MMAP_CHECK_PAGE_UNIT() \ |
34 | if (page_unit == 0) \ |
35 | page_unit = __getpagesize (); |
36 | # undef MMAP2_PAGE_UNIT |
37 | # define MMAP2_PAGE_UNIT page_unit |
38 | #else |
39 | # define MMAP_CHECK_PAGE_UNIT() |
40 | #endif |
41 | |
42 | /* Do not accept offset not multiple of page size. */ |
43 | #define MMAP_OFF_LOW_MASK (MMAP2_PAGE_UNIT - 1) |
44 | |
45 | /* An architecture may override this. */ |
46 | #ifndef MMAP_CALL |
47 | # define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \ |
48 | INLINE_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset) |
49 | #endif |
50 | |
51 | #endif /* MMAP_INTERNAL_LINUX_H */ |
52 | |