diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index 698c1765378..d9825b47c71 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -337,6 +337,8 @@ MADV_* Constants MADV_NOCORE MADV_CORE MADV_PROTECT + MADV_FREE_REUSABLE + MADV_FREE_REUSE These options can be passed to :meth:`mmap.madvise`. Not every option will be present on every system. diff --git a/Misc/NEWS.d/next/macOS/2020-11-01-15-10-28.bpo-42232.2zI1GN.rst b/Misc/NEWS.d/next/macOS/2020-11-01-15-10-28.bpo-42232.2zI1GN.rst new file mode 100644 index 00000000000..d431a9d1e32 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2020-11-01-15-10-28.bpo-42232.2zI1GN.rst @@ -0,0 +1 @@ +Added Darwin specific madvise options to mmap module. \ No newline at end of file diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 1e9684970f5..1e66962d37b 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1667,6 +1667,14 @@ mmap_exec(PyObject *module) #ifdef MADV_PROTECT ADD_INT_MACRO(module, MADV_PROTECT); #endif + + // Darwin-specific +#ifdef MADV_FREE_REUSABLE // (As MADV_FREE but reclaims more faithful for task_info/Activity Monitor...) + ADD_INT_MACRO(module, MADV_FREE_REUSABLE); +#endif +#ifdef MADV_FREE_REUSE // (Reuse pages previously tagged as reusable) + ADD_INT_MACRO(module, MADV_FREE_REUSE); +#endif #endif // HAVE_MADVISE return 0; }