-
Notifications
You must be signed in to change notification settings - Fork 8k
zend: optimisation for zend_page_size for macos. #19494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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 | ||
* 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. */ | ||
|
||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.