From 21f10fd262328f4fab232daa133fc7f6da92b065 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Tue, 9 Dec 2025 15:23:49 -0500 Subject: [PATCH] gh-142490: for macOS, use vm_page_size directly from the kernel header We do not need to call sysconf for this at all. --- .../Library/2025-12-09-15-26-02.gh-issue-142490.-ov3D8.rst | 2 ++ Modules/_ctypes/malloc_closure.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2025-12-09-15-26-02.gh-issue-142490.-ov3D8.rst diff --git a/Misc/NEWS.d/next/Library/2025-12-09-15-26-02.gh-issue-142490.-ov3D8.rst b/Misc/NEWS.d/next/Library/2025-12-09-15-26-02.gh-issue-142490.-ov3D8.rst new file mode 100644 index 00000000000000..d770c5812e7703 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-09-15-26-02.gh-issue-142490.-ov3D8.rst @@ -0,0 +1,2 @@ +It comes straight from the mach header as a global variable. No need to call +to get it. diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index 62c7aa5d6affbf..4b230bb8522072 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -12,6 +12,9 @@ # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) # define MAP_ANONYMOUS MAP_ANON # endif +# if defined(__APPLE__) +# include +# endif #endif #include "ctypes.h" #include "pycore_mmap.h" // _PyAnnotateMemoryMap() @@ -55,7 +58,9 @@ static void more_core(void) } #else if (!_pagesize) { -#ifdef _SC_PAGESIZE +#ifdef __APPLE__ + _pagesize = vm_page_size; +#elif defined(_SC_PAGESIZE) _pagesize = sysconf(_SC_PAGESIZE); #else _pagesize = getpagesize();