From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Andreas Schwab <schwab@suse.de>, libc-alpha@sourceware.org
Subject: Re: [PATCH] Expose all MAP_ constants in <sys/mman.h> unconditionally (bug 29375)
Date: Thu, 6 Oct 2022 14:54:20 -0300 [thread overview]
Message-ID: <51b3386f-244d-022e-7406-ca84cecda9d1@linaro.org> (raw)
In-Reply-To: <mvm5yisgumz.fsf@suse.de>
On 16/08/22 10:55, Andreas Schwab via Libc-alpha wrote:
> POSIX reserves the MAP_ prefix for <sys/mman.h>, so there is no need to
> conditionalize their definitions on feature test macros.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> 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 <bits/mman-linux.h>
>
> -#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 <bits/mman-map-flags-generic.h>
>
> 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 <bits/mman-linux.h>
>
> -#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 <bits/mman-linux.h>
>
> /* 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 <bits/mman-map-flags-generic.h>
>
prev parent reply other threads:[~2022-10-06 17:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 13:55 Andreas Schwab
2022-10-06 17:54 ` Adhemerval Zanella Netto [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51b3386f-244d-022e-7406-ca84cecda9d1@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).