diff options
author | Xinchen Hui <laruence@php.net> | 2011-10-16 01:19:55 +0000 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2011-10-16 01:19:55 +0000 |
commit | c5ac13f632d4f09c8347146f7d49b476b57ebe72 (patch) | |
tree | 1176d7b1e520cfbc5dfeb394525cd37dcd9d59e4 | |
parent | 70a6a67c1e4cbd2ab5f138d387acc4992c4402ed (diff) | |
download | php-git-c5ac13f632d4f09c8347146f7d49b476b57ebe72.tar.gz |
Merge r316812 to trunk
-rw-r--r-- | main/main.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/main/main.c b/main/main.c index 7ee8e69057..67d2ff1b1e 100644 --- a/main/main.c +++ b/main/main.c @@ -93,14 +93,25 @@ #include "SAPI.h" #include "rfc1867.h" -#if HAVE_SYS_MMAN_H -# include <sys/mman.h> -# ifndef PAGE_SIZE -# define PAGE_SIZE 4096 +#if HAVE_MMAP +# if HAVE_UNISTD_H +# include <unistd.h> +# if defined(_SC_PAGESIZE) +# define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE); +# elif defined(_SC_PAGE_SIZE) +# define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE); +# endif +# endif +# if HAVE_SYS_MMAN_H +# include <sys/mman.h> +# endif +# ifndef REAL_PAGE_SIZE +# ifdef PAGE_SIZE +# define REAL_PAGE_SIZE PAGE_SIZE +# else +# define REAL_PAGE_SIZE 4096 +# endif # endif -#endif -#ifdef PHP_WIN32 -# define PAGE_SIZE 4096 #endif /* }}} */ @@ -1234,6 +1245,10 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &handle->opened_path); if (stream) { +#if HAVE_MMAP + size_t page_size = REAL_PAGE_SIZE; +#endif + handle->filename = (char*)filename; handle->free_filename = 0; handle->handle.stream.handle = stream; @@ -1244,7 +1259,9 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h memset(&handle->handle.stream.mmap, 0, sizeof(handle->handle.stream.mmap)); len = php_zend_stream_fsizer(stream TSRMLS_CC); if (len != 0 - && ((len - 1) % PAGE_SIZE) <= PAGE_SIZE - ZEND_MMAP_AHEAD +#if HAVE_MMAP + && ((len - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD +#endif && php_stream_mmap_possible(stream) && (p = php_stream_mmap_range(stream, 0, len, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped_len)) != NULL) { handle->handle.stream.closer = php_zend_stream_mmap_closer; |