[Pkg-php-commits] [php/debian-sid] Add patch to use sysconf() to determine the page size
Raphael Geissert
geissert at debian.org
Tue Feb 9 23:21:56 UTC 2010
---
debian/patches/page_size_fixes.patch | 108 ++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 109 insertions(+), 0 deletions(-)
create mode 100644 debian/patches/page_size_fixes.patch
diff --git a/debian/patches/page_size_fixes.patch b/debian/patches/page_size_fixes.patch
new file mode 100644
index 0000000..f24b732
--- /dev/null
+++ b/debian/patches/page_size_fixes.patch
@@ -0,0 +1,108 @@
+Description: Don't assume value of PAGE_SIZE if sys/mman.h does not
+ define it. Instead, use sysconf() at runtime if available.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-02-09
+
+Index: php/Zend/zend_stream.c
+===================================================================
+--- php.orig/Zend/zend_stream.c
++++ php/Zend/zend_stream.c
+@@ -27,10 +27,15 @@
+
+ #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_UNISTD_H
++# include <unistd.h>
++#endif
++#if !HAVE_UNISTD_H || (!defined(_SC_PAGESIZE) && !defined(_SC_PAGE_SIZE))
++# if HAVE_SYS_MMAN_H
++# include <sys/mman.h>
++# ifndef PAGE_SIZE
++# define PAGE_SIZE 4096
++# endif
+ # endif
+ #endif
+
+@@ -215,9 +220,21 @@ ZEND_API int zend_stream_fixup(zend_file
+
+ if (old_type == ZEND_HANDLE_FP && !file_handle->handle.stream.isatty && size) {
+ #if HAVE_MMAP
++ long page_size = 0;
++
++# if HAVE_UNISTD_H
++# ifdef _SC_PAGESIZE
++ page_size = sysconf(_SC_PAGESIZE);
++# else
++ page_size = sysconf(_SC_PAGE_SIZE);
++# endif
++# else
++ page_size = PAGE_SIZE;
++# endif
++
+ 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) {
+Index: php/main/main.c
+===================================================================
+--- php.orig/main/main.c
++++ php/main/main.c
+@@ -91,15 +91,17 @@
+ #include "SAPI.h"
+ #include "rfc1867.h"
+
+-#if HAVE_SYS_MMAN_H
+-# include <sys/mman.h>
+-# ifndef PAGE_SIZE
++#if !HAVE_UNISTD_H || (!defined(_SC_PAGESIZE) && !defined(_SC_PAGE_SIZE))
++# if HAVE_SYS_MMAN_H
++# include <sys/mman.h>
++# ifndef PAGE_SIZE
++# define PAGE_SIZE 4096
++# endif
++# endif
++# ifdef PHP_WIN32
+ # define PAGE_SIZE 4096
+ # endif
+ #endif
+-#ifdef PHP_WIN32
+-# define PAGE_SIZE 4096
+-#endif
+ /* }}} */
+
+ PHPAPI int (*php_register_internal_extensions_func)(TSRMLS_D) = php_register_internal_extensions;
+@@ -1161,6 +1163,17 @@ PHPAPI int php_stream_open_for_zend_ex(c
+ char *p;
+ size_t len, mapped_len;
+ php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &handle->opened_path);
++ long page_size = 0;
++
++#if HAVE_UNISTD_H
++# ifdef _SC_PAGESIZE
++ page_size = sysconf(_SC_PAGESIZE);
++# else
++ page_size = sysconf(_SC_PAGE_SIZE);
++# endif
++#else
++ page_size = PAGE_SIZE;
++#endif
+
+ if (stream) {
+ handle->filename = (char*)filename;
+@@ -1173,7 +1186,7 @@ PHPAPI int php_stream_open_for_zend_ex(c
+ 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
++ && ((len - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD
+ && 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;
diff --git a/debian/patches/series b/debian/patches/series
index 41a7214..b7fb32c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -25,6 +25,7 @@ libtool2.2.patch
115-autoconf_ftbfs.patch
116-posixness_fix.patch
libdb_is_-ldb
+page_size_fixes.patch
suhosin.patch
fix_broken_upstream_tests.patch
use_embedded_timezonedb.patch
--
1.6.3.3
More information about the Pkg-php-commits
mailing list