summaryrefslogtreecommitdiff
path: root/Zend/zend_stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_stream.c')
-rw-r--r--Zend/zend_stream.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c
index 7a3c8a1a2..422244098 100644
--- a/Zend/zend_stream.c
+++ b/Zend/zend_stream.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
- | Copyright (c) 1998-2011 Zend Technologies Ltd. (http://www.zend.com) |
+ | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_stream.c 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: zend_stream.c 321634 2012-01-01 13:15:04Z felipe $ */
#include "zend.h"
@@ -27,10 +27,24 @@
#include <sys/types.h>
#include <sys/stat.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
@@ -215,9 +229,11 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
#if HAVE_MMAP
+ size_t page_size = REAL_PAGE_SIZE;
+
if (file_handle->handle.fp &&
size != 0 &&
- ((size - 1) % PAGE_SIZE) <= PAGE_SIZE - ZEND_MMAP_AHEAD) {
+ ((size - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD) {
/* *buf[size] is zeroed automatically by the kernel */
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
if (*buf != MAP_FAILED) {