Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
#include "php.h"
#include "php_globals.h"

#if defined(__APPLE__)
#include <mach/machine/vm_param.h>
#endif

// FIXME: Breaks the declaration of the function below
#undef zenderror

Expand Down Expand Up @@ -1275,6 +1279,10 @@ ZEND_API size_t zend_get_page_size(void)
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
return system_info.dwPageSize;
#elif defined(__APPLE__)
/* Is in fact the global vm_page_size which is a kernel global
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose is to safe syscall, wouldn't it be better to cache the result like in https://github.com/apple-open-source-mirror/Libc/blob/5e566be7a7047360adfb35ffc44c6a019a854bea/gen/FreeBSD/getpagesize.c#L50-L64 for all platforms?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the callsites already cache it., like here. If you mean in here to me windodws/posix cases would benefit it, for mac it is just a variable.

* we save a syscall as they fetch the same cached value */
return (size_t)PAGE_SIZE;
#elif defined(__FreeBSD__)
/* This returns the value obtained from
* the auxv vector, avoiding a syscall. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment accurate for macOS? From your link https://github.com/apple-open-source-mirror/Libc/blob/5e566be7a7047360adfb35ffc44c6a019a854bea/gen/FreeBSD/sysconf.c#L296 it appears that sysconf(_SC_PAGESIZE) just calls getpagesize(), so we only save a single function call, not a syscall, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I can correct the comment.

Expand Down