From 954b8f38958de72c4712088735eb175118f17b51 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 16 Aug 2022 15:18:11 +0200 Subject: [PATCH] Expose all MAP_ constants in unconditionally (bug 29375) POSIX reserves the MAP_ prefix for , so there is no need to conditionalize their definitions on feature test macros. --- bits/mman.h | 22 +++++-------- sysdeps/unix/sysv/linux/alpha/bits/mman.h | 22 ++++++------- sysdeps/unix/sysv/linux/bits/mman-linux.h | 26 +++++++-------- .../sysv/linux/bits/mman-map-flags-generic.h | 24 +++++++------- sysdeps/unix/sysv/linux/hppa/bits/mman.h | 32 ++++++++----------- sysdeps/unix/sysv/linux/ia64/bits/mman.h | 4 +-- sysdeps/unix/sysv/linux/mips/bits/mman.h | 26 +++++++-------- sysdeps/unix/sysv/linux/powerpc/bits/mman.h | 24 +++++++------- sysdeps/unix/sysv/linux/sparc/bits/mman.h | 30 ++++++++--------- sysdeps/unix/sysv/linux/x86/bits/mman.h | 4 +-- 10 files changed, 90 insertions(+), 124 deletions(-) diff --git a/bits/mman.h b/bits/mman.h index a55fd9a251..e2aac6f26a 100644 --- a/bits/mman.h +++ b/bits/mman.h @@ -37,27 +37,21 @@ /* Flags contain mapping type, sharing type and options. */ /* Mapping type (must choose one and only one of these). */ -#ifdef __USE_MISC -# define MAP_FILE 0x0001 /* Mapped from a file or device. */ -# define MAP_ANON 0x0002 /* Allocated from anonymous virtual memory. */ -# define MAP_TYPE 0x000f /* Mask for type field. */ -# define MAP_ANONYMOUS MAP_ANON /* Linux name. */ -#endif +#define MAP_FILE 0x0001 /* Mapped from a file or device. */ +#define MAP_ANON 0x0002 /* Allocated from anonymous virtual memory. */ +#define MAP_TYPE 0x000f /* Mask for type field. */ +#define MAP_ANONYMOUS MAP_ANON /* Linux name. */ /* Sharing types (must choose one and only one of these). */ -#ifdef __USE_MISC -# define MAP_COPY 0x0020 /* Virtual copy of region at mapping time. */ -#endif +#define MAP_COPY 0x0020 /* Virtual copy of region at mapping time. */ #define MAP_SHARED 0x0010 /* Share changes. */ #define MAP_PRIVATE 0x0000 /* Changes private; copy pages on write. */ /* Other flags. */ #define MAP_FIXED 0x0100 /* Map address must be exactly as requested. */ -#ifdef __USE_MISC -# define MAP_NOEXTEND 0x0200 /* For MAP_FILE, don't change file size. */ -# define MAP_HASSEMPHORE 0x0400 /* Region may contain semaphores. */ -# define MAP_INHERIT 0x0800 /* Region is retained after exec. */ -#endif +#define MAP_NOEXTEND 0x0200 /* For MAP_FILE, don't change file size. */ +#define MAP_HASSEMPHORE 0x0400 /* Region may contain semaphores. */ +#define MAP_INHERIT 0x0800 /* Region is retained after exec. */ /* Advice to `madvise'. */ #ifdef __USE_MISC diff --git a/sysdeps/unix/sysv/linux/alpha/bits/mman.h b/sysdeps/unix/sysv/linux/alpha/bits/mman.h index f74a3bf9e4..fdfb6f5cd4 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/mman.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/mman.h @@ -26,19 +26,17 @@ #define __MAP_ANONYMOUS 0x10 /* Don't use a file. */ /* These are Linux-specific. */ -#ifdef __USE_MISC -# define MAP_GROWSDOWN 0x01000 /* Stack-like segment. */ -# define MAP_DENYWRITE 0x02000 /* ETXTBSY */ -# define MAP_EXECUTABLE 0x04000 /* Mark it as an executable. */ -# define MAP_LOCKED 0x08000 /* Lock the mapping. */ -# 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_STACK 0x80000 /* Allocation is for a stack. */ -# define MAP_HUGETLB 0x100000 /* Create huge page mapping. */ -# define MAP_FIXED_NOREPLACE 0x200000 /* MAP_FIXED but do not unmap +#define MAP_GROWSDOWN 0x01000 /* Stack-like segment. */ +#define MAP_DENYWRITE 0x02000 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x04000 /* Mark it as an executable. */ +#define MAP_LOCKED 0x08000 /* Lock the mapping. */ +#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_STACK 0x80000 /* Allocation is for a stack. */ +#define MAP_HUGETLB 0x100000 /* Create huge page mapping. */ +#define MAP_FIXED_NOREPLACE 0x200000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif /* Flags for `mlockall'. */ #define MCL_CURRENT 8192 diff --git a/sysdeps/unix/sysv/linux/bits/mman-linux.h b/sysdeps/unix/sysv/linux/bits/mman-linux.h index cb5ad30ef9..1fb7f888aa 100644 --- a/sysdeps/unix/sysv/linux/bits/mman-linux.h +++ b/sysdeps/unix/sysv/linux/bits/mman-linux.h @@ -41,26 +41,22 @@ /* 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_SHARED_VALIDATE 0x03 /* Share changes and validate +#define MAP_SHARED_VALIDATE 0x03 /* Share changes and validate extension flags. */ -# define MAP_TYPE 0x0f /* Mask for type of mapping. */ -#endif +#define MAP_TYPE 0x0f /* Mask for type of mapping. */ /* 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 +#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 /* Flags to `msync'. */ #define MS_ASYNC 1 /* Sync memory asynchronously. */ diff --git a/sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h b/sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h index ffb28d6977..b93c3e051f 100644 --- a/sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h +++ b/sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h @@ -25,18 +25,16 @@ includes asm-generic/mman.h without any changes to the values of the MAP_* flags defined in that header. */ -#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_SYNC 0x80000 /* Perform synchronous page +#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_SYNC 0x80000 /* Perform synchronous page faults for the mapping. */ -# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif diff --git a/sysdeps/unix/sysv/linux/hppa/bits/mman.h b/sysdeps/unix/sysv/linux/hppa/bits/mman.h index 15167ba78f..acaa1cc3e7 100644 --- a/sysdeps/unix/sysv/linux/hppa/bits/mman.h +++ b/sysdeps/unix/sysv/linux/hppa/bits/mman.h @@ -24,24 +24,20 @@ /* Other flags. */ #define __MAP_ANONYMOUS 0x10 /* Don't use a file */ -#ifdef __USE_MISC -# define MAP_VARIABLE 0 -#endif +#define MAP_VARIABLE 0 /* These are Linux-specific. */ -#ifdef __USE_MISC -# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ -# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable */ -# define MAP_LOCKED 0x2000 /* Pages are locked */ -# define MAP_NORESERVE 0x4000 /* Don't check for reservations */ -# 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 */ -# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* Mark it as an executable */ +#define MAP_LOCKED 0x2000 /* Pages are locked */ +#define MAP_NORESERVE 0x4000 /* Don't check for reservations */ +#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 */ +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif /* Advice to "madvise" */ #ifdef __USE_MISC @@ -50,10 +46,8 @@ #include -#ifdef __USE_MISC -# undef MAP_TYPE -# define MAP_TYPE 0x2b /* Mask for type of mapping */ -#endif +#undef MAP_TYPE +#define MAP_TYPE 0x2b /* Mask for type of mapping */ #undef MAP_FIXED #define MAP_FIXED 0x04 /* Interpret addr exactly */ diff --git a/sysdeps/unix/sysv/linux/ia64/bits/mman.h b/sysdeps/unix/sysv/linux/ia64/bits/mman.h index fec05c898c..b02a2770ae 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/mman.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/mman.h @@ -24,9 +24,7 @@ But the kernel header is not namespace clean. */ /* These are Linux-specific. */ -#ifdef __USE_MISC -# define MAP_GROWSUP 0x00200 /* Register stack-like segment */ -#endif +#define MAP_GROWSUP 0x00200 /* Register stack-like segment */ #include diff --git a/sysdeps/unix/sysv/linux/mips/bits/mman.h b/sysdeps/unix/sysv/linux/mips/bits/mman.h index c215ec9f5e..2334372ef5 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/mman.h +++ b/sysdeps/unix/sysv/linux/mips/bits/mman.h @@ -24,25 +24,21 @@ But the kernel header is not namespace clean. */ /* 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_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_STACK 0x40000 /* Allocation is for a stack. */ -# define MAP_HUGETLB 0x80000 /* Create huge page mapping. */ -# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap +#define MAP_NORESERVE 0x0400 /* don't check for reservations */ +#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_STACK 0x40000 /* Allocation is for a stack. */ +#define MAP_HUGETLB 0x80000 /* Create huge page mapping. */ +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif #define __MAP_ANONYMOUS 0x0800 /* Include generic Linux declarations. */ #include -#ifdef __USE_MISC -# define MAP_RENAME MAP_ANONYMOUS -#endif +#define MAP_RENAME MAP_ANONYMOUS diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/mman.h b/sysdeps/unix/sysv/linux/powerpc/bits/mman.h index 9ec01977c4..d6f83332df 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/mman.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/mman.h @@ -26,21 +26,19 @@ #define PROT_SAO 0x10 /* Strong Access Ordering. */ /* 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 0x00080 /* Lock the mapping. */ -# 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_STACK 0x20000 /* Allocation is for a stack. */ -# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ -# define MAP_SYNC 0x80000 /* Perform synchronous page +#define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +#define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +#define MAP_LOCKED 0x00080 /* Lock the mapping. */ +#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_STACK 0x20000 /* Allocation is for a stack. */ +#define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#define MAP_SYNC 0x80000 /* Perform synchronous page faults for the mapping. */ -# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif /* Flags for `mlockall'. */ #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */ diff --git a/sysdeps/unix/sysv/linux/sparc/bits/mman.h b/sysdeps/unix/sysv/linux/sparc/bits/mman.h index 6283e4074a..e7fc670159 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/mman.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/mman.h @@ -25,22 +25,20 @@ /* These are Linux-specific. */ -#ifdef __USE_MISC -# define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */ -# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ -# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ -# define MAP_LOCKED 0x0100 /* Lock the mapping. */ -# define MAP_NORESERVE 0x0040 /* Don't check for reservations. */ -# 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_STACK 0x20000 /* Allocation is for a stack. */ -# define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ -# define MAP_SYNC 0x80000 /* Perform synchronous page +#define MAP_GROWSDOWN 0x0200 /* Stack-like segment. */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ +#define MAP_LOCKED 0x0100 /* Lock the mapping. */ +#define MAP_NORESERVE 0x0040 /* Don't check for reservations. */ +#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_STACK 0x20000 /* Allocation is for a stack. */ +#define MAP_HUGETLB 0x40000 /* Create huge page mapping. */ +#define MAP_SYNC 0x80000 /* Perform synchronous page faults for the mapping. */ -# define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED but do not unmap underlying mapping. */ -#endif /* Flags for `mlockall'. */ #define MCL_CURRENT 0x2000 /* Lock all currently mapped pages. */ @@ -52,6 +50,4 @@ #include /* Other flags. */ -#ifdef __USE_MISC -# define MAP_RENAME MAP_ANONYMOUS -#endif +#define MAP_RENAME MAP_ANONYMOUS diff --git a/sysdeps/unix/sysv/linux/x86/bits/mman.h b/sysdeps/unix/sysv/linux/x86/bits/mman.h index 877be77336..e03227cc31 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/mman.h +++ b/sysdeps/unix/sysv/linux/x86/bits/mman.h @@ -24,9 +24,7 @@ But the kernel header is not namespace clean. */ /* Other flags. */ -#ifdef __USE_MISC -# define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */ -#endif +#define MAP_32BIT 0x40 /* Only give out 32-bit addresses. */ #include