Skip to content

Commit 2c08c57

Browse files
committed
zend: optimisation for zend_page_size for macos.
Using the kernel global vm_page_size set by the dynamic linker before the process starts.
1 parent 7ca21d2 commit 2c08c57

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Zend/zend.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#include "php.h"
4343
#include "php_globals.h"
4444

45+
#if defined(__APPLE__)
46+
#include <mach/machine/vm_param.h>
47+
#endif
48+
4549
// FIXME: Breaks the declaration of the function below
4650
#undef zenderror
4751

@@ -1275,6 +1279,10 @@ ZEND_API size_t zend_get_page_size(void)
12751279
SYSTEM_INFO system_info;
12761280
GetSystemInfo(&system_info);
12771281
return system_info.dwPageSize;
1282+
#elif defined(__APPLE__)
1283+
/* Is in fact the global vm_page_size which is a kernel global
1284+
* we save a syscall as they fetch the same cached value */
1285+
return (size_t)PAGE_SIZE;
12781286
#elif defined(__FreeBSD__)
12791287
/* This returns the value obtained from
12801288
* the auxv vector, avoiding a syscall. */

0 commit comments

Comments
 (0)