From 7cc754bc93eafa78695ec03bb0e4e8256d52c76d Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 28 Jan 2018 04:30:35 +0000 Subject: 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. --- ldso/include/ldso.h | 6 ++ ldso/ldso/dl-elf.c | 2 +- ldso/ldso/ldso.c | 2 +- libc/sysdeps/linux/aarch64/bits/mman.h | 39 +++++++++ libc/sysdeps/linux/alpha/bits/mman.h | 104 ++++++------------------ libc/sysdeps/linux/arm/bits/mman.h | 40 +++++++++ libc/sysdeps/linux/common/bits/mman-common.h | 80 +----------------- libc/sysdeps/linux/common/bits/mman-linux.h | 117 +++++++++++++++++++++++++++ libc/sysdeps/linux/common/bits/mman-shared.h | 75 +++++++++++++++++ libc/sysdeps/linux/hppa/bits/mman.h | 34 ++++---- libc/sysdeps/linux/i386/bits/mman.h | 44 ++++++++++ libc/sysdeps/linux/ia64/bits/mman.h | 38 ++++++++- libc/sysdeps/linux/m68k/bits/mman.h | 40 +++++++++ libc/sysdeps/linux/microblaze/bits/mman.h | 39 +++++++++ libc/sysdeps/linux/mips/bits/mman.h | 80 +++--------------- libc/sysdeps/linux/nds32/bits/mman.h | 72 ++--------------- libc/sysdeps/linux/nios2/bits/mman.h | 39 +++++++++ libc/sysdeps/linux/powerpc/bits/mman.h | 75 +++-------------- libc/sysdeps/linux/sh/bits/mman.h | 40 +++++++++ libc/sysdeps/linux/sparc/bits/mman.h | 75 +++-------------- libc/sysdeps/linux/sparc64/bits/mman.h | 76 +++-------------- libc/sysdeps/linux/x86_64/bits/mman.h | 42 +++++++++- libc/sysdeps/linux/xtensa/bits/mman.h | 84 +++---------------- 23 files changed, 659 insertions(+), 584 deletions(-) create mode 100644 libc/sysdeps/linux/aarch64/bits/mman.h create mode 100644 libc/sysdeps/linux/arm/bits/mman.h create mode 100644 libc/sysdeps/linux/common/bits/mman-linux.h create mode 100644 libc/sysdeps/linux/common/bits/mman-shared.h create mode 100644 libc/sysdeps/linux/i386/bits/mman.h create mode 100644 libc/sysdeps/linux/m68k/bits/mman.h create mode 100644 libc/sysdeps/linux/microblaze/bits/mman.h create mode 100644 libc/sysdeps/linux/nios2/bits/mman.h create mode 100644 libc/sysdeps/linux/sh/bits/mman.h diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index 884c116b9..f19957d1d 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -9,6 +9,12 @@ #include +#ifdef __ARCH_USE_MMU__ +# define _MAP_UNINITIALIZED 0 +#else +# define _MAP_UNINITIALIZED MAP_UNINITIALIZED +#endif + /* Prepare for the case that `__builtin_expect' is not available. */ #if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96 #define __builtin_expect(x, expected_value) (x) diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 930ccacb8..d264e6a49 100644 --- 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, return NULL; } header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0); + MAP_PRIVATE | MAP_ANONYMOUS | _MAP_UNINITIALIZED, -1, 0); if (_dl_mmap_check_error(header)) { _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname); _dl_internal_error_number = LD_ERROR_MMAP_FAILED; diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 0257d1f33..17818b5fd 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -235,7 +235,7 @@ void *_dl_malloc(size_t size) _dl_debug_early("mmapping more memory\n"); _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size, - PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0); + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | _MAP_UNINITIALIZED, -1, 0); if (_dl_mmap_check_error(_dl_mmap_zero)) { _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname); _dl_exit(20); diff --git a/libc/sysdeps/linux/aarch64/bits/mman.h b/libc/sysdeps/linux/aarch64/bits/mman.h new file mode 100644 index 000000000..c68752c48 --- /dev/null +++ b/libc/sysdeps/linux/aarch64/bits/mman.h @@ -0,0 +1,39 @@ +/* Definitions for POSIX memory map interface. Linux/AArch64 version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/alpha/bits/mman.h b/libc/sysdeps/linux/alpha/bits/mman.h index a9820d596..7d9b622af 100644 --- a/libc/sysdeps/linux/alpha/bits/mman.h +++ b/libc/sysdeps/linux/alpha/bits/mman.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/Alpha version. - Copyright (C) 1997, 1998, 2000, 2003, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -13,7 +12,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see + License along with the GNU C Library. If not, see . */ #ifndef _SYS_MMAN_H @@ -23,43 +22,7 @@ /* The following definitions basically come from the kernel headers. But the kernel header is not namespace clean. */ - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x100 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0 -# define MAP_ANONYMOUS 0x10 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -#endif - -/* Not used by Linux, but here to make sure we don't clash with - OSF/1 defines. */ -#if 0 && defined __USE_BSD -# define MAP_HASSEMAPHORE 0x0200 -# define MAP_INHERIT 0x0400 -# define MAP_UNALIGNED 0x0800 -#endif +#define __MAP_ANONYMOUS 0x10 /* Don't use a file. */ /* These are Linux-specific. */ #ifdef __USE_MISC @@ -70,50 +33,33 @@ # define MAP_NORESERVE 0x10000 /* Don't check for reservations. */ # define MAP_POPULATE 0x20000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x40000 /* Do not block on IO. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x80000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x100000 /* Create huge page mapping. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 2 /* Synchronous memory sync. */ -#define MS_INVALIDATE 4 /* Invalidate the caches. */ - /* Flags for `mlockall'. */ -#define MCL_CURRENT 8192 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 16384 /* Lock all additions to address - space. */ +#define MCL_CURRENT 8192 +#define MCL_FUTURE 16384 +#define MCL_ONFAULT 32768 -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif +#include -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 6 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif +/* Values that differ from standard . For the most part newer + values are shared, but older values are skewed. */ -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 6 /* Don't need these pages. */ -#endif +#undef MAP_FIXED +#define MAP_FIXED 0x100 -/* Not used by Linux, but here to make sure we don't clash with - OSF/1 defines. */ -#if 0 && defined __USE_BSD -# define MADV_DONTNEED_COMPAT 4 /* Old version? */ -# define MADV_SPACEAVAIL 5 /* Ensure resources are available. */ +#undef MS_SYNC +#define MS_SYNC 2 +#undef MS_INVALIDATE +#define MS_INVALIDATE 4 + +#ifdef __USE_MISC +# undef MADV_DONTNEED +# define MADV_DONTNEED 6 +#endif +#ifdef __USE_XOPEN2K +# undef POSIX_MADV_DONTNEED +# define POSIX_MADV_DONTNEED 6 #endif diff --git a/libc/sysdeps/linux/arm/bits/mman.h b/libc/sysdeps/linux/arm/bits/mman.h new file mode 100644 index 000000000..1edc294a8 --- /dev/null +++ b/libc/sysdeps/linux/arm/bits/mman.h @@ -0,0 +1,40 @@ +/* Definitions for POSIX memory map interface. Linux/ARM version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/common/bits/mman-common.h b/libc/sysdeps/linux/common/bits/mman-common.h index 5b20da4d0..ddd03a8d3 100644 --- a/libc/sysdeps/linux/common/bits/mman-common.h +++ b/libc/sysdeps/linux/common/bits/mman-common.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/generic version. - Copyright (C) 1997,2000,2003,2005,2006,2009 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,36 +22,6 @@ /* The following definitions basically come from the kernel headers. But the kernel header is not namespace clean. */ - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0 -# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC # define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ @@ -63,49 +32,8 @@ # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ # define MAP_STACK 0x20000 /* Allocation is for a stack. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - -/* Flags for `mlockall'. */ -#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 2 /* Lock all additions to address - space. */ - -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif - -/* only define for MMU targets, no-MMU does not support madvise. */ -#ifdef __ARCH_USE_MMU__ -/* Advice to `madvise'. */ -# ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ -# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ -# define MADV_HWPOISON 100 /* Poison a page for testing. */ -# endif - -/* The POSIX people had to invent similar names for the same things. */ -# ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ -# endif -#endif +#include diff --git a/libc/sysdeps/linux/common/bits/mman-linux.h b/libc/sysdeps/linux/common/bits/mman-linux.h new file mode 100644 index 000000000..6ca08415a --- /dev/null +++ b/libc/sysdeps/linux/common/bits/mman-linux.h @@ -0,0 +1,117 @@ +/* Definitions for POSIX memory map interface. Linux generic version. + Copyright (C) 2001-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + + +/* Protections are chosen from these bits, OR'd together. The + implementation does not necessarily support PROT_EXEC or PROT_WRITE + without PROT_READ. The only guarantees are that no writing will be + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ + +#define PROT_READ 0x1 /* Page can be read. */ +#define PROT_WRITE 0x2 /* Page can be written. */ +#define PROT_EXEC 0x4 /* Page can be executed. */ +#define PROT_NONE 0x0 /* Page can not be accessed. */ +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of + growsdown vma (mprotect only). */ +#define PROT_GROWSUP 0x02000000 /* Extend change to start of + growsup vma (mprotect only). */ + +/* Sharing types (must choose one and only one of these). */ +#define MAP_SHARED 0x01 /* Share changes. */ +#define MAP_PRIVATE 0x02 /* Changes are private. */ +#ifdef __USE_MISC +# define MAP_TYPE 0x0f /* Mask for type of mapping. */ +#endif + +/* Other flags. */ +#define MAP_FIXED 0x10 /* Interpret addr exactly. */ +#ifdef __USE_MISC +# define MAP_FILE 0 +# ifdef __MAP_ANONYMOUS +# define MAP_ANONYMOUS __MAP_ANONYMOUS /* Don't use a file. */ +# else +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ +# endif +# define MAP_ANON MAP_ANONYMOUS +/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size. */ +# define MAP_HUGE_SHIFT 26 +# define MAP_HUGE_MASK 0x3f +#endif + +/* Flags to `msync'. */ +#define MS_ASYNC 1 /* Sync memory asynchronously. */ +#define MS_SYNC 4 /* Synchronous memory sync. */ +#define MS_INVALIDATE 2 /* Invalidate the caches. */ + +/* Flags for `mremap'. */ +#ifdef __USE_GNU +# define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 +#endif + +/* only define for MMU targets, no-MMU does not support madvise. */ +#ifdef __ARCH_USE_MMU__ +/* Advice to `madvise'. */ +# ifdef __USE_MISC +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_FREE 8 /* Free pages only if memory pressure. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +# define MADV_MERGEABLE 12 /* KSM may merge identical pages. */ +# define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages. */ +# define MADV_HUGEPAGE 14 /* Worth backing with hugepages. */ +# define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages. */ +# define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, + overrides the coredump filter bits. */ +# define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag. */ +# define MADV_WIPEONFORK 18 /* Zero memory on fork, child only. */ +# define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ +# endif + +/* The POSIX people had to invent similar names for the same things. */ +# ifdef __USE_XOPEN2K +# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ +# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ +# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +# endif +#endif + +/* Flags for `mlockall'. */ +#ifndef MCL_CURRENT +# define MCL_CURRENT 1 /* Lock all currently mapped pages. */ +# define MCL_FUTURE 2 /* Lock all additions to address + space. */ +# define MCL_ONFAULT 4 /* Lock all pages that are + faulted in. */ +#endif + +#include diff --git a/libc/sysdeps/linux/common/bits/mman-shared.h b/libc/sysdeps/linux/common/bits/mman-shared.h new file mode 100644 index 000000000..c40ae2d1e --- /dev/null +++ b/libc/sysdeps/linux/common/bits/mman-shared.h @@ -0,0 +1,75 @@ +/* Memory-mapping-related declarations/definitions, not architecture-specific. + Copyright (C) 2017-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +#ifdef __USE_GNU +/* Flags for memfd_create. */ +# ifndef MFD_CLOEXEC +# define MFD_CLOEXEC 1U +# define MFD_ALLOW_SEALING 2U +# define MFD_HUGETLB 4U +# endif + +/* Flags for mlock2. */ +# ifndef MLOCK_ONFAULT +# define MLOCK_ONFAULT 1U +# endif + +/* Access rights for pkey_alloc. */ +# ifndef PKEY_DISABLE_ACCESS +# define PKEY_DISABLE_ACCESS 0x1 +# define PKEY_DISABLE_WRITE 0x2 +# endif + +__BEGIN_DECLS + +/* Create a new memory file descriptor. NAME is a name for debugging. + FLAGS is a combination of the MFD_* constants. */ +int memfd_create (const char *__name, unsigned int __flags) __THROW; + +/* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into + memory. FLAGS is a combination of the MLOCK_* flags above. */ +int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW; + +/* Allocate a new protection key, with the PKEY_DISABLE_* bits + specified in ACCESS_RIGHTS. The protection key mask for the + current thread is updated to match the access privilege for the new + key. */ +int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW; + +/* Update the access rights for the current thread for KEY, which must + have been allocated using pkey_alloc. */ +int pkey_set (int __key, unsigned int __access_rights) __THROW; + +/* Return the access rights for the current thread for KEY, which must + have been allocated using pkey_alloc. */ +int pkey_get (int _key) __THROW; + +/* Free an allocated protection key, which must have been allocated + using pkey_alloc. */ +int pkey_free (int __key) __THROW; + +/* Apply memory protection flags for KEY to the specified address + range. */ +int pkey_mprotect (void *__addr, size_t __len, int __prot, int __pkey) __THROW; + +__END_DECLS + +#endif /* __USE_GNU */ diff --git a/libc/sysdeps/linux/hppa/bits/mman.h b/libc/sysdeps/linux/hppa/bits/mman.h index cbde4b8d4..7e0812e39 100644 --- a/libc/sysdeps/linux/hppa/bits/mman.h +++ b/libc/sysdeps/linux/hppa/bits/mman.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/HPPA version. - Copyright (C) 1997-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -58,6 +57,8 @@ # define MAP_GROWSDOWN 0x8000 /* Stack-like segment */ # define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables */ # define MAP_NONBLOCK 0x20000 /* Do not block on IO */ +# define MAP_STACK 0x40000 /* Create for process/thread stacks */ +# define MAP_HUGETLB 0x80000 /* Create a huge page mapping */ #endif /* Flags to "msync" */ @@ -68,6 +69,7 @@ /* Flags to "mlockall" */ #define MCL_CURRENT 1 /* Lock all current mappings */ #define MCL_FUTURE 2 /* Lock all future mappings */ +#define MCL_ONFAULT 4 /* Lock all pages that are faulted in */ /* Flags for `mremap'. */ #ifdef __USE_GNU @@ -82,27 +84,21 @@ # define MADV_SEQUENTIAL 2 /* Expect sequential page references */ # define MADV_WILLNEED 3 /* Will need these pages */ # define MADV_DONTNEED 4 /* Dont need these pages */ -# define MADV_SPACEAVAIL 5 /* Insure that resources are reserved */ -# define MADV_VPS_PURGE 6 /* Purge pages from VM page cache */ -# define MADV_VPS_INHERIT 7 /* Inherit parents page size */ +# define MADV_FREE 8 /* Free pages only if memory pressure. */ # define MADV_REMOVE 9 /* Remove these pages and resources. */ # define MADV_DONTFORK 10 /* Do not inherit across fork. */ # define MADV_DOFORK 11 /* Do inherit across fork. */ # define MADV_MERGEABLE 65 /* KSM may merge identical pages */ # define MADV_UNMERGEABLE 66 /* KSM may not merge identical pages */ -#endif - -/* The range 12-64 is reserved for page size specification. */ -/* These are Linux-specific. */ -#ifdef __USE_MISC -# define MADV_4K_PAGES 12 /* Use 4K pages. */ -# define MADV_16K_PAGES 14 /* Use 16K pages. */ -# define MADV_64K_PAGES 16 /* Use 64K pages. */ -# define MADV_256K_PAGES 18 /* Use 256K pages. */ -# define MADV_1M_PAGES 20 /* Use 1 Megabyte pages. */ -# define MADV_4M_PAGES 22 /* Use 4 Megabyte pages. */ -# define MADV_16M_PAGES 24 /* Use 16 Megabyte pages. */ -# define MADV_64M_PAGES 26 /* Use 64 Megabyte pages. */ +# define MADV_HUGEPAGE 67 /* Worth backing with hugepages */ +# define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */ +# define MADV_DONTDUMP 69 /* Explicity exclude from the core dump, + overrides the coredump filter bits */ +# define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */ +# define MADV_WIPEONFORK 71 /* Zero memory on fork, child only. */ +# define MADV_KEEPONFORK 72 /* Undo MADV_WIPEONFORK. */ +# define MADV_HWPOISON 100 /* Poison a page for testing. */ +# define MADV_SOFT_OFFLINE 101 /* Soft offline page for testing. */ #endif /* The POSIX people had to invent similar names for the same things. */ @@ -113,3 +109,5 @@ # define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ # define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ #endif + +#include diff --git a/libc/sysdeps/linux/i386/bits/mman.h b/libc/sysdeps/linux/i386/bits/mman.h new file mode 100644 index 000000000..64fee2206 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/mman.h @@ -0,0 +1,44 @@ +/* Definitions for POSIX memory map interface. Linux/x86 version. + Copyright (C) 2001-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* Other flags. */ +#ifdef __USE_MISC +# define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */ +#endif + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/ia64/bits/mman.h b/libc/sysdeps/linux/ia64/bits/mman.h index a9d56ed07..7b61c9cba 100644 --- a/libc/sysdeps/linux/ia64/bits/mman.h +++ b/libc/sysdeps/linux/ia64/bits/mman.h @@ -1,4 +1,40 @@ +/* Definitions for POSIX memory map interface. Linux/ia64 version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ #ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ # define MAP_GROWSUP 0x00200 /* Register stack-like segment */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ #endif -#include + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/m68k/bits/mman.h b/libc/sysdeps/linux/m68k/bits/mman.h new file mode 100644 index 000000000..c486dfa48 --- /dev/null +++ b/libc/sysdeps/linux/m68k/bits/mman.h @@ -0,0 +1,40 @@ +/* Definitions for POSIX memory map interface. Linux/m68k version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/microblaze/bits/mman.h b/libc/sysdeps/linux/microblaze/bits/mman.h new file mode 100644 index 000000000..ddd6c32b9 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/bits/mman.h @@ -0,0 +1,39 @@ +/* Definitions for POSIX memory map interface. Linux/MicroBlaze version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +#ifdef __USE_MISC +/* These are Linux-specific. */ +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY. */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/mips/bits/mman.h b/libc/sysdeps/linux/mips/bits/mman.h index ca1497ebc..0619d7a82 100644 --- a/libc/sysdeps/linux/mips/bits/mman.h +++ b/libc/sysdeps/linux/mips/bits/mman.h @@ -1,7 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/MIPS version. - Copyright (C) 1997, 2000, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -14,7 +12,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see + License along with the GNU C Library. If not, see . */ #ifndef _SYS_MMAN_H @@ -24,84 +22,24 @@ /* The following definitions basically come from the kernel headers. But the kernel header is not namespace clean. */ - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0 -# define MAP_ANONYMOUS 0x0800 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -# define MAP_RENAME MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC # define MAP_NORESERVE 0x0400 /* don't check for reservations */ -# define MAP_ANONYMOUS 0x0800 /* don't use a file */ # define MAP_GROWSDOWN 0x1000 /* stack-like segment */ # define MAP_DENYWRITE 0x2000 /* ETXTBSY */ # define MAP_EXECUTABLE 0x4000 /* mark it as an executable */ # define MAP_LOCKED 0x8000 /* pages are locked */ # define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ # define MAP_NONBLOCK 0x20000 /* do not block on IO */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x40000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x80000 /* Create huge page mapping. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - -/* Flags for `mlockall'. */ -#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 2 /* Lock all additions to address - space. */ - -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif +#define __MAP_ANONYMOUS 0x0800 -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif +/* Include generic Linux declarations. */ +#include -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +#ifdef __USE_MISC +# define MAP_RENAME MAP_ANONYMOUS #endif diff --git a/libc/sysdeps/linux/nds32/bits/mman.h b/libc/sysdeps/linux/nds32/bits/mman.h index ac242e065..c1b263a4c 100644 --- a/libc/sysdeps/linux/nds32/bits/mman.h +++ b/libc/sysdeps/linux/nds32/bits/mman.h @@ -4,7 +4,7 @@ */ /* Definitions for POSIX memory map interface. Linux/NDS32 version. - Copyright (C) 1997, 2000, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -28,37 +28,6 @@ /* The following definitions basically come from the kernel headers. But the kernel header is not namespace clean. */ - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0x00 -# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -# define MAP_RENAME MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC # define MAP_GROWSDOWN 0x0100 /* stack-like segment */ @@ -68,40 +37,9 @@ # define MAP_NORESERVE 0x4000 /* don't check for reservations */ # define MAP_POPULATE 0x08000 /* populate (prefault) pagetables */ # define MAP_NONBLOCK 0x10000 /* do not block on IO */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ -#endif - -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ - -/* Flags for `mlockall'. */ -#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 2 /* Lock all additions to address - space. */ - -/* Advice to `madvise'. */ -#ifdef __USE_BSD -#define MADV_NORMAL 0 /* default page-in behavior */ -#define MADV_RANDOM 1 /* page-in minimum required */ -#define MADV_SEQUENTIAL 2 /* read-ahead aggressively */ -#define MADV_WILLNEED 3 /* pre-fault pages */ -#define MADV_DONTNEED 4 /* discard these pages */ -#endif - -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ #endif -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/nios2/bits/mman.h b/libc/sysdeps/linux/nios2/bits/mman.h new file mode 100644 index 000000000..4595e4756 --- /dev/null +++ b/libc/sysdeps/linux/nios2/bits/mman.h @@ -0,0 +1,39 @@ +/* Definitions for POSIX memory map interface. Linux/Nios II version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/powerpc/bits/mman.h b/libc/sysdeps/linux/powerpc/bits/mman.h index c39e7929d..c42e11718 100644 --- a/libc/sysdeps/linux/powerpc/bits/mman.h +++ b/libc/sysdeps/linux/powerpc/bits/mman.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/PowerPC version. - Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -17,41 +16,13 @@ . */ #ifndef _SYS_MMAN_H -# error "Never use directly; iclude instead." +# error "Never use directly; include instead." #endif /* The following definitions basically come from the kernel headers. But the kernel header is not namespace clean. */ - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x001 /* Share changes. */ -#define MAP_PRIVATE 0x002 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x00f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x010 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0x000 -# define MAP_ANONYMOUS 0x020 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -#endif +#define PROT_SAO 0x10 /* Strong Access Ordering. */ /* These are Linux-specific. */ #ifdef __USE_MISC @@ -62,44 +33,16 @@ # define MAP_NORESERVE 0x00040 /* Don't check for reservations. */ # define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - /* Flags for `mlockall'. */ #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */ #define MCL_FUTURE 0x4000 /* Lock all additions to address space. */ +#define MCL_ONFAULT 0x8000 /* Lock all pages that are + faulted in. */ - -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif - -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif - -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ -#endif +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/sh/bits/mman.h b/libc/sysdeps/linux/sh/bits/mman.h new file mode 100644 index 000000000..9ae83299a --- /dev/null +++ b/libc/sysdeps/linux/sh/bits/mman.h @@ -0,0 +1,40 @@ +/* Definitions for POSIX memory map interface. Linux/SH version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never include this file directly. Use instead" +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x2000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/sparc/bits/mman.h b/libc/sysdeps/linux/sparc/bits/mman.h index cf1d18096..4dc62bbeb 100644 --- a/libc/sysdeps/linux/sparc/bits/mman.h +++ b/libc/sysdeps/linux/sparc/bits/mman.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/SPARC version. - Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -24,36 +23,6 @@ But the kernel header is not namespace clean. */ -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0x00 -# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -# define MAP_RENAME MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC # define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */ @@ -64,44 +33,20 @@ # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */ # define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - /* Flags for `mlockall'. */ #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */ #define MCL_FUTURE 0x4000 /* Lock all additions to address space. */ +#define MCL_ONFAULT 0x8000 /* Lock all pages that are + faulted in. */ +/* Include generic Linux declarations. */ +#include -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif - -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_FREE 5 /* Content can be freed (Solaris). */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif - -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +/* Other flags. */ +#ifdef __USE_MISC +# define MAP_RENAME MAP_ANONYMOUS #endif diff --git a/libc/sysdeps/linux/sparc64/bits/mman.h b/libc/sysdeps/linux/sparc64/bits/mman.h index 9ac2b7011..e4cd1bb2b 100644 --- a/libc/sysdeps/linux/sparc64/bits/mman.h +++ b/libc/sysdeps/linux/sparc64/bits/mman.h @@ -1,5 +1,5 @@ -/* Definitions for POSIX memory map interface. Linux/SPARC version. - Copyright (C) 1997,1999,2000,2003,2005,2006 Free Software Foundation, Inc. +/* Definitions for POSIX memory map interface. Linux/SPARC64 version. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -23,36 +23,6 @@ But the kernel header is not namespace clean. */ -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0x00 -# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -# define MAP_RENAME MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC # define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */ @@ -63,44 +33,20 @@ # define _MAP_NEW 0x80000000 /* Binary compatibility with SunOS. */ # define MAP_POPULATE 0x8000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ - /* Flags for `mlockall'. */ #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */ #define MCL_FUTURE 0x4000 /* Lock all additions to address space. */ +#define MCL_ONFAULT 0x8000 /* Lock all pages that are + faulted in. */ +/* Include generic Linux declarations. */ +#include -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif - -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_FREE 5 /* Content can be freed (Solaris). */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif - -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +/* Other flags. */ +#ifdef __USE_MISC +# define MAP_RENAME MAP_ANONYMOUS #endif diff --git a/libc/sysdeps/linux/x86_64/bits/mman.h b/libc/sysdeps/linux/x86_64/bits/mman.h index a0b7a0e97..ab163b3e3 100644 --- a/libc/sysdeps/linux/x86_64/bits/mman.h +++ b/libc/sysdeps/linux/x86_64/bits/mman.h @@ -1,4 +1,44 @@ +/* Definitions for POSIX memory map interface. Linux/x86_64 version. + Copyright (C) 2001-2018 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + +/* Other flags. */ #ifdef __USE_MISC # define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */ #endif -#include + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +# define MAP_STACK 0x20000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#endif + +/* Include generic Linux declarations. */ +#include diff --git a/libc/sysdeps/linux/xtensa/bits/mman.h b/libc/sysdeps/linux/xtensa/bits/mman.h index a42e92663..60be03bda 100644 --- a/libc/sysdeps/linux/xtensa/bits/mman.h +++ b/libc/sysdeps/linux/xtensa/bits/mman.h @@ -1,6 +1,5 @@ /* Definitions for POSIX memory map interface. Linux/Xtensa version. - Copyright (C) 1997, 2000, 2007 Free Software Foundation, Inc. - This file is part of the GNU C Library. + Copyright (C) 1997-2018 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -20,86 +19,25 @@ # error "Never use directly; include instead." #endif -/* The following definitions basically come from the kernel headers. - But the kernel header is not namespace clean. */ - - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_READ 0x1 /* Page can be read. */ -#define PROT_WRITE 0x2 /* Page can be written. */ -#define PROT_EXEC 0x4 /* Page can be executed. */ -#define PROT_NONE 0x0 /* Page can not be accessed. */ -#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of - growsdown vma (mprotect only). */ -#define PROT_GROWSUP 0x02000000 /* Extend change to start of - growsup vma (mprotect only). */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes are private. */ -#ifdef __USE_MISC -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Interpret addr exactly. */ -#ifdef __USE_MISC -# define MAP_FILE 0 -# define MAP_ANONYMOUS 0x800 /* Don't use a file. */ -# define MAP_ANON MAP_ANONYMOUS -# define MAP_RENAME MAP_ANONYMOUS -#endif - /* These are Linux-specific. */ #ifdef __USE_MISC +# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */ # define MAP_GROWSDOWN 0x1000 /* Stack-like segment. */ -# define MAP_DENYWRITE 0x2000 /* ETXTBSY */ +# define MAP_DENYWRITE 0x2000 /* ETXTBSY */ # define MAP_EXECUTABLE 0x4000 /* Mark it as an executable. */ # define MAP_LOCKED 0x8000 /* Lock the mapping. */ -# define MAP_NORESERVE 0x0400 /* Don't check for reservations. */ # define MAP_POPULATE 0x10000 /* Populate (prefault) pagetables. */ # define MAP_NONBLOCK 0x20000 /* Do not block on IO. */ -# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ +# define MAP_STACK 0x40000 /* Allocation is for a stack. */ +# define MAP_HUGETLB 0x80000 /* Create huge page mapping. */ +# define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could - be uninitialized. */ #endif -/* Flags to `msync'. */ -#define MS_ASYNC 1 /* Sync memory asynchronously. */ -#define MS_SYNC 4 /* Synchronous memory sync. */ -#define MS_INVALIDATE 2 /* Invalidate the caches. */ +#define __MAP_ANONYMOUS 0x0800 /* Don't use a file */ -/* Flags for `mlockall'. */ -#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ -#define MCL_FUTURE 2 /* Lock all additions to address - space. */ - -/* Flags for `mremap'. */ -#ifdef __USE_GNU -# define MREMAP_MAYMOVE 1 -# define MREMAP_FIXED 2 -#endif +/* Include generic Linux declarations. */ +#include -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -# define MADV_REMOVE 9 /* Remove these pages and resources. */ -# define MADV_DONTFORK 10 /* Do not inherit across fork. */ -# define MADV_DOFORK 11 /* Do inherit across fork. */ -#endif - -/* The POSIX people had to invent similar names for the same things. */ -#ifdef __USE_XOPEN2K -# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ -# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ -# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ -# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +#ifdef __USE_MISC +# define MAP_RENAME MAP_ANONYMOUS #endif -- cgit v1.2.3