Remove any mention of feature test macro requirements for mmap()
PATCH 1/1 Remove any mention of feature test macro requirements for mmap()
I'm not subscribed, please CC me.
glibc doesn't require _GNU_SOURCE to expose certain MAP_* constants anymore (MAP_ANONYMOUS being particularly noteworthy among them for being on track for POSIX Issue 8). See this commit:
https://sourceware.org/git/?p=glibc.git;a=commit;h=954b8f38958de72c4712088735eb175118f17b51
or my glibc bug report which triggered the change at
https://sourceware.org/bugzilla/show_bug.cgi?id=29375
This is because POSIX reserves MAP_ constants to the implementation, so their unconditional visibility in sys/mman.h is always allowed. This is also helpful for portable application writers.
Other C libraries like musl already exhibit this behavior.
Because mmap() is in a POSIX-specific header already, using it with any combination of MAP_ constants doesn't require feature test macros.
Thanks for your consideration
From 47632888627cac3d0547a969c55d3848b3b350b7 Mon Sep 17 00:00:00 2001
From: John Scott <[email protected]>
Date: Wed, 19 Oct 2022 06:25:25 -0400
Subject: [PATCH] Remove any feature test macro requirements for mmap()
No feature test macros are required anymore, not even to expose certain constants. See
https://sourceware.org/bugzilla/show_bug.cgi?id=29375
--- man2/mmap.2 | 35 ----------------------------------- 1 file changed, 35 deletions(-)
man2/mmap.2 +0 -35
@@ -32,8 +32,6 @@ Standard C library .BI " int " fd ", off_t " offset ); .BI "int munmap(void *" addr ", size_t " length ); .fi -.PP -See NOTES for information on feature test macro requirements. .SH DESCRIPTION .BR mmap () creates a new mapping in the virtual address space of
@@ -727,39 +725,6 @@ flag is specified, and .I addr is 0 (NULL), then the mapped address will be 0 (NULL). .PP -Certain -.I flags -constants are defined only if suitable feature test macros are defined -(possibly by default): -.B _DEFAULT_SOURCE -with glibc 2.19 or later; -or -.B _BSD_SOURCE -or -.B _SVID_SOURCE -in glibc 2.19 and earlier. -(Employing -.B _GNU_SOURCE -also suffices, -and requiring that macro specifically would have been more logical, -since these flags are all Linux-specific.) -The relevant flags are: -.BR MAP_32BIT , -.B MAP_ANONYMOUS -(and the synonym -.BR MAP_ANON ), -.BR MAP_DENYWRITE , -.BR MAP_EXECUTABLE , -.BR MAP_FILE , -.BR MAP_GROWSDOWN , -.BR MAP_HUGETLB , -.BR MAP_LOCKED , -.BR MAP_NONBLOCK , -.BR MAP_NORESERVE , -.BR MAP_POPULATE , -and -.BR MAP_STACK . -.PP An application can determine which pages of a mapping are currently resident in the buffer/page cache using .BR mincore (2).
Signature · 1 line
2.35.1
Hi John, Andreas,
Quoted 50 lines · John Scott
I'm not subscribed, please CC me.
glibc doesn't
require_GNU_SOURCEto expose certain MAP_* constants anymore (MAP_ANONYMOUSbeing particularly noteworthy among them for being on track for POSIX Issue 8). See this commit:
https://sourceware.org/git/?p=glibc.git;a=commit;h=954b8f38958de72c4712088735eb175118f17b51or my glibc bug report which triggered the change at
https://sourceware.org/bugzilla/show_bug.cgi?id=29375This is because POSIX reserves
MAP_constants to the implementation, so their unconditional visibility insys/mman.his always allowed. This is also helpful for portable application writers.Other C libraries like musl already exhibit this behavior.
Because
mmap()is in a POSIX-specific header already, using it with any combination ofMAP_constants doesn't require feature test macros.Thanks for your consideration
0001-Remove-any-feature-test-macro-requirements-for-mmap.patch
From
47632888627cac3d0547a969c55d3848b3b350b7Mon Sep 17 00:00:00 2001
From: John Scott<[email protected]>
Date: Wed, 19 Oct 2022 06:25:25 -0400
Subject: [PATCH] Remove any feature test macro requirements formmap()No feature test macros are required anymore, not even to expose certain constants. See
https://sourceware.org/bugzilla/show_bug.cgi?id=29375--- man2/mmap.2 | 35 ----------------------------------- 1 file changed, 35 deletions(-)man2/mmap.2 +0
-2@@ -32,8 +32,6 @@ Standard C library .BI " int " fd ", off_t " offset ); .BI "int munmap(void *" addr ", size_t " length ); .fi -.PP -See NOTES for information on feature test macro requirements. .SH DESCRIPTION .BR mmap () creates a new mapping in the virtual address space of
man2/mmap.2 flag is specified, and · line 735
Quoted 9 lines
man2/mmap.2 +0
-6@@ -727,39 +725,6 @@ flag is specified, and .I addr is 0 (NULL), then the mapped address will be 0 (NULL). .PP -Certain -.I flags -constants are defined only if suitable feature test macros are defined -(possibly by default): -.B _DEFAULT_SOURCE -with glibc 2.19 or later;
We should keep some notice that in the past it was needed. BTW, is glibc backporting the fix to old supported versions?
Thanks,
Alex
Signature · 1 line
<http://www.alejandro-colomar.es/>