summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Steinberg <ethan.steinberg@gmail.com>2020-05-26 21:42:18 (GMT)
committerGitHub <noreply@github.com>2020-05-26 21:42:18 (GMT)
commit21fda91f8da96406e6a912f7c312424209c19bef (patch)
tree5b2caa6d631e4dfbbdfbf5fda85d67803e3df674
parentb45af1a5691e83b86321fc52d173f66cf891ce5f (diff)
downloadcpython-21fda91f8da96406e6a912f7c312424209c19bef.zip
cpython-21fda91f8da96406e6a912f7c312424209c19bef.tar.gz
cpython-21fda91f8da96406e6a912f7c312424209c19bef.tar.bz2
bpo-40611: Adds MAP_POPULATE to the mmap module (GH-20061)
MAP_POPULATE constant has now been added to the list of exported mmap module flags.
-rw-r--r--Doc/library/mmap.rst22
-rw-r--r--Misc/NEWS.d/next/Library/2020-05-13-16-28-33.bpo-40611.ZCk0_c.rst1
-rw-r--r--Modules/mmapmodule.c3
3 files changed, 25 insertions, 1 deletions
diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst
index 1f3fbc3..698c176 100644
--- a/Doc/library/mmap.rst
+++ b/Doc/library/mmap.rst
@@ -81,7 +81,9 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
private copy-on-write mapping, so changes to the contents of the mmap
object will be private to this process, and :const:`MAP_SHARED` creates a
mapping that's shared with all other processes mapping the same areas of
- the file. The default value is :const:`MAP_SHARED`.
+ the file. The default value is :const:`MAP_SHARED`. Some systems have
+ additional possible flags with the full list specified in
+ :ref:`MAP_* constants <map-constants>`.
*prot*, if specified, gives the desired memory protection; the two most
useful values are :const:`PROT_READ` and :const:`PROT_WRITE`, to specify
@@ -342,3 +344,21 @@ MADV_* Constants
Availability: Systems with the madvise() system call.
.. versionadded:: 3.8
+
+.. _map-constants:
+
+MAP_* Constants
++++++++++++++++
+
+.. data:: MAP_SHARED
+ MAP_PRIVATE
+ MAP_DENYWRITE
+ MAP_EXECUTABLE
+ MAP_ANON
+ MAP_ANONYMOUS
+ MAP_POPULATE
+
+ These are the various flags that can be passed to :meth:`mmap.mmap`. Note that some options might not be present on some systems.
+
+ .. versionchanged:: 3.10
+ Added MAP_POPULATE constant.
diff --git a/Misc/NEWS.d/next/Library/2020-05-13-16-28-33.bpo-40611.ZCk0_c.rst b/Misc/NEWS.d/next/Library/2020-05-13-16-28-33.bpo-40611.ZCk0_c.rst
new file mode 100644
index 0000000..50ef3ad
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-05-13-16-28-33.bpo-40611.ZCk0_c.rst
@@ -0,0 +1 @@
+:data:`~mmap.MAP_POPULATE` constant has now been added to the list of exported :mod:`mmap` module flags.
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index a3e22d0..8a60db1 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1574,6 +1574,9 @@ PyInit_mmap(void)
setint(dict, "MAP_ANON", MAP_ANONYMOUS);
setint(dict, "MAP_ANONYMOUS", MAP_ANONYMOUS);
#endif
+#ifdef MAP_POPULATE
+ setint(dict, "MAP_POPULATE", MAP_POPULATE);
+#endif
setint(dict, "PAGESIZE", (long)my_getpagesize());