Skip to content

Commit 9f63c48

Browse files
committed
gh-142490: for macOS, use vm_page_size directly from the kernel header
We do not need to call sysconf for this at all.
1 parent 02c085d commit 9f63c48

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
It comes straight from the mach header as a global variable. No need to call
2+
to get it.

Modules/_ctypes/malloc_closure.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
1313
# define MAP_ANONYMOUS MAP_ANON
1414
# endif
15+
# if defined(__APPLE__)
16+
# include <mach/vm_page_size.h>
17+
# endif
1518
#endif
1619
#include "ctypes.h"
1720
#include "pycore_mmap.h" // _PyAnnotateMemoryMap()
@@ -55,7 +58,9 @@ static void more_core(void)
5558
}
5659
#else
5760
if (!_pagesize) {
58-
#ifdef _SC_PAGESIZE
61+
#ifdef __APPLE__
62+
_pagesize = vm_page_size;
63+
#elif defined(_SC_PAGESIZE)
5964
_pagesize = sysconf(_SC_PAGESIZE);
6065
#else
6166
_pagesize = getpagesize();

0 commit comments

Comments
 (0)