From 66c47b63a0df3143fe48d6efc1183eecda2a363d Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 29 Dec 2021 13:52:29 +0000 Subject: [PATCH] bpo-46176: mmap module adding MAP_STACK constant. (GH-30252) --- Doc/library/mmap.rst | 4 ++++ .../next/Library/2021-12-25-11-11-21.bpo-46176.EOY9wd.rst | 1 + Modules/mmapmodule.c | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2021-12-25-11-11-21.bpo-46176.EOY9wd.rst diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index c1ebd80abd9..d19580cd7ee 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -367,8 +367,12 @@ MAP_* Constants MAP_ANON MAP_ANONYMOUS MAP_POPULATE + MAP_STACK 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. + + .. versionadded:: 3.11 + Added MAP_STACK constant. diff --git a/Misc/NEWS.d/next/Library/2021-12-25-11-11-21.bpo-46176.EOY9wd.rst b/Misc/NEWS.d/next/Library/2021-12-25-11-11-21.bpo-46176.EOY9wd.rst new file mode 100644 index 00000000000..4a50c261720 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-12-25-11-11-21.bpo-46176.EOY9wd.rst @@ -0,0 +1 @@ +Adding the ``MAP_STACK`` constant for the mmap module. \ No newline at end of file diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 399cb0a99ad..742bcb3d145 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1637,6 +1637,11 @@ mmap_exec(PyObject *module) #endif #ifdef MAP_POPULATE ADD_INT_MACRO(module, MAP_POPULATE); +#endif +#ifdef MAP_STACK + // Mostly a no-op on Linux and NetBSD, but useful on OpenBSD + // for stack usage (even on x86 arch) + ADD_INT_MACRO(module, MAP_STACK); #endif if (PyModule_AddIntConstant(module, "PAGESIZE", (long)my_getpagesize()) < 0 ) { return -1;