Skip to content

Commit 21fda91

Browse files
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.
1 parent b45af1a commit 21fda91

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Doc/library/mmap.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
8181
private copy-on-write mapping, so changes to the contents of the mmap
8282
object will be private to this process, and :const:`MAP_SHARED` creates a
8383
mapping that's shared with all other processes mapping the same areas of
84-
the file. The default value is :const:`MAP_SHARED`.
84+
the file. The default value is :const:`MAP_SHARED`. Some systems have
85+
additional possible flags with the full list specified in
86+
:ref:`MAP_* constants <map-constants>`.
8587

8688
*prot*, if specified, gives the desired memory protection; the two most
8789
useful values are :const:`PROT_READ` and :const:`PROT_WRITE`, to specify
@@ -342,3 +344,21 @@ MADV_* Constants
342344
Availability: Systems with the madvise() system call.
343345

344346
.. versionadded:: 3.8
347+
348+
.. _map-constants:
349+
350+
MAP_* Constants
351+
+++++++++++++++
352+
353+
.. data:: MAP_SHARED
354+
MAP_PRIVATE
355+
MAP_DENYWRITE
356+
MAP_EXECUTABLE
357+
MAP_ANON
358+
MAP_ANONYMOUS
359+
MAP_POPULATE
360+
361+
These are the various flags that can be passed to :meth:`mmap.mmap`. Note that some options might not be present on some systems.
362+
363+
.. versionchanged:: 3.10
364+
Added MAP_POPULATE constant.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:data:`~mmap.MAP_POPULATE` constant has now been added to the list of exported :mod:`mmap` module flags.

Modules/mmapmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,9 @@ PyInit_mmap(void)
15741574
setint(dict, "MAP_ANON", MAP_ANONYMOUS);
15751575
setint(dict, "MAP_ANONYMOUS", MAP_ANONYMOUS);
15761576
#endif
1577+
#ifdef MAP_POPULATE
1578+
setint(dict, "MAP_POPULATE", MAP_POPULATE);
1579+
#endif
15771580

15781581
setint(dict, "PAGESIZE", (long)my_getpagesize());
15791582

0 commit comments

Comments
 (0)