• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision7cc754bc93eafa78695ec03bb0e4e8256d52c76d (tree)
Time2018-02-04 04:29:51
AuthorWaldemar Brodkorb <wbx@ucli...>
CommiterWaldemar Brodkorb

Log Message

bits/mman.h: consolidate header file

Sync with GNU C library and consolidate duplicate non
architecture specific defines.
MAP_UNINITIALIZED is only defined to 0x4000000 and used by
the Linux kernel when CONFIG_MMAP_ALLOW_UNINITIALIZED is enabled.
CONFIG_MMAP_ALLOW_UNINITIALIZED is only available for nommu.
See Documentation/nommu-mmap.txt.

Change Summary

Incremental Difference

--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -9,6 +9,12 @@
99
1010 #include <features.h>
1111
12+#ifdef __ARCH_USE_MMU__
13+# define _MAP_UNINITIALIZED 0
14+#else
15+# define _MAP_UNINITIALIZED MAP_UNINITIALIZED
16+#endif
17+
1218 /* Prepare for the case that `__builtin_expect' is not available. */
1319 #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
1420 #define __builtin_expect(x, expected_value) (x)
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -569,7 +569,7 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned int rflags,
569569 return NULL;
570570 }
571571 header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
572- MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
572+ MAP_PRIVATE | MAP_ANONYMOUS | _MAP_UNINITIALIZED, -1, 0);
573573 if (_dl_mmap_check_error(header)) {
574574 _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
575575 _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -235,7 +235,7 @@ void *_dl_malloc(size_t size)
235235
236236 _dl_debug_early("mmapping more memory\n");
237237 _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size,
238- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
238+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | _MAP_UNINITIALIZED, -1, 0);
239239 if (_dl_mmap_check_error(_dl_mmap_zero)) {
240240 _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
241241 _dl_exit(20);
--- /dev/null
+++ b/libc/sysdeps/linux/aarch64/bits/mman.h
@@ -0,0 +1,39 @@
1+/* Definitions for POSIX memory map interface. Linux/AArch64 version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
26+#ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
29+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+#endif
37+
38+/* Include generic Linux declarations. */
39+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/alpha/bits/mman.h
+++ b/libc/sysdeps/linux/alpha/bits/mman.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/Alpha version.
2- Copyright (C) 1997, 1998, 2000, 2003, 2006 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -13,7 +12,7 @@
1312 Lesser General Public License for more details.
1413
1514 You should have received a copy of the GNU Lesser General Public
16- License along with the GNU C Library; if not, see
15+ License along with the GNU C Library. If not, see
1716 <http://www.gnu.org/licenses/>. */
1817
1918 #ifndef _SYS_MMAN_H
@@ -23,43 +22,7 @@
2322 /* The following definitions basically come from the kernel headers.
2423 But the kernel header is not namespace clean. */
2524
26-
27-/* Protections are chosen from these bits, OR'd together. The
28- implementation does not necessarily support PROT_EXEC or PROT_WRITE
29- without PROT_READ. The only guarantees are that no writing will be
30- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31-
32-#define PROT_READ 0x1 /* Page can be read. */
33-#define PROT_WRITE 0x2 /* Page can be written. */
34-#define PROT_EXEC 0x4 /* Page can be executed. */
35-#define PROT_NONE 0x0 /* Page can not be accessed. */
36-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37- growsdown vma (mprotect only). */
38-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39- growsup vma (mprotect only). */
40-
41-/* Sharing types (must choose one and only one of these). */
42-#define MAP_SHARED 0x01 /* Share changes. */
43-#define MAP_PRIVATE 0x02 /* Changes are private. */
44-#ifdef __USE_MISC
45-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
46-#endif
47-
48-/* Other flags. */
49-#define MAP_FIXED 0x100 /* Interpret addr exactly. */
50-#ifdef __USE_MISC
51-# define MAP_FILE 0
52-# define MAP_ANONYMOUS 0x10 /* Don't use a file. */
53-# define MAP_ANON MAP_ANONYMOUS
54-#endif
55-
56-/* Not used by Linux, but here to make sure we don't clash with
57- OSF/1 defines. */
58-#if 0 && defined __USE_BSD
59-# define MAP_HASSEMAPHORE 0x0200
60-# define MAP_INHERIT 0x0400
61-# define MAP_UNALIGNED 0x0800
62-#endif
25+#define __MAP_ANONYMOUS 0x10 /* Don't use a file. */
6326
6427 /* These are Linux-specific. */
6528 #ifdef __USE_MISC
@@ -70,50 +33,33 @@
7033 # define MAP_NORESERVE 0x10000 /* Don't check for reservations. */
7134 # define MAP_POPULATE 0x20000 /* Populate (prefault) pagetables. */
7235 # define MAP_NONBLOCK 0x40000 /* Do not block on IO. */
73-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
74- be uninitialized. */
36+# define MAP_STACK 0x80000 /* Allocation is for a stack. */
37+# define MAP_HUGETLB 0x100000 /* Create huge page mapping. */
7538 #endif
7639
77-/* Flags to `msync'. */
78-#define MS_ASYNC 1 /* Sync memory asynchronously. */
79-#define MS_SYNC 2 /* Synchronous memory sync. */
80-#define MS_INVALIDATE 4 /* Invalidate the caches. */
81-
8240 /* Flags for `mlockall'. */
83-#define MCL_CURRENT 8192 /* Lock all currently mapped pages. */
84-#define MCL_FUTURE 16384 /* Lock all additions to address
85- space. */
41+#define MCL_CURRENT 8192
42+#define MCL_FUTURE 16384
43+#define MCL_ONFAULT 32768
8644
87-/* Flags for `mremap'. */
88-#ifdef __USE_GNU
89-# define MREMAP_MAYMOVE 1
90-# define MREMAP_FIXED 2
91-#endif
45+#include <bits/mman-linux.h>
9246
93-/* Advice to `madvise'. */
94-#ifdef __USE_BSD
95-# define MADV_NORMAL 0 /* No further special treatment. */
96-# define MADV_RANDOM 1 /* Expect random page references. */
97-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
98-# define MADV_WILLNEED 3 /* Will need these pages. */
99-# define MADV_DONTNEED 6 /* Don't need these pages. */
100-# define MADV_REMOVE 9 /* Remove these pages and resources. */
101-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
102-# define MADV_DOFORK 11 /* Do inherit across fork. */
103-#endif
47+/* Values that differ from standard <mman-linux.h>. For the most part newer
48+ values are shared, but older values are skewed. */
10449
105-/* The POSIX people had to invent similar names for the same things. */
106-#ifdef __USE_XOPEN2K
107-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
108-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
109-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
110-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
111-# define POSIX_MADV_DONTNEED 6 /* Don't need these pages. */
112-#endif
50+#undef MAP_FIXED
51+#define MAP_FIXED 0x100
11352
114-/* Not used by Linux, but here to make sure we don't clash with
115- OSF/1 defines. */
116-#if 0 && defined __USE_BSD
117-# define MADV_DONTNEED_COMPAT 4 /* Old version? */
118-# define MADV_SPACEAVAIL 5 /* Ensure resources are available. */
53+#undef MS_SYNC
54+#define MS_SYNC 2
55+#undef MS_INVALIDATE
56+#define MS_INVALIDATE 4
57+
58+#ifdef __USE_MISC
59+# undef MADV_DONTNEED
60+# define MADV_DONTNEED 6
61+#endif
62+#ifdef __USE_XOPEN2K
63+# undef POSIX_MADV_DONTNEED
64+# define POSIX_MADV_DONTNEED 6
11965 #endif
--- /dev/null
+++ b/libc/sysdeps/linux/arm/bits/mman.h
@@ -0,0 +1,40 @@
1+/* Definitions for POSIX memory map interface. Linux/ARM version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
26+#ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
29+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */
37+#endif
38+
39+/* Include generic Linux declarations. */
40+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/common/bits/mman-common.h
+++ b/libc/sysdeps/linux/common/bits/mman-common.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/generic version.
2- Copyright (C) 1997,2000,2003,2005,2006,2009 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -23,36 +22,6 @@
2322 /* The following definitions basically come from the kernel headers.
2423 But the kernel header is not namespace clean. */
2524
26-
27-/* Protections are chosen from these bits, OR'd together. The
28- implementation does not necessarily support PROT_EXEC or PROT_WRITE
29- without PROT_READ. The only guarantees are that no writing will be
30- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31-
32-#define PROT_READ 0x1 /* Page can be read. */
33-#define PROT_WRITE 0x2 /* Page can be written. */
34-#define PROT_EXEC 0x4 /* Page can be executed. */
35-#define PROT_NONE 0x0 /* Page can not be accessed. */
36-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37- growsdown vma (mprotect only). */
38-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39- growsup vma (mprotect only). */
40-
41-/* Sharing types (must choose one and only one of these). */
42-#define MAP_SHARED 0x01 /* Share changes. */
43-#define MAP_PRIVATE 0x02 /* Changes are private. */
44-#ifdef __USE_MISC
45-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
46-#endif
47-
48-/* Other flags. */
49-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
50-#ifdef __USE_MISC
51-# define MAP_FILE 0
52-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
53-# define MAP_ANON MAP_ANONYMOUS
54-#endif
55-
5625 /* These are Linux-specific. */
5726 #ifdef __USE_MISC
5827 # define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
@@ -63,49 +32,8 @@
6332 # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
6433 # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
6534 # define MAP_STACK 0x20000 /* Allocation is for a stack. */
66-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
67- be uninitialized. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */
6837 #endif
6938
70-/* Flags to `msync'. */
71-#define MS_ASYNC 1 /* Sync memory asynchronously. */
72-#define MS_SYNC 4 /* Synchronous memory sync. */
73-#define MS_INVALIDATE 2 /* Invalidate the caches. */
74-
75-/* Flags for `mlockall'. */
76-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
77-#define MCL_FUTURE 2 /* Lock all additions to address
78- space. */
79-
80-/* Flags for `mremap'. */
81-#ifdef __USE_GNU
82-# define MREMAP_MAYMOVE 1
83-# define MREMAP_FIXED 2
84-#endif
85-
86-/* only define for MMU targets, no-MMU does not support madvise. */
87-#ifdef __ARCH_USE_MMU__
88-/* Advice to `madvise'. */
89-# ifdef __USE_BSD
90-# define MADV_NORMAL 0 /* No further special treatment. */
91-# define MADV_RANDOM 1 /* Expect random page references. */
92-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
93-# define MADV_WILLNEED 3 /* Will need these pages. */
94-# define MADV_DONTNEED 4 /* Don't need these pages. */
95-# define MADV_REMOVE 9 /* Remove these pages and resources. */
96-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
97-# define MADV_DOFORK 11 /* Do inherit across fork. */
98-# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */
99-# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */
100-# define MADV_HWPOISON 100 /* Poison a page for testing. */
101-# endif
102-
103-/* The POSIX people had to invent similar names for the same things. */
104-# ifdef __USE_XOPEN2K
105-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
106-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
107-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
108-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
109-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
110-# endif
111-#endif
39+#include <bits/mman-linux.h>
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/mman-linux.h
@@ -0,0 +1,117 @@
1+/* Definitions for POSIX memory map interface. Linux generic version.
2+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman-linux.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+
26+/* Protections are chosen from these bits, OR'd together. The
27+ implementation does not necessarily support PROT_EXEC or PROT_WRITE
28+ without PROT_READ. The only guarantees are that no writing will be
29+ allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
30+
31+#define PROT_READ 0x1 /* Page can be read. */
32+#define PROT_WRITE 0x2 /* Page can be written. */
33+#define PROT_EXEC 0x4 /* Page can be executed. */
34+#define PROT_NONE 0x0 /* Page can not be accessed. */
35+#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
36+ growsdown vma (mprotect only). */
37+#define PROT_GROWSUP 0x02000000 /* Extend change to start of
38+ growsup vma (mprotect only). */
39+
40+/* Sharing types (must choose one and only one of these). */
41+#define MAP_SHARED 0x01 /* Share changes. */
42+#define MAP_PRIVATE 0x02 /* Changes are private. */
43+#ifdef __USE_MISC
44+# define MAP_TYPE 0x0f /* Mask for type of mapping. */
45+#endif
46+
47+/* Other flags. */
48+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
49+#ifdef __USE_MISC
50+# define MAP_FILE 0
51+# ifdef __MAP_ANONYMOUS
52+# define MAP_ANONYMOUS __MAP_ANONYMOUS /* Don't use a file. */
53+# else
54+# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
55+# endif
56+# define MAP_ANON MAP_ANONYMOUS
57+/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. */
58+# define MAP_HUGE_SHIFT 26
59+# define MAP_HUGE_MASK 0x3f
60+#endif
61+
62+/* Flags to `msync'. */
63+#define MS_ASYNC 1 /* Sync memory asynchronously. */
64+#define MS_SYNC 4 /* Synchronous memory sync. */
65+#define MS_INVALIDATE 2 /* Invalidate the caches. */
66+
67+/* Flags for `mremap'. */
68+#ifdef __USE_GNU
69+# define MREMAP_MAYMOVE 1
70+# define MREMAP_FIXED 2
71+#endif
72+
73+/* only define for MMU targets, no-MMU does not support madvise. */
74+#ifdef __ARCH_USE_MMU__
75+/* Advice to `madvise'. */
76+# ifdef __USE_MISC
77+# define MADV_NORMAL 0 /* No further special treatment. */
78+# define MADV_RANDOM 1 /* Expect random page references. */
79+# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
80+# define MADV_WILLNEED 3 /* Will need these pages. */
81+# define MADV_DONTNEED 4 /* Don't need these pages. */
82+# define MADV_FREE 8 /* Free pages only if memory pressure. */
83+# define MADV_REMOVE 9 /* Remove these pages and resources. */
84+# define MADV_DONTFORK 10 /* Do not inherit across fork. */
85+# define MADV_DOFORK 11 /* Do inherit across fork. */
86+# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */
87+# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */
88+# define MADV_HUGEPAGE 14 /* Worth backing with hugepages. */
89+# define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages. */
90+# define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
91+ overrides the coredump filter bits. */
92+# define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag. */
93+# define MADV_WIPEONFORK 18 /* Zero memory on fork, child only. */
94+# define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK. */
95+# define MADV_HWPOISON 100 /* Poison a page for testing. */
96+# endif
97+
98+/* The POSIX people had to invent similar names for the same things. */
99+# ifdef __USE_XOPEN2K
100+# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
101+# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
102+# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
103+# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
104+# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
105+# endif
106+#endif
107+
108+/* Flags for `mlockall'. */
109+#ifndef MCL_CURRENT
110+# define MCL_CURRENT 1 /* Lock all currently mapped pages. */
111+# define MCL_FUTURE 2 /* Lock all additions to address
112+ space. */
113+# define MCL_ONFAULT 4 /* Lock all pages that are
114+ faulted in. */
115+#endif
116+
117+#include <bits/mman-shared.h>
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/mman-shared.h
@@ -0,0 +1,75 @@
1+/* Memory-mapping-related declarations/definitions, not architecture-specific.
2+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman-shared.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+#ifdef __USE_GNU
23+/* Flags for memfd_create. */
24+# ifndef MFD_CLOEXEC
25+# define MFD_CLOEXEC 1U
26+# define MFD_ALLOW_SEALING 2U
27+# define MFD_HUGETLB 4U
28+# endif
29+
30+/* Flags for mlock2. */
31+# ifndef MLOCK_ONFAULT
32+# define MLOCK_ONFAULT 1U
33+# endif
34+
35+/* Access rights for pkey_alloc. */
36+# ifndef PKEY_DISABLE_ACCESS
37+# define PKEY_DISABLE_ACCESS 0x1
38+# define PKEY_DISABLE_WRITE 0x2
39+# endif
40+
41+__BEGIN_DECLS
42+
43+/* Create a new memory file descriptor. NAME is a name for debugging.
44+ FLAGS is a combination of the MFD_* constants. */
45+int memfd_create (const char *__name, unsigned int __flags) __THROW;
46+
47+/* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into
48+ memory. FLAGS is a combination of the MLOCK_* flags above. */
49+int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW;
50+
51+/* Allocate a new protection key, with the PKEY_DISABLE_* bits
52+ specified in ACCESS_RIGHTS. The protection key mask for the
53+ current thread is updated to match the access privilege for the new
54+ key. */
55+int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
56+
57+/* Update the access rights for the current thread for KEY, which must
58+ have been allocated using pkey_alloc. */
59+int pkey_set (int __key, unsigned int __access_rights) __THROW;
60+
61+/* Return the access rights for the current thread for KEY, which must
62+ have been allocated using pkey_alloc. */
63+int pkey_get (int _key) __THROW;
64+
65+/* Free an allocated protection key, which must have been allocated
66+ using pkey_alloc. */
67+int pkey_free (int __key) __THROW;
68+
69+/* Apply memory protection flags for KEY to the specified address
70+ range. */
71+int pkey_mprotect (void *__addr, size_t __len, int __prot, int __pkey) __THROW;
72+
73+__END_DECLS
74+
75+#endif /* __USE_GNU */
--- a/libc/sysdeps/linux/hppa/bits/mman.h
+++ b/libc/sysdeps/linux/hppa/bits/mman.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/HPPA version.
2- Copyright (C) 1997-2015 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -58,6 +57,8 @@
5857 # define MAP_GROWSDOWN 0x8000 /* Stack-like segment */
5958 # define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables */
6059 # define MAP_NONBLOCK 0x20000 /* Do not block on IO */
60+# define MAP_STACK 0x40000 /* Create for process/thread stacks */
61+# define MAP_HUGETLB 0x80000 /* Create a huge page mapping */
6162 #endif
6263
6364 /* Flags to "msync" */
@@ -68,6 +69,7 @@
6869 /* Flags to "mlockall" */
6970 #define MCL_CURRENT 1 /* Lock all current mappings */
7071 #define MCL_FUTURE 2 /* Lock all future mappings */
72+#define MCL_ONFAULT 4 /* Lock all pages that are faulted in */
7173
7274 /* Flags for `mremap'. */
7375 #ifdef __USE_GNU
@@ -82,27 +84,21 @@
8284 # define MADV_SEQUENTIAL 2 /* Expect sequential page references */
8385 # define MADV_WILLNEED 3 /* Will need these pages */
8486 # define MADV_DONTNEED 4 /* Dont need these pages */
85-# define MADV_SPACEAVAIL 5 /* Insure that resources are reserved */
86-# define MADV_VPS_PURGE 6 /* Purge pages from VM page cache */
87-# define MADV_VPS_INHERIT 7 /* Inherit parents page size */
87+# define MADV_FREE 8 /* Free pages only if memory pressure. */
8888 # define MADV_REMOVE 9 /* Remove these pages and resources. */
8989 # define MADV_DONTFORK 10 /* Do not inherit across fork. */
9090 # define MADV_DOFORK 11 /* Do inherit across fork. */
9191 # define MADV_MERGEABLE 65 /* KSM may merge identical pages */
9292 # define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */
93-#endif
94-
95-/* The range 12-64 is reserved for page size specification. */
96-/* These are Linux-specific. */
97-#ifdef __USE_MISC
98-# define MADV_4K_PAGES 12 /* Use 4K pages. */
99-# define MADV_16K_PAGES 14 /* Use 16K pages. */
100-# define MADV_64K_PAGES 16 /* Use 64K pages. */
101-# define MADV_256K_PAGES 18 /* Use 256K pages. */
102-# define MADV_1M_PAGES 20 /* Use 1 Megabyte pages. */
103-# define MADV_4M_PAGES 22 /* Use 4 Megabyte pages. */
104-# define MADV_16M_PAGES 24 /* Use 16 Megabyte pages. */
105-# define MADV_64M_PAGES 26 /* Use 64 Megabyte pages. */
93+# define MADV_HUGEPAGE 67 /* Worth backing with hugepages */
94+# define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */
95+# define MADV_DONTDUMP 69 /* Explicity exclude from the core dump,
96+ overrides the coredump filter bits */
97+# define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */
98+# define MADV_WIPEONFORK 71 /* Zero memory on fork, child only. */
99+# define MADV_KEEPONFORK 72 /* Undo MADV_WIPEONFORK. */
100+# define MADV_HWPOISON 100 /* Poison a page for testing. */
101+# define MADV_SOFT_OFFLINE 101 /* Soft offline page for testing. */
106102 #endif
107103
108104 /* The POSIX people had to invent similar names for the same things. */
@@ -113,3 +109,5 @@
113109 # define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
114110 # define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
115111 #endif
112+
113+#include <bits/mman-shared.h>
--- /dev/null
+++ b/libc/sysdeps/linux/i386/bits/mman.h
@@ -0,0 +1,44 @@
1+/* Definitions for POSIX memory map interface. Linux/x86 version.
2+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* Other flags. */
26+#ifdef __USE_MISC
27+# define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */
28+#endif
29+
30+/* These are Linux-specific. */
31+#ifdef __USE_MISC
32+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
33+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
34+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
35+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
36+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
37+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
38+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
39+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
40+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
41+#endif
42+
43+/* Include generic Linux declarations. */
44+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/ia64/bits/mman.h
+++ b/libc/sysdeps/linux/ia64/bits/mman.h
@@ -1,4 +1,40 @@
1+/* Definitions for POSIX memory map interface. Linux/ia64 version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
126 #ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
228 # define MAP_GROWSUP 0x00200 /* Register stack-like segment */
29+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
30+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
31+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
32+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
33+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
34+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
35+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
36+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
337 #endif
4-#include <bits/mman-common.h>
38+
39+/* Include generic Linux declarations. */
40+#include <bits/mman-linux.h>
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/bits/mman.h
@@ -0,0 +1,40 @@
1+/* Definitions for POSIX memory map interface. Linux/m68k version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
26+#ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
29+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */
37+#endif
38+
39+/* Include generic Linux declarations. */
40+#include <bits/mman-linux.h>
--- /dev/null
+++ b/libc/sysdeps/linux/microblaze/bits/mman.h
@@ -0,0 +1,39 @@
1+/* Definitions for POSIX memory map interface. Linux/MicroBlaze version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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 License as
6+ published by the Free Software Foundation; either version 2.1 of the
7+ License, or (at your option) any later version.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+#ifdef __USE_MISC
26+/* These are Linux-specific. */
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x00800 /* ETXTBSY. */
29+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+#endif
37+
38+/* Include generic Linux declarations. */
39+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/mips/bits/mman.h
+++ b/libc/sysdeps/linux/mips/bits/mman.h
@@ -1,7 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/MIPS version.
2- Copyright (C) 1997, 2000, 2003, 2004, 2005, 2006
3- Free Software Foundation, Inc.
4- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
53
64 The GNU C Library is free software; you can redistribute it and/or
75 modify it under the terms of the GNU Lesser General Public
@@ -14,7 +12,7 @@
1412 Lesser General Public License for more details.
1513
1614 You should have received a copy of the GNU Lesser General Public
17- License along with the GNU C Library; if not, see
15+ License along with the GNU C Library. If not, see
1816 <http://www.gnu.org/licenses/>. */
1917
2018 #ifndef _SYS_MMAN_H
@@ -24,84 +22,24 @@
2422 /* The following definitions basically come from the kernel headers.
2523 But the kernel header is not namespace clean. */
2624
27-
28-/* Protections are chosen from these bits, OR'd together. The
29- implementation does not necessarily support PROT_EXEC or PROT_WRITE
30- without PROT_READ. The only guarantees are that no writing will be
31- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
32-
33-#define PROT_READ 0x1 /* Page can be read. */
34-#define PROT_WRITE 0x2 /* Page can be written. */
35-#define PROT_EXEC 0x4 /* Page can be executed. */
36-#define PROT_NONE 0x0 /* Page can not be accessed. */
37-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
38- growsdown vma (mprotect only). */
39-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
40- growsup vma (mprotect only). */
41-
42-/* Sharing types (must choose one and only one of these). */
43-#define MAP_SHARED 0x01 /* Share changes. */
44-#define MAP_PRIVATE 0x02 /* Changes are private. */
45-#ifdef __USE_MISC
46-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
47-#endif
48-
49-/* Other flags. */
50-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
51-#ifdef __USE_MISC
52-# define MAP_FILE 0
53-# define MAP_ANONYMOUS 0x0800 /* Don't use a file. */
54-# define MAP_ANON MAP_ANONYMOUS
55-# define MAP_RENAME MAP_ANONYMOUS
56-#endif
57-
5825 /* These are Linux-specific. */
5926 #ifdef __USE_MISC
6027 # define MAP_NORESERVE 0x0400 /* don't check for reservations */
61-# define MAP_ANONYMOUS 0x0800 /* don't use a file */
6228 # define MAP_GROWSDOWN 0x1000 /* stack-like segment */
6329 # define MAP_DENYWRITE 0x2000 /* ETXTBSY */
6430 # define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
6531 # define MAP_LOCKED 0x8000 /* pages are locked */
6632 # define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
6733 # define MAP_NONBLOCK 0x20000 /* do not block on IO */
68-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
69- be uninitialized. */
34+# define MAP_STACK 0x40000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x80000 /* Create huge page mapping. */
7036 #endif
7137
72-/* Flags to `msync'. */
73-#define MS_ASYNC 1 /* Sync memory asynchronously. */
74-#define MS_SYNC 4 /* Synchronous memory sync. */
75-#define MS_INVALIDATE 2 /* Invalidate the caches. */
76-
77-/* Flags for `mlockall'. */
78-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
79-#define MCL_FUTURE 2 /* Lock all additions to address
80- space. */
81-
82-/* Flags for `mremap'. */
83-#ifdef __USE_GNU
84-# define MREMAP_MAYMOVE 1
85-# define MREMAP_FIXED 2
86-#endif
38+#define __MAP_ANONYMOUS 0x0800
8739
88-/* Advice to `madvise'. */
89-#ifdef __USE_BSD
90-# define MADV_NORMAL 0 /* No further special treatment. */
91-# define MADV_RANDOM 1 /* Expect random page references. */
92-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
93-# define MADV_WILLNEED 3 /* Will need these pages. */
94-# define MADV_DONTNEED 4 /* Don't need these pages. */
95-# define MADV_REMOVE 9 /* Remove these pages and resources. */
96-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
97-# define MADV_DOFORK 11 /* Do inherit across fork. */
98-#endif
40+/* Include generic Linux declarations. */
41+#include <bits/mman-linux.h>
9942
100-/* The POSIX people had to invent similar names for the same things. */
101-#ifdef __USE_XOPEN2K
102-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
103-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
104-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
105-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
106-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
43+#ifdef __USE_MISC
44+# define MAP_RENAME MAP_ANONYMOUS
10745 #endif
--- a/libc/sysdeps/linux/nds32/bits/mman.h
+++ b/libc/sysdeps/linux/nds32/bits/mman.h
@@ -4,7 +4,7 @@
44 */
55
66 /* Definitions for POSIX memory map interface. Linux/NDS32 version.
7- Copyright (C) 1997, 2000, 2003, 2004 Free Software Foundation, Inc.
7+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
88
99 The GNU C Library is free software; you can redistribute it and/or
1010 modify it under the terms of the GNU Lesser General Public
@@ -28,37 +28,6 @@
2828 /* The following definitions basically come from the kernel headers.
2929 But the kernel header is not namespace clean. */
3030
31-
32-/* Protections are chosen from these bits, OR'd together. The
33- implementation does not necessarily support PROT_EXEC or PROT_WRITE
34- without PROT_READ. The only guarantees are that no writing will be
35- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
36-
37-#define PROT_READ 0x1 /* Page can be read. */
38-#define PROT_WRITE 0x2 /* Page can be written. */
39-#define PROT_EXEC 0x4 /* Page can be executed. */
40-#define PROT_NONE 0x0 /* Page can not be accessed. */
41-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
42- growsdown vma (mprotect only). */
43-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
44- growsup vma (mprotect only). */
45-
46-/* Sharing types (must choose one and only one of these). */
47-#define MAP_SHARED 0x01 /* Share changes. */
48-#define MAP_PRIVATE 0x02 /* Changes are private. */
49-#ifdef __USE_MISC
50-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
51-#endif
52-
53-/* Other flags. */
54-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
55-#ifdef __USE_MISC
56-# define MAP_FILE 0x00
57-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
58-# define MAP_ANON MAP_ANONYMOUS
59-# define MAP_RENAME MAP_ANONYMOUS
60-#endif
61-
6231 /* These are Linux-specific. */
6332 #ifdef __USE_MISC
6433 # define MAP_GROWSDOWN 0x0100 /* stack-like segment */
@@ -68,40 +37,9 @@
6837 # define MAP_NORESERVE 0x4000 /* don't check for reservations */
6938 # define MAP_POPULATE 0x08000 /* populate (prefault) pagetables */
7039 # define MAP_NONBLOCK 0x10000 /* do not block on IO */
71-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
72- be uninitialized. */
73-#endif
74-
75-/* Flags to `msync'. */
76-#define MS_ASYNC 1 /* Sync memory asynchronously. */
77-#define MS_INVALIDATE 2 /* Invalidate the caches. */
78-#define MS_SYNC 4 /* Synchronous memory sync. */
79-
80-/* Flags for `mlockall'. */
81-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
82-#define MCL_FUTURE 2 /* Lock all additions to address
83- space. */
84-
85-/* Advice to `madvise'. */
86-#ifdef __USE_BSD
87-#define MADV_NORMAL 0 /* default page-in behavior */
88-#define MADV_RANDOM 1 /* page-in minimum required */
89-#define MADV_SEQUENTIAL 2 /* read-ahead aggressively */
90-#define MADV_WILLNEED 3 /* pre-fault pages */
91-#define MADV_DONTNEED 4 /* discard these pages */
92-#endif
93-
94-/* The POSIX people had to invent similar names for the same things. */
95-#ifdef __USE_XOPEN2K
96-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
97-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
98-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
99-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
100-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
40+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
41+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
10142 #endif
10243
103-/* Flags for `mremap'. */
104-#ifdef __USE_GNU
105-# define MREMAP_MAYMOVE 1
106-# define MREMAP_FIXED 2
107-#endif
44+/* Include generic Linux declarations. */
45+#include <bits/mman-linux.h>
--- /dev/null
+++ b/libc/sysdeps/linux/nios2/bits/mman.h
@@ -0,0 +1,39 @@
1+/* Definitions for POSIX memory map interface. Linux/Nios II version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
26+#ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
29+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+#endif
37+
38+/* Include generic Linux declarations. */
39+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/powerpc/bits/mman.h
+++ b/libc/sysdeps/linux/powerpc/bits/mman.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/PowerPC version.
2- Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -17,41 +16,13 @@
1716 <http://www.gnu.org/licenses/>. */
1817
1918 #ifndef _SYS_MMAN_H
20-# error "Never use <bits/mman.h> directly; iclude <sys/mman.h> instead."
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
2120 #endif
2221
2322 /* The following definitions basically come from the kernel headers.
2423 But the kernel header is not namespace clean. */
2524
26-
27-/* Protections are chosen from these bits, OR'd together. The
28- implementation does not necessarily support PROT_EXEC or PROT_WRITE
29- without PROT_READ. The only guarantees are that no writing will be
30- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31-
32-#define PROT_READ 0x1 /* Page can be read. */
33-#define PROT_WRITE 0x2 /* Page can be written. */
34-#define PROT_EXEC 0x4 /* Page can be executed. */
35-#define PROT_NONE 0x0 /* Page can not be accessed. */
36-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37- growsdown vma (mprotect only). */
38-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39- growsup vma (mprotect only). */
40-
41-/* Sharing types (must choose one and only one of these). */
42-#define MAP_SHARED 0x001 /* Share changes. */
43-#define MAP_PRIVATE 0x002 /* Changes are private. */
44-#ifdef __USE_MISC
45-# define MAP_TYPE 0x00f /* Mask for type of mapping. */
46-#endif
47-
48-/* Other flags. */
49-#define MAP_FIXED 0x010 /* Interpret addr exactly. */
50-#ifdef __USE_MISC
51-# define MAP_FILE 0x000
52-# define MAP_ANONYMOUS 0x020 /* Don't use a file. */
53-# define MAP_ANON MAP_ANONYMOUS
54-#endif
25+#define PROT_SAO 0x10 /* Strong Access Ordering. */
5526
5627 /* These are Linux-specific. */
5728 #ifdef __USE_MISC
@@ -62,44 +33,16 @@
6233 # define MAP_NORESERVE 0x00040 /* Don't check for reservations. */
6334 # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
6435 # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
65-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
66- be uninitialized. */
36+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
37+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
6738 #endif
6839
69-/* Flags to `msync'. */
70-#define MS_ASYNC 1 /* Sync memory asynchronously. */
71-#define MS_SYNC 4 /* Synchronous memory sync. */
72-#define MS_INVALIDATE 2 /* Invalidate the caches. */
73-
7440 /* Flags for `mlockall'. */
7541 #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */
7642 #define MCL_FUTURE 0x4000 /* Lock all additions to address
7743 space. */
44+#define MCL_ONFAULT 0x8000 /* Lock all pages that are
45+ faulted in. */
7846
79-
80-/* Flags for `mremap'. */
81-#ifdef __USE_GNU
82-# define MREMAP_MAYMOVE 1
83-# define MREMAP_FIXED 2
84-#endif
85-
86-/* Advice to `madvise'. */
87-#ifdef __USE_BSD
88-# define MADV_NORMAL 0 /* No further special treatment. */
89-# define MADV_RANDOM 1 /* Expect random page references. */
90-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
91-# define MADV_WILLNEED 3 /* Will need these pages. */
92-# define MADV_DONTNEED 4 /* Don't need these pages. */
93-# define MADV_REMOVE 9 /* Remove these pages and resources. */
94-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
95-# define MADV_DOFORK 11 /* Do inherit across fork. */
96-#endif
97-
98-/* The POSIX people had to invent similar names for the same things. */
99-#ifdef __USE_XOPEN2K
100-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
101-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
102-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
103-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
104-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
105-#endif
47+/* Include generic Linux declarations. */
48+#include <bits/mman-linux.h>
--- /dev/null
+++ b/libc/sysdeps/linux/sh/bits/mman.h
@@ -0,0 +1,40 @@
1+/* Definitions for POSIX memory map interface. Linux/SH version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never include this file directly. Use <sys/mman.h> instead"
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* These are Linux-specific. */
26+#ifdef __USE_MISC
27+# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
28+# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
29+# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
30+# define MAP_LOCKED 0x2000 /* Lock the mapping. */
31+# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
32+# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
33+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
34+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
35+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
36+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */
37+#endif
38+
39+/* Include generic Linux declarations. */
40+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/sparc/bits/mman.h
+++ b/libc/sysdeps/linux/sparc/bits/mman.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/SPARC version.
2- Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -24,36 +23,6 @@
2423 But the kernel header is not namespace clean. */
2524
2625
27-/* Protections are chosen from these bits, OR'd together. The
28- implementation does not necessarily support PROT_EXEC or PROT_WRITE
29- without PROT_READ. The only guarantees are that no writing will be
30- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31-
32-#define PROT_READ 0x1 /* Page can be read. */
33-#define PROT_WRITE 0x2 /* Page can be written. */
34-#define PROT_EXEC 0x4 /* Page can be executed. */
35-#define PROT_NONE 0x0 /* Page can not be accessed. */
36-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37- growsdown vma (mprotect only). */
38-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39- growsup vma (mprotect only). */
40-
41-/* Sharing types (must choose one and only one of these). */
42-#define MAP_SHARED 0x01 /* Share changes. */
43-#define MAP_PRIVATE 0x02 /* Changes are private. */
44-#ifdef __USE_MISC
45-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
46-#endif
47-
48-/* Other flags. */
49-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
50-#ifdef __USE_MISC
51-# define MAP_FILE 0x00
52-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
53-# define MAP_ANON MAP_ANONYMOUS
54-# define MAP_RENAME MAP_ANONYMOUS
55-#endif
56-
5726 /* These are Linux-specific. */
5827 #ifdef __USE_MISC
5928 # define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */
@@ -64,44 +33,20 @@
6433 # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */
6534 # define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
6635 # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
67-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
68- be uninitialized. */
36+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
37+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
6938 #endif
7039
71-/* Flags to `msync'. */
72-#define MS_ASYNC 1 /* Sync memory asynchronously. */
73-#define MS_SYNC 4 /* Synchronous memory sync. */
74-#define MS_INVALIDATE 2 /* Invalidate the caches. */
75-
7640 /* Flags for `mlockall'. */
7741 #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */
7842 #define MCL_FUTURE 0x4000 /* Lock all additions to address
7943 space. */
44+#define MCL_ONFAULT 0x8000 /* Lock all pages that are
45+ faulted in. */
46+/* Include generic Linux declarations. */
47+#include <bits/mman-linux.h>
8048
81-/* Flags for `mremap'. */
82-#ifdef __USE_GNU
83-# define MREMAP_MAYMOVE 1
84-# define MREMAP_FIXED 2
85-#endif
86-
87-/* Advice to `madvise'. */
88-#ifdef __USE_BSD
89-# define MADV_NORMAL 0 /* No further special treatment. */
90-# define MADV_RANDOM 1 /* Expect random page references. */
91-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
92-# define MADV_WILLNEED 3 /* Will need these pages. */
93-# define MADV_DONTNEED 4 /* Don't need these pages. */
94-# define MADV_FREE 5 /* Content can be freed (Solaris). */
95-# define MADV_REMOVE 9 /* Remove these pages and resources. */
96-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
97-# define MADV_DOFORK 11 /* Do inherit across fork. */
98-#endif
99-
100-/* The POSIX people had to invent similar names for the same things. */
101-#ifdef __USE_XOPEN2K
102-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
103-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
104-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
105-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
106-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
49+/* Other flags. */
50+#ifdef __USE_MISC
51+# define MAP_RENAME MAP_ANONYMOUS
10752 #endif
--- a/libc/sysdeps/linux/sparc64/bits/mman.h
+++ b/libc/sysdeps/linux/sparc64/bits/mman.h
@@ -1,5 +1,5 @@
1-/* Definitions for POSIX memory map interface. Linux/SPARC version.
2- Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc.
1+/* Definitions for POSIX memory map interface. Linux/SPARC64 version.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
33
44 The GNU C Library is free software; you can redistribute it and/or
55 modify it under the terms of the GNU Lesser General Public
@@ -23,36 +23,6 @@
2323 But the kernel header is not namespace clean. */
2424
2525
26-/* Protections are chosen from these bits, OR'd together. The
27- implementation does not necessarily support PROT_EXEC or PROT_WRITE
28- without PROT_READ. The only guarantees are that no writing will be
29- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
30-
31-#define PROT_READ 0x1 /* Page can be read. */
32-#define PROT_WRITE 0x2 /* Page can be written. */
33-#define PROT_EXEC 0x4 /* Page can be executed. */
34-#define PROT_NONE 0x0 /* Page can not be accessed. */
35-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
36- growsdown vma (mprotect only). */
37-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
38- growsup vma (mprotect only). */
39-
40-/* Sharing types (must choose one and only one of these). */
41-#define MAP_SHARED 0x01 /* Share changes. */
42-#define MAP_PRIVATE 0x02 /* Changes are private. */
43-#ifdef __USE_MISC
44-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
45-#endif
46-
47-/* Other flags. */
48-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
49-#ifdef __USE_MISC
50-# define MAP_FILE 0x00
51-# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
52-# define MAP_ANON MAP_ANONYMOUS
53-# define MAP_RENAME MAP_ANONYMOUS
54-#endif
55-
5626 /* These are Linux-specific. */
5727 #ifdef __USE_MISC
5828 # define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */
@@ -63,44 +33,20 @@
6333 # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */
6434 # define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */
6535 # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
66-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
67- be uninitialized. */
36+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
37+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
6838 #endif
6939
70-/* Flags to `msync'. */
71-#define MS_ASYNC 1 /* Sync memory asynchronously. */
72-#define MS_SYNC 4 /* Synchronous memory sync. */
73-#define MS_INVALIDATE 2 /* Invalidate the caches. */
74-
7540 /* Flags for `mlockall'. */
7641 #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */
7742 #define MCL_FUTURE 0x4000 /* Lock all additions to address
7843 space. */
44+#define MCL_ONFAULT 0x8000 /* Lock all pages that are
45+ faulted in. */
46+/* Include generic Linux declarations. */
47+#include <bits/mman-linux.h>
7948
80-/* Flags for `mremap'. */
81-#ifdef __USE_GNU
82-# define MREMAP_MAYMOVE 1
83-# define MREMAP_FIXED 2
84-#endif
85-
86-/* Advice to `madvise'. */
87-#ifdef __USE_BSD
88-# define MADV_NORMAL 0 /* No further special treatment. */
89-# define MADV_RANDOM 1 /* Expect random page references. */
90-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
91-# define MADV_WILLNEED 3 /* Will need these pages. */
92-# define MADV_DONTNEED 4 /* Don't need these pages. */
93-# define MADV_FREE 5 /* Content can be freed (Solaris). */
94-# define MADV_REMOVE 9 /* Remove these pages and resources. */
95-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
96-# define MADV_DOFORK 11 /* Do inherit across fork. */
97-#endif
98-
99-/* The POSIX people had to invent similar names for the same things. */
100-#ifdef __USE_XOPEN2K
101-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
102-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
103-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
104-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
105-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
49+/* Other flags. */
50+#ifdef __USE_MISC
51+# define MAP_RENAME MAP_ANONYMOUS
10652 #endif
--- a/libc/sysdeps/linux/x86_64/bits/mman.h
+++ b/libc/sysdeps/linux/x86_64/bits/mman.h
@@ -1,4 +1,44 @@
1+/* Definitions for POSIX memory map interface. Linux/x86_64 version.
2+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
3+
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.
8+
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.
13+
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/>. */
17+
18+#ifndef _SYS_MMAN_H
19+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
20+#endif
21+
22+/* The following definitions basically come from the kernel headers.
23+ But the kernel header is not namespace clean. */
24+
25+/* Other flags. */
126 #ifdef __USE_MISC
227 # define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */
328 #endif
4-#include <bits/mman-common.h>
29+
30+/* These are Linux-specific. */
31+#ifdef __USE_MISC
32+# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
33+# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
34+# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
35+# define MAP_LOCKED 0x02000 /* Lock the mapping. */
36+# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
37+# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
38+# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
39+# define MAP_STACK 0x20000 /* Allocation is for a stack. */
40+# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */
41+#endif
42+
43+/* Include generic Linux declarations. */
44+#include <bits/mman-linux.h>
--- a/libc/sysdeps/linux/xtensa/bits/mman.h
+++ b/libc/sysdeps/linux/xtensa/bits/mman.h
@@ -1,6 +1,5 @@
11 /* Definitions for POSIX memory map interface. Linux/Xtensa version.
2- Copyright (C) 1997, 2000, 2007 Free Software Foundation, Inc.
3- This file is part of the GNU C Library.
2+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
43
54 The GNU C Library is free software; you can redistribute it and/or
65 modify it under the terms of the GNU Lesser General Public
@@ -20,86 +19,25 @@
2019 # error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
2120 #endif
2221
23-/* The following definitions basically come from the kernel headers.
24- But the kernel header is not namespace clean. */
25-
26-
27-/* Protections are chosen from these bits, OR'd together. The
28- implementation does not necessarily support PROT_EXEC or PROT_WRITE
29- without PROT_READ. The only guarantees are that no writing will be
30- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
31-
32-#define PROT_READ 0x1 /* Page can be read. */
33-#define PROT_WRITE 0x2 /* Page can be written. */
34-#define PROT_EXEC 0x4 /* Page can be executed. */
35-#define PROT_NONE 0x0 /* Page can not be accessed. */
36-#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
37- growsdown vma (mprotect only). */
38-#define PROT_GROWSUP 0x02000000 /* Extend change to start of
39- growsup vma (mprotect only). */
40-
41-/* Sharing types (must choose one and only one of these). */
42-#define MAP_SHARED 0x01 /* Share changes. */
43-#define MAP_PRIVATE 0x02 /* Changes are private. */
44-#ifdef __USE_MISC
45-# define MAP_TYPE 0x0f /* Mask for type of mapping. */
46-#endif
47-
48-/* Other flags. */
49-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
50-#ifdef __USE_MISC
51-# define MAP_FILE 0
52-# define MAP_ANONYMOUS 0x800 /* Don't use a file. */
53-# define MAP_ANON MAP_ANONYMOUS
54-# define MAP_RENAME MAP_ANONYMOUS
55-#endif
56-
5722 /* These are Linux-specific. */
5823 #ifdef __USE_MISC
24+# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */
5925 # define MAP_GROWSDOWN 0x1000 /* Stack-like segment. */
60-# define MAP_DENYWRITE 0x2000 /* ETXTBSY */
26+# define MAP_DENYWRITE 0x2000 /* ETXTBSY */
6127 # define MAP_EXECUTABLE 0x4000 /* Mark it as an executable. */
6228 # define MAP_LOCKED 0x8000 /* Lock the mapping. */
63-# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */
6429 # define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables. */
6530 # define MAP_NONBLOCK 0x20000 /* Do not block on IO. */
66-# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could
67- be uninitialized. */
31+# define MAP_STACK 0x40000 /* Allocation is for a stack. */
32+# define MAP_HUGETLB 0x80000 /* Create huge page mapping. */
33+# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */
6834 #endif
6935
70-/* Flags to `msync'. */
71-#define MS_ASYNC 1 /* Sync memory asynchronously. */
72-#define MS_SYNC 4 /* Synchronous memory sync. */
73-#define MS_INVALIDATE 2 /* Invalidate the caches. */
36+#define __MAP_ANONYMOUS 0x0800 /* Don't use a file */
7437
75-/* Flags for `mlockall'. */
76-#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
77-#define MCL_FUTURE 2 /* Lock all additions to address
78- space. */
79-
80-/* Flags for `mremap'. */
81-#ifdef __USE_GNU
82-# define MREMAP_MAYMOVE 1
83-# define MREMAP_FIXED 2
84-#endif
38+/* Include generic Linux declarations. */
39+#include <bits/mman-linux.h>
8540
86-/* Advice to `madvise'. */
87-#ifdef __USE_BSD
88-# define MADV_NORMAL 0 /* No further special treatment. */
89-# define MADV_RANDOM 1 /* Expect random page references. */
90-# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
91-# define MADV_WILLNEED 3 /* Will need these pages. */
92-# define MADV_DONTNEED 4 /* Don't need these pages. */
93-# define MADV_REMOVE 9 /* Remove these pages and resources. */
94-# define MADV_DONTFORK 10 /* Do not inherit across fork. */
95-# define MADV_DOFORK 11 /* Do inherit across fork. */
96-#endif
97-
98-/* The POSIX people had to invent similar names for the same things. */
99-#ifdef __USE_XOPEN2K
100-# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
101-# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
102-# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
103-# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
104-# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
41+#ifdef __USE_MISC
42+# define MAP_RENAME MAP_ANONYMOUS
10543 #endif