From: Hauke Mehrtens Date: Wed, 22 Dec 2010 01:54:35 +0000 (+0000) Subject: php5: update version to 5.3.4 X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;h=454bad7c1c049183712b6c413e165b9168d4d4f9 php5: update version to 5.3.4 * fix build with libiconv * update apc extension SVN-Revision: 24774 --- diff --git a/lang/php5/Makefile b/lang/php5/Makefile index 538f5d7482..4ffc3e8d54 100644 --- a/lang/php5/Makefile +++ b/lang/php5/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=php -PKG_VERSION:=5.3.1 -PKG_RELEASE:=4 +PKG_VERSION:=5.3.4 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://www.php.net/distributions/ -PKG_MD5SUM:=63e97ad450f0f7259e785100b634c797 +PKG_MD5SUM:=2c069d8f690933e3bf6a8741ed818150 PKG_FIXUP:=libtool no-autoreconf PKG_BUILD_PARALLEL:=1 @@ -390,7 +390,7 @@ PKG_CONFIGURE_OPTS:= \ --disable-phar ifneq ($(SDK),) - PKG_BUILD_DEPENDS:=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libsqlite2 libpthread libsqlite3 libpcre libxml2 + PKG_BUILD_DEPENDS+=libopenssl zlib libcurl libgd libgmp libopenldap libmysqlclient libpq libsqlite2 libpthread libsqlite3 libpcre libxml2 libiconv # force PKG_CONFIGURE_{LIBS,OPTS} below when built in the SDK CONFIG_PACKAGE_php5-cli:=m CONFIG_PACKAGE_php5-cgi:=m @@ -469,7 +469,7 @@ else endif ifneq ($(CONFIG_PACKAGE_php5-mod-iconv),) - PKG_CONFIGURE_OPTS+= --with-iconv=shared,"$(STAGING_DIR)/usr/lib/libiconv" + PKG_CONFIGURE_OPTS+= --with-iconv=shared,"$(STAGING_DIR)/usr" else PKG_CONFIGURE_OPTS+= --without-iconv endif diff --git a/lang/php5/patches/001-configure_cross.patch b/lang/php5/patches/001-configure_cross.patch deleted file mode 100644 index 7265676db8..0000000000 --- a/lang/php5/patches/001-configure_cross.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -Naur php-5.3.1.orig/configure php-5.3.1/configure ---- php-5.3.1.orig/configure 2009-11-18 21:11:57.000000000 +0100 -+++ php-5.3.1/configure 2010-01-15 23:43:10.000000000 +0100 -@@ -14712,7 +14712,7 @@ - ac_libs=$LIBS - LIBS="$LIBS -ldl" - if test "$cross_compiling" = yes; then -- found=no -+ found=yes - else - cat > conftest.$ac_ext <&6 - echo "configure:54501: checking for 3 arg ldap_set_rebind_proc" >&5 diff --git a/lang/php5/patches/005-APC.patch b/lang/php5/patches/005-APC.patch index d11859e2e1..a52977477f 100644 --- a/lang/php5/patches/005-APC.patch +++ b/lang/php5/patches/005-APC.patch @@ -1,12 +1,11 @@ -diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c ---- php-5.3.1.orig/ext/apc/apc_bin.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_bin.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,946 @@ +--- /dev/null ++++ b/ext/apc/apc_bin.c +@@ -0,0 +1,987 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -21,7 +20,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + + */ + -+/* $Id: apc_bin.c 284580 2009-07-22 06:05:31Z kalle $ */ ++/* $Id: apc_bin.c 303383 2010-09-15 08:15:58Z dmitry $ */ + +/* Creates a binary architecture specific output to a string or file containing + * the current cache contents for both fies and user variables. This is accomplished @@ -54,7 +53,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + ptr = (void*)((long)(ptr) - (long)(bd)); \ + printf("%x in %s on line %d", ptr, __FILE__, __LINE__); \ + } else if((long)ptr > bd->size) { /* not swizzled */ \ -+ apc_eprint("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d", (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ ++ apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ + } \ + printf("\n"); \ + } while(0); @@ -73,7 +72,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + if((long)bd < (long)ptr && (ulong)ptr < ((long)bd + bd->size)) { \ + ptr = (void*)((long)(ptr) - (long)(bd)); \ + } else if((ulong)ptr > bd->size) { /* not swizzled */ \ -+ apc_eprint("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d", (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ ++ apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, ptr, ((long)bd + bd->size), __FILE__, __LINE__); \ + } \ + } while(0); + @@ -85,9 +84,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c +#endif + + -+static void *apc_bd_alloc(size_t size); -+static void apc_bd_free(void *ptr); -+static void *apc_bd_alloc_ex(void *ptr_new, size_t size); ++static void *apc_bd_alloc(size_t size TSRMLS_DC); ++static void apc_bd_free(void *ptr TSRMLS_DC); ++static void *apc_bd_alloc_ex(void *ptr_new, size_t size TSRMLS_DC); + +typedef void (*apc_swizzle_cb_t)(apc_bd_t *bd, zend_llist *ll, void *ptr TSRMLS_DC); + @@ -113,18 +112,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + +/* {{{ apc_bd_alloc + * callback for copy_* functions */ -+static void *apc_bd_alloc(size_t size) { -+ return apc_bd_alloc_ex(NULL, size); ++static void *apc_bd_alloc(size_t size TSRMLS_DC) { ++ return apc_bd_alloc_ex(NULL, size TSRMLS_CC); +} /* }}} */ + + +/* {{{ apc_bd_free + * callback for copy_* functions */ -+static void apc_bd_free(void *ptr) { ++static void apc_bd_free(void *ptr TSRMLS_DC) { + size_t *size; -+ TSRMLS_FETCH(); + if(zend_hash_index_find(&APCG(apc_bd_alloc_list), (ulong)ptr, (void**)&size) == FAILURE) { -+ apc_eprint("apc_bd_free could not free pointer (not found in list: %x)", ptr); ++ apc_error("apc_bd_free could not free pointer (not found in list: %x)" TSRMLS_CC, ptr); + } + APCG(apc_bd_alloc_ptr) = (void*)((size_t)APCG(apc_bd_alloc_ptr) - *size); + zend_hash_index_del(&APCG(apc_bd_alloc_list), (ulong)ptr); @@ -137,9 +135,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + * with a range of size. If ptr_new is NULL, returns the next available + * block of given size. + */ -+static void *apc_bd_alloc_ex(void *ptr_new, size_t size) { ++static void *apc_bd_alloc_ex(void *ptr_new, size_t size TSRMLS_DC) { + void *rval; -+ TSRMLS_FETCH(); + + rval = APCG(apc_bd_alloc_ptr); + if(ptr_new != NULL) { /* reset ptrs */ @@ -148,10 +145,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + } else { /* alloc block */ + APCG(apc_bd_alloc_ptr) = (void*)((size_t)APCG(apc_bd_alloc_ptr) + size); +#if APC_BINDUMP_DEBUG -+ apc_nprint("apc_bd_alloc: rval: 0x%x ptr: 0x%x ubptr: 0x%x size: %d", rval, APCG(apc_bd_alloc_ptr), APCG(apc_bd_alloc_ubptr), size); ++ apc_notice("apc_bd_alloc: rval: 0x%x ptr: 0x%x ubptr: 0x%x size: %d" TSRMLS_CC, rval, APCG(apc_bd_alloc_ptr), APCG(apc_bd_alloc_ubptr), size); +#endif + if(APCG(apc_bd_alloc_ptr) > APCG(apc_bd_alloc_ubptr)) { -+ apc_eprint("Exceeded bounds check in apc_bd_alloc_ex by %d bytes.", (unsigned char *) APCG(apc_bd_alloc_ptr) - (unsigned char *) APCG(apc_bd_alloc_ubptr)); ++ apc_error("Exceeded bounds check in apc_bd_alloc_ex by %d bytes." TSRMLS_CC, (unsigned char *) APCG(apc_bd_alloc_ptr) - (unsigned char *) APCG(apc_bd_alloc_ubptr)); + } + zend_hash_index_update(&APCG(apc_bd_alloc_list), (ulong)rval, &size, sizeof(size_t), NULL); + } @@ -170,7 +167,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + printf(" in %s on line %d \n", file, line); +#endif + } else if((ulong)ptr > bd->size) { -+ apc_eprint("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d", (long)bd, *ptr, ((long)bd + bd->size), file, line); \ ++ apc_error("pointer to be swizzled is not within allowed memory range! (%x < %x < %x) in %s on %d" TSRMLS_CC, (long)bd, *ptr, ((long)bd + bd->size), file, line); \ + } + } +} /* }}} */ @@ -195,6 +192,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + + /* swizzle op_array */ + for(i=0; i < op_array->last; i++) { ++#ifndef ZEND_ENGINE_2_4 + if(op_array->opcodes[i].result.op_type == IS_CONST) { + apc_swizzle_zval(bd, ll, &op_array->opcodes[i].result.u.constant TSRMLS_CC); + } @@ -204,14 +202,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + if(op_array->opcodes[i].op2.op_type == IS_CONST) { + apc_swizzle_zval(bd, ll, &op_array->opcodes[i].op2.u.constant TSRMLS_CC); + } ++#endif + switch (op_array->opcodes[i].opcode) { + case ZEND_JMP: ++#ifdef ZEND_ENGINE_2_4 ++ apc_swizzle_ptr(bd, ll, &op_array->opcodes[i].op1.jmp_addr); ++#else + apc_swizzle_ptr(bd, ll, &op_array->opcodes[i].op1.u.jmp_addr); ++#endif + case ZEND_JMPZ: + case ZEND_JMPNZ: + case ZEND_JMPZ_EX: + case ZEND_JMPNZ_EX: ++#ifdef ZEND_ENGINE_2_4 ++ apc_swizzle_ptr(bd, ll, &op_array->opcodes[i].op2.jmp_addr); ++#else + apc_swizzle_ptr(bd, ll, &op_array->opcodes[i].op2.u.jmp_addr); ++#endif + } + } + apc_swizzle_ptr(bd, ll, &op_array->opcodes); @@ -274,8 +281,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + apc_swizzle_ptr(bd, ll, &ce->name); + } + -+ if(ce->doc_comment) { -+ apc_swizzle_ptr(bd, ll, &ce->doc_comment); ++ if (ce->type == ZEND_USER_CLASS && ZEND_CE_DOC_COMMENT(ce)) { ++ apc_swizzle_ptr(bd, ll, &ZEND_CE_DOC_COMMENT(ce)); + } + +#ifndef ZEND_ENGINE_2 @@ -283,12 +290,38 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c +#endif + + apc_swizzle_hashtable(bd, ll, &ce->function_table, (apc_swizzle_cb_t)apc_swizzle_function, 0 TSRMLS_CC); ++#ifdef ZEND_ENGINE_2_4 ++ if (ce->default_properties_table) { ++ int i; ++ ++ for (i = 0; i < ce->default_properties_count; i++) { ++ if (ce->default_properties_table[i]) { ++ apc_swizzle_ptr(bd, ll, &ce->default_properties_table[i]); ++ apc_swizzle_zval(bd, ll, ce->default_properties_table[i] TSRMLS_CC); ++ } ++ } ++ } ++#else + apc_swizzle_hashtable(bd, ll, &ce->default_properties, (apc_swizzle_cb_t)apc_swizzle_zval, 1 TSRMLS_CC); ++#endif + +#ifdef ZEND_ENGINE_2 + apc_swizzle_hashtable(bd, ll, &ce->properties_info, (apc_swizzle_cb_t)apc_swizzle_property_info, 0 TSRMLS_CC); +#endif + ++#ifdef ZEND_ENGINE_2_4 ++ if (ce->default_static_members_table) { ++ int i; ++ ++ for (i = 0; i < ce->default_static_members_count; i++) { ++ if (ce->default_static_members_table[i]) { ++ apc_swizzle_ptr(bd, ll, &ce->default_static_members_table[i]); ++ apc_swizzle_zval(bd, ll, ce->default_static_members_table[i] TSRMLS_CC); ++ } ++ } ++ } ++ ce->static_members_table = ce->default_static_members_table; ++#else + apc_swizzle_hashtable(bd, ll, &ce->default_static_members, (apc_swizzle_cb_t)apc_swizzle_zval, 1 TSRMLS_CC); + + if(ce->static_members != &ce->default_static_members) { @@ -296,12 +329,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + } else { + apc_swizzle_ptr(bd, ll, &ce->static_members); + } ++#endif + + apc_swizzle_hashtable(bd, ll, &ce->constants_table, (apc_swizzle_cb_t)apc_swizzle_zval, 1 TSRMLS_CC); + -+ if(ce->builtin_functions) { -+ for(i=0; ce->builtin_functions[i].fname; i++) { -+ apc_swizzle_function_entry(bd, ll, &ce->builtin_functions[i] TSRMLS_CC); ++ if(ce->type == ZEND_INTERNAL_CLASS && ZEND_CE_BUILTIN_FUNCTIONS(ce)) { ++ for(i=0; ZEND_CE_BUILTIN_FUNCTIONS(ce)[i].fname; i++) { ++ apc_swizzle_function_entry(bd, ll, &ZEND_CE_BUILTIN_FUNCTIONS(ce)[i] TSRMLS_CC); + } + } + @@ -320,7 +354,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + apc_swizzle_ptr(bd, ll, &ce->__tostring); +#endif + -+ apc_swizzle_ptr(bd, ll, &ce->filename); ++ if (ce->type == ZEND_USER_CLASS) { ++ apc_swizzle_ptr(bd, ll, &ZEND_CE_FILENAME(ce)); ++ } +} /* }}} */ + + @@ -517,7 +553,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + PHP_MD5Update(&context, (const unsigned char*)bd, bd->size); + PHP_MD5Final(digest, &context); + if(memcmp(md5_orig, digest, 16)) { -+ apc_eprint("MD5 checksum of binary dump failed."); ++ apc_error("MD5 checksum of binary dump failed." TSRMLS_CC); + memcpy(bd->md5, md5_orig, 16); /* add back md5 checksum */ + return -1; + } @@ -529,7 +565,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32tab[(crc ^ (*crc_p)) & 0xFF ]; + } + if(crc_orig != crc) { -+ apc_eprint("CRC32 checksum of binary dump failed."); ++ apc_error("CRC32 checksum of binary dump failed." TSRMLS_CC); + bd->crc = crc_orig; + return -1; + } @@ -597,12 +633,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + + /* fixup hashtable destructor pointers */ + ce->function_table.pDestructor = (dtor_func_t)zend_function_dtor; ++#ifndef ZEND_ENGINE_2_4 + ce->default_properties.pDestructor = (dtor_func_t)zval_ptr_dtor_wrapper; ++#endif + ce->properties_info.pDestructor = (dtor_func_t)zval_ptr_dtor_wrapper; ++#ifndef ZEND_ENGINE_2_4 + ce->default_static_members.pDestructor = (dtor_func_t)zval_ptr_dtor_wrapper; + if (ce->static_members) { + ce->static_members->pDestructor = (dtor_func_t)zval_ptr_dtor_wrapper; + } ++#endif + ce->constants_table.pDestructor = (dtor_func_t)zval_ptr_dtor_wrapper; +} +/* }}} */ @@ -633,7 +673,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + for(i=0; i < apc_user_cache->num_slots; i++) { + sp = apc_user_cache->slots[i]; + for(; sp != NULL; sp = sp->next) { -+ if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len+1)) { ++ if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len)) { + size += sizeof(apc_bd_entry_t*) + sizeof(apc_bd_entry_t); + size += sp->value->mem_size - (sizeof(apc_cache_entry_t) - sizeof(apc_cache_entry_value_t)); + count++; @@ -651,7 +691,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + } + } else { + /* TODO: Currently we don't support APC_CACHE_KEY_FILE type. We need to store the path and re-stat on load */ -+ apc_wprint("Excluding some files from apc_bin_dump[file]. Cached files must be included using full path with apc.stat=0."); ++ apc_warning("Excluding some files from apc_bin_dump[file]. Cached files must be included using full path with apc.stat=0." TSRMLS_CC); + } + } + } @@ -660,16 +700,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + bd = emalloc(size); + bd->size = size; + pool_ptr = emalloc(sizeof(apc_pool)); -+ apc_bd_alloc_ex(pool_ptr, sizeof(apc_pool)); -+ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_bd_alloc, apc_bd_free, NULL, NULL); /* ideally the pool wouldn't be alloc'd as part of this */ ++ apc_bd_alloc_ex(pool_ptr, sizeof(apc_pool) TSRMLS_CC); ++ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_bd_alloc, apc_bd_free, NULL, NULL TSRMLS_CC); /* ideally the pool wouldn't be alloc'd as part of this */ + if (!ctxt.pool) { /* TODO need to cleanup */ -+ apc_wprint("Unable to allocate memory for pool."); ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + return NULL; + } + ctxt.copy = APC_COPY_IN_USER; /* avoid stupid ALLOC_ZVAL calls here, hack */ -+ apc_bd_alloc_ex( (void*)((long)bd + sizeof(apc_bd_t)), bd->size - sizeof(apc_bd_t) -1); ++ apc_bd_alloc_ex((void*)((long)bd + sizeof(apc_bd_t)), bd->size - sizeof(apc_bd_t) -1 TSRMLS_CC); + bd->num_entries = count; -+ bd->entries = apc_bd_alloc_ex(NULL, sizeof(apc_bd_entry_t) * count); ++ bd->entries = apc_bd_alloc_ex(NULL, sizeof(apc_bd_entry_t) * count TSRMLS_CC); + + /* User entries */ + zend_hash_init(&APCG(copied_zvals), 0, NULL, NULL, 0); @@ -677,13 +717,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + for(i=0; i < apc_user_cache->num_slots; i++) { + sp = apc_user_cache->slots[i]; + for(; sp != NULL; sp = sp->next) { -+ if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len+1)) { ++ if(apc_bin_checkfilter(user_vars, sp->key.data.user.identifier, sp->key.data.user.identifier_len)) { + ep = &bd->entries[count]; + ep->type = sp->value->type; -+ ep->val.user.info = apc_bd_alloc(sp->value->data.user.info_len+1); -+ memcpy(ep->val.user.info, sp->value->data.user.info, sp->value->data.user.info_len+1); ++ ep->val.user.info = apc_bd_alloc(sp->value->data.user.info_len TSRMLS_CC); ++ memcpy(ep->val.user.info, sp->value->data.user.info, sp->value->data.user.info_len); + ep->val.user.info_len = sp->value->data.user.info_len; -+ ep->val.user.val = apc_copy_zval(NULL, sp->value->data.user.val, &ctxt); ++ ep->val.user.val = apc_copy_zval(NULL, sp->value->data.user.val, &ctxt TSRMLS_CC); + ep->val.user.ttl = sp->value->data.user.ttl; + + /* swizzle pointers */ @@ -706,17 +746,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + if(apc_bin_checkfilter(files, sp->key.data.fpfile.fullpath, sp->key.data.fpfile.fullpath_len+1)) { + ep = &bd->entries[count]; + ep->type = sp->key.type; -+ ep->val.file.filename = apc_bd_alloc(strlen(sp->value->data.file.filename)+1); ++ ep->val.file.filename = apc_bd_alloc(strlen(sp->value->data.file.filename) + 1 TSRMLS_CC); + strcpy(ep->val.file.filename, sp->value->data.file.filename); + ep->val.file.op_array = apc_copy_op_array(NULL, sp->value->data.file.op_array, &ctxt TSRMLS_CC); + + for(ep->num_functions=0; sp->value->data.file.functions[ep->num_functions].function != NULL;) { ep->num_functions++; } -+ ep->val.file.functions = apc_bd_alloc(sizeof(apc_function_t) * ep->num_functions); ++ ep->val.file.functions = apc_bd_alloc(sizeof(apc_function_t) * ep->num_functions TSRMLS_CC); + for(fcount=0; fcount < ep->num_functions; fcount++) { + memcpy(&ep->val.file.functions[fcount], &sp->value->data.file.functions[fcount], sizeof(apc_function_t)); -+ ep->val.file.functions[fcount].name = apc_xmemcpy(sp->value->data.file.functions[fcount].name, sp->value->data.file.functions[fcount].name_len+1, apc_bd_alloc); ++ ep->val.file.functions[fcount].name = apc_xmemcpy(sp->value->data.file.functions[fcount].name, sp->value->data.file.functions[fcount].name_len+1, apc_bd_alloc TSRMLS_CC); + ep->val.file.functions[fcount].name_len = sp->value->data.file.functions[fcount].name_len; -+ ep->val.file.functions[fcount].function = apc_bd_alloc(sizeof(zend_function)); ++ ep->val.file.functions[fcount].function = apc_bd_alloc(sizeof(zend_function) TSRMLS_CC); + efp = ep->val.file.functions[fcount].function; + sfp = sp->value->data.file.functions[fcount].function; + switch(sfp->type) { @@ -742,12 +782,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + + + for(ep->num_classes=0; sp->value->data.file.classes[ep->num_classes].class_entry != NULL;) { ep->num_classes++; } -+ ep->val.file.classes = apc_bd_alloc(sizeof(apc_class_t) * ep->num_classes); ++ ep->val.file.classes = apc_bd_alloc(sizeof(apc_class_t) * ep->num_classes TSRMLS_CC); + for(fcount=0; fcount < ep->num_classes; fcount++) { -+ ep->val.file.classes[fcount].name = apc_xmemcpy(sp->value->data.file.classes[fcount].name, sp->value->data.file.classes[fcount].name_len+1, apc_bd_alloc); ++ ep->val.file.classes[fcount].name = apc_xmemcpy(sp->value->data.file.classes[fcount].name, sp->value->data.file.classes[fcount].name_len + 1, apc_bd_alloc TSRMLS_CC); + ep->val.file.classes[fcount].name_len = sp->value->data.file.classes[fcount].name_len; -+ ep->val.file.classes[fcount].class_entry = apc_copy_class_entry(NULL, sp->value->data.file.classes[fcount].class_entry, &ctxt); -+ ep->val.file.classes[fcount].parent_name = apc_xstrdup(sp->value->data.file.classes[fcount].parent_name, apc_bd_alloc); ++ ep->val.file.classes[fcount].class_entry = apc_copy_class_entry(NULL, sp->value->data.file.classes[fcount].class_entry, &ctxt TSRMLS_CC); ++ ep->val.file.classes[fcount].parent_name = apc_xstrdup(sp->value->data.file.classes[fcount].parent_name, apc_bd_alloc TSRMLS_CC); + + apc_swizzle_ptr(bd, &ll, &ep->val.file.classes[fcount].name); + apc_swizzle_ptr(bd, &ll, &ep->val.file.classes[fcount].parent_name); @@ -812,9 +852,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + t = apc_time(); + + for(i = 0; i < bd->num_entries; i++) { -+ ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect); ++ ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + if (!ctxt.pool) { /* TODO need to cleanup previous pools */ -+ apc_wprint("Unable to allocate memory for pool."); ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + goto failure; + } + ep = &bd->entries[i]; @@ -828,7 +868,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + HANDLE_BLOCK_INTERRUPTIONS(); +#if NONBLOCKING_LOCK_AVAILABLE + if(APCG(write_lock)) { -+ if(!apc_cache_write_lock(apc_cache)) { ++ if(!apc_cache_write_lock(apc_cache TSRMLS_CC)) { + HANDLE_UNBLOCK_INTERRUPTIONS(); + return -1; + } @@ -839,15 +879,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + } + apc_bin_fixup_op_array(alloc_op_array); + -+ if(! (alloc_functions = apc_sma_malloc(sizeof(apc_function_t) * (ep->num_functions + 1)))) { ++ if(! (alloc_functions = apc_sma_malloc(sizeof(apc_function_t) * (ep->num_functions + 1) TSRMLS_CC))) { + goto failure; + } + for(i2=0; i2 < ep->num_functions; i2++) { -+ if(! (alloc_functions[i2].name = apc_xmemcpy(ep->val.file.functions[i2].name, ep->val.file.functions[i2].name_len+1, apc_sma_malloc))) { ++ if(! (alloc_functions[i2].name = apc_xmemcpy(ep->val.file.functions[i2].name, ep->val.file.functions[i2].name_len + 1, apc_sma_malloc TSRMLS_CC))) { + goto failure; + } + alloc_functions[i2].name_len = ep->val.file.functions[i2].name_len; -+ if(! (alloc_functions[i2].function = apc_sma_malloc(sizeof(zend_function)))) { ++ if(! (alloc_functions[i2].function = apc_sma_malloc(sizeof(zend_function) TSRMLS_CC))) { + goto failure; + } + switch(ep->val.file.functions[i2].function->type) { @@ -873,19 +913,19 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + alloc_functions[i2].name = NULL; + alloc_functions[i2].function = NULL; + -+ if(! (alloc_classes = apc_sma_malloc(sizeof(apc_class_t) * (ep->num_classes + 1)))) { ++ if(! (alloc_classes = apc_sma_malloc(sizeof(apc_class_t) * (ep->num_classes + 1) TSRMLS_CC))) { + goto failure; + } + for(i2=0; i2 < ep->num_classes; i2++) { -+ if(! (alloc_classes[i2].name = apc_xmemcpy(ep->val.file.classes[i2].name, ep->val.file.classes[i2].name_len+1, apc_sma_malloc))) { ++ if(! (alloc_classes[i2].name = apc_xmemcpy(ep->val.file.classes[i2].name, ep->val.file.classes[i2].name_len+1, apc_sma_malloc TSRMLS_CC))) { + goto failure; + } + alloc_classes[i2].name_len = ep->val.file.classes[i2].name_len; -+ if(! (alloc_classes[i2].class_entry = apc_copy_class_entry(NULL, ep->val.file.classes[i2].class_entry, &ctxt))) { ++ if(! (alloc_classes[i2].class_entry = apc_copy_class_entry(NULL, ep->val.file.classes[i2].class_entry, &ctxt TSRMLS_CC))) { + goto failure; + } + apc_bin_fixup_class_entry(alloc_classes[i2].class_entry); -+ if(! (alloc_classes[i2].parent_name = apc_xstrdup(ep->val.file.classes[i2].parent_name, apc_sma_malloc))) { ++ if(! (alloc_classes[i2].parent_name = apc_xstrdup(ep->val.file.classes[i2].parent_name, apc_sma_malloc TSRMLS_CC))) { + if(ep->val.file.classes[i2].parent_name != NULL) { + goto failure; + } @@ -894,7 +934,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + alloc_classes[i2].name = NULL; + alloc_classes[i2].class_entry = NULL; + -+ if(!(cache_entry = apc_cache_make_file_entry(ep->val.file.filename, alloc_op_array, alloc_functions, alloc_classes, &ctxt))) { ++ if(!(cache_entry = apc_cache_make_file_entry(ep->val.file.filename, alloc_op_array, alloc_functions, alloc_classes, &ctxt TSRMLS_CC))) { + goto failure; + } + @@ -902,7 +942,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + goto failure; + } + -+ if ((ret = apc_cache_insert(apc_cache, cache_key, cache_entry, &ctxt, t)) != 1) { ++ if ((ret = apc_cache_insert(apc_cache, cache_key, cache_entry, &ctxt, t TSRMLS_CC)) != 1) { + if(ret==-1) { + goto failure; + } @@ -910,7 +950,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + +#if NONBLOCKING_LOCK_AVAILABLE + if(APCG(write_lock)) { -+ apc_cache_write_unlock(apc_cache); ++ apc_cache_write_unlock(apc_cache TSRMLS_CC); + } +#endif + HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -928,11 +968,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + return 0; + +failure: -+ apc_pool_destroy(ctxt.pool); -+ apc_wprint("Unable to allocate memory for apc binary load/dump functionality."); ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); ++ apc_warning("Unable to allocate memory for apc binary load/dump functionality." TSRMLS_CC); +#if NONBLOCKING_LOCK_AVAILABLE + if(APCG(write_lock)) { -+ apc_cache_write_unlock(apc_cache); ++ apc_cache_write_unlock(apc_cache TSRMLS_CC); + } +#endif + HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -948,15 +988,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.c php-5.3.1/ext/apc/apc_bin.c + * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_bin.h php-5.3.1/ext/apc/apc_bin.h ---- php-5.3.1.orig/ext/apc/apc_bin.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_bin.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_bin.h @@ -0,0 +1,63 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2009 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -971,7 +1010,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.h php-5.3.1/ext/apc/apc_bin.h + + */ + -+/* $Id: apc_bin.h 274613 2009-01-26 06:57:57Z shire $ */ ++/* $Id: apc_bin.h 300979 2010-07-04 10:15:05Z kalle $ */ + +#ifndef APC_BINDUMP_H +#define APC_BINDUMP_H @@ -1015,15 +1054,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_bin.h php-5.3.1/ext/apc/apc_bin.h + * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c ---- php-5.3.1.orig/ext/apc/apc.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,635 @@ +--- /dev/null ++++ b/ext/apc/apc.c +@@ -0,0 +1,636 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -1050,10 +1088,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + + */ + -+/* $Id: apc.c 277132 2009-03-14 01:50:57Z shire $ */ ++/* $Id: apc.c 305003 2010-10-31 19:45:10Z gopalv $ */ + +#include "apc.h" +#include "apc_zend.h" ++#include "apc_cache.h" +#include "php.h" + +#if HAVE_PCRE || HAVE_BUNDLED_PCRE @@ -1070,33 +1109,33 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + +/* {{{ memory allocation wrappers */ + -+void* apc_emalloc(size_t n) ++void* apc_emalloc(size_t n TSRMLS_DC) +{ + void* p = malloc(n); + if (p == NULL) { -+ apc_eprint("apc_emalloc: malloc failed to allocate %u bytes:", n); ++ apc_error("apc_emalloc: malloc failed to allocate %u bytes:" TSRMLS_CC, n); + } + return p; +} + -+void* apc_erealloc(void* p, size_t n) ++void* apc_erealloc(void* p, size_t n TSRMLS_DC) +{ + p = realloc(p, n); + if (p == NULL) { -+ apc_eprint("apc_erealloc: realloc failed to allocate %u bytes:", n); ++ apc_error("apc_erealloc: realloc failed to allocate %u bytes:" TSRMLS_CC, n); + } + return p; +} + -+void apc_efree(void* p) ++void apc_efree(void* p TSRMLS_DC) +{ + if (p == NULL) { -+ apc_eprint("apc_efree: attempt to free null pointer"); ++ apc_error("apc_efree: attempt to free null pointer" TSRMLS_CC); + } + free(p); +} + -+char* apc_estrdup(const char* s) ++char* apc_estrdup(const char* s TSRMLS_DC) +{ + int len; + char* dup; @@ -1107,23 +1146,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + len = strlen(s); + dup = (char*) malloc(len+1); + if (dup == NULL) { -+ apc_eprint("apc_estrdup: malloc failed to allocate %u bytes:", len+1); ++ apc_error("apc_estrdup: malloc failed to allocate %u bytes:" TSRMLS_CC, len+1); + } + memcpy(dup, s, len); + dup[len] = '\0'; + return dup; +} + -+void* apc_xstrdup(const char* s, apc_malloc_t f) ++void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC) +{ -+ return s != NULL ? apc_xmemcpy(s, strlen(s)+1, f) : NULL; ++ return s != NULL ? apc_xmemcpy(s, strlen(s)+1, f TSRMLS_CC) : NULL; +} + -+void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f) ++void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC) +{ + void* q; + -+ if (p != NULL && (q = f(n)) != NULL) { ++ if (p != NULL && (q = f(n TSRMLS_CC)) != NULL) { + memcpy(q, p, n); + return q; + } @@ -1133,91 +1172,36 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c +/* }}} */ + +/* {{{ console display functions */ ++#ifdef ZTS ++# define APC_PRINT_FUNCTION_PARAMETER TSRMLS_C ++#else ++# define APC_PRINT_FUNCTION_PARAMETER format ++#endif + -+static void my_log(int level, const char* fmt, va_list args) -+{ -+ static const char* level_strings[] = { -+ "apc-debug", -+ "apc-notice", -+ "apc-warning", -+ "apc-error" -+ }; -+ static const int num_levels = NELEMS(level_strings); -+ -+ time_t now; -+ char* buf; /* for ctime */ -+ -+ TSRMLS_FETCH(); -+ -+ fflush(stdout); -+ -+ if (level < 0) -+ level = 0; -+ else if (level >= num_levels) -+ level = num_levels-1; -+ -+ now = time(0); -+ buf = ctime(&now); /* TODO: replace with reentrant impl */ -+ buf[24] = '\0'; -+ -+ fprintf(stderr, "[%s] [%s] ", buf, level_strings[level]); -+ vfprintf(stderr, fmt, args); -+ -+ if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':') { -+ fprintf(stderr, " %s", strerror(errno)); -+ } -+ -+ if (zend_is_compiling(TSRMLS_C)) { -+ fprintf(stderr, " in %s on line %d.", zend_get_compiled_filename(TSRMLS_C), zend_get_compiled_lineno(TSRMLS_C)); -+ } else if (zend_is_executing(TSRMLS_C)) { -+ fprintf(stderr, " in %s on line %d.", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C)); -+ } -+ fprintf(stderr, "\n"); -+ -+ if (level == APC_ERROR) { -+ exit(2); -+ } -+} -+ -+void apc_eprint(const char* fmt, ...) -+{ -+ va_list args; -+ va_start(args, fmt); -+ my_log(APC_ERROR, fmt, args); -+ va_end(args); -+} -+ -+void apc_wprint(const char* fmt, ...) -+{ -+ va_list args; -+ va_start(args, fmt); -+ my_log(APC_WARNING, fmt, args); -+ va_end(args); -+} ++#define APC_PRINT_FUNCTION(name, verbosity) \ ++ void apc_##name(const char *format TSRMLS_DC, ...) \ ++ { \ ++ va_list args; \ ++ \ ++ va_start(args, APC_PRINT_FUNCTION_PARAMETER); \ ++ php_verror(NULL, "", verbosity, format, args TSRMLS_CC); \ ++ va_end(args); \ ++ } + -+void apc_nprint(const char* fmt, ...) -+{ -+ va_list args; -+ va_start(args, fmt); -+ my_log(APC_NOTICE, fmt, args); -+ va_end(args); -+} ++APC_PRINT_FUNCTION(error, E_ERROR) ++APC_PRINT_FUNCTION(warning, E_WARNING) ++APC_PRINT_FUNCTION(notice, E_NOTICE) + -+void apc_dprint(const char* fmt, ...) -+{ -+#ifdef APC_DEBUG -+ va_list args; -+ va_start(args, fmt); -+ my_log(APC_DBG, fmt, args); -+ va_end(args); ++#ifdef __DEBUG_APC__ ++APC_PRINT_FUNCTION(debug, E_NOTICE) ++#else ++void apc_debug(const char *format TSRMLS_DC, ...) {} +#endif -+} -+ +/* }}} */ + +/* {{{ string and text manipulation */ + -+char* apc_append(const char* s, const char* t) ++char* apc_append(const char* s, const char* t TSRMLS_DC) +{ + int slen; + int tlen; @@ -1226,14 +1210,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + slen = strlen(s); + tlen = strlen(t); + -+ p = (char*) apc_emalloc((slen + tlen + 1) * sizeof(char)); ++ p = (char*) apc_emalloc((slen + tlen + 1) * sizeof(char) TSRMLS_CC); + memcpy(p, s, slen); + memcpy(p + slen, t, tlen + 1); + + return p; +} + -+char* apc_substr(const char* s, int start, int length) ++char* apc_substr(const char* s, int start, int length TSRMLS_DC) +{ + char* substr; + int src_len = strlen(s); @@ -1252,12 +1236,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + } + + /* create the substring */ -+ substr = apc_xmemcpy(s + start, length + 1, apc_emalloc); ++ substr = apc_xmemcpy(s + start, length + 1, apc_emalloc TSRMLS_CC); + substr[length] = '\0'; + return substr; +} + -+char** apc_tokenize(const char* s, char delim) ++char** apc_tokenize(const char* s, char delim TSRMLS_DC) +{ + char** tokens; /* array of tokens, NULL terminated */ + int size; /* size of tokens array */ @@ -1275,7 +1259,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + cur = 0; + end = strlen(s) - 1; + -+ tokens = (char**) apc_emalloc(size * sizeof(char*)); ++ tokens = (char**) apc_emalloc(size * sizeof(char*) TSRMLS_CC); + tokens[n] = NULL; + + while (cur <= end) { @@ -1286,11 +1270,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + /* resize token array if necessary */ + if (n == size-1) { + size *= 2; -+ tokens = (char**) apc_erealloc(tokens, size * sizeof(char*)); ++ tokens = (char**) apc_erealloc(tokens, size * sizeof(char*) TSRMLS_CC); + } + + /* save the current token */ -+ tokens[n] = apc_substr(s, cur, next-cur); ++ tokens[n] = apc_substr(s, cur, next-cur TSRMLS_CC); + + tokens[++n] = NULL; + cur = next + 1; @@ -1301,13 +1285,64 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + +/* }}} */ + -+/* {{{ apc stat */ ++ ++/* {{{ apc_win32_restat */ ++#ifdef PHP_WIN32 ++static int apc_restat(apc_fileinfo_t *fileinfo TSRMLS_DC) ++{ ++ HANDLE hFile; ++ BY_HANDLE_FILE_INFORMATION hInfo; ++ ++ hFile = CreateFile(fileinfo->fullpath, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL); ++ ++ if (!hFile) { ++ apc_debug("Cannot create a file HANDLE for %s\n" TSRMLS_CC, fileinfo->fullpath); ++ return -1; ++ } ++ ++ if (!GetFileInformationByHandle(hFile, &hInfo)) { ++ apc_debug("Cannot get file information from handle\n" TSRMLS_CC); ++ CloseHandle(hFile); ++ return -1; ++ } ++ ++ CloseHandle(hFile); ++ ++ fileinfo->st_buf.sb.st_dev = hInfo.dwVolumeSerialNumber; ++ fileinfo->st_buf.sb.st_ino = (((apc_ino_t)(hInfo.nFileIndexHigh) << 32) | (apc_ino_t) hInfo.nFileIndexLow); ++ ++ return 0; ++} ++#else ++static int apc_restat(apc_fileinfo_t *fileinfo TSRMLS_DC) ++{ ++ return 0; ++} ++#endif ++/* }}} */ ++ ++/* {{{ apc_search_paths */ +/* similar to php_stream_stat_path */ +#define APC_URL_STAT(wrapper, filename, pstatbuf) \ + ((wrapper)->wops->url_stat((wrapper), (filename), PHP_STREAM_URL_STAT_QUIET, (pstatbuf), NULL TSRMLS_CC)) -+int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo) ++ ++/* copy out to path_buf if path_for_open isn't the same as filename */ ++#define COPY_IF_CHANGED(p) \ ++ (char*) (((p) == filename) ? filename : \ ++ (strlcpy((char*)fileinfo->path_buf, (p), sizeof(fileinfo->path_buf))) \ ++ ? (fileinfo->path_buf) : NULL) ++ ++/* len checks can be skipped here because filename is NUL terminated */ ++#define IS_RELATIVE_PATH(filename, len) \ ++ ((filename) && (filename[0] == '.' && \ ++ (IS_SLASH(filename[1]) || \ ++ (filename[1] == '.' && \ ++ IS_SLASH(filename[2]))))) ++ ++ ++int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC) +{ -+ char** paths; ++ char** paths = NULL; + char *exec_fname; + int exec_fname_length; + int found = 0; @@ -1315,8 +1350,6 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + php_stream_wrapper *wrapper = NULL; + char *path_for_open = NULL; + -+ TSRMLS_FETCH(); -+ + assert(filename && fileinfo); + + @@ -1328,28 +1361,31 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + + if(wrapper != &php_plain_files_wrapper) { + if(APC_URL_STAT(wrapper, path_for_open, &fileinfo->st_buf) == 0) { -+ strncpy(fileinfo->fullpath, path_for_open, MAXPATHLEN); -+ return 0; ++ fileinfo->fullpath = COPY_IF_CHANGED(path_for_open); ++ return apc_restat(fileinfo TSRMLS_CC); + } + return -1; /* cannot stat */ + } + + if (IS_ABSOLUTE_PATH(path_for_open, strlen(path_for_open)) && + APC_URL_STAT(wrapper, path_for_open, &fileinfo->st_buf) == 0) { -+ strncpy(fileinfo->fullpath, path_for_open, MAXPATHLEN); -+ return 0; ++ fileinfo->fullpath = COPY_IF_CHANGED(path_for_open); ++ return apc_restat(fileinfo TSRMLS_CC); + } + -+ paths = apc_tokenize(path, DEFAULT_DIR_SEPARATOR); -+ if (!paths) -+ return -1; ++ if (!IS_RELATIVE_PATH(path_for_open, strlen(path_for_open))) { ++ paths = apc_tokenize(path, DEFAULT_DIR_SEPARATOR TSRMLS_CC); ++ if (!paths) ++ return -1; + -+ /* for each directory in paths, look for filename inside */ -+ for (i = 0; paths[i]; i++) { -+ snprintf(fileinfo->fullpath, sizeof(fileinfo->fullpath), "%s%c%s", paths[i], DEFAULT_SLASH, path_for_open); -+ if (APC_URL_STAT(wrapper, fileinfo->fullpath, &fileinfo->st_buf) == 0) { -+ found = 1; -+ break; ++ /* for each directory in paths, look for filename inside */ ++ for (i = 0; paths[i]; i++) { ++ snprintf(fileinfo->path_buf, sizeof(fileinfo->path_buf), "%s%c%s", paths[i], DEFAULT_SLASH, path_for_open); ++ if (APC_URL_STAT(wrapper, fileinfo->path_buf, &fileinfo->st_buf) == 0) { ++ fileinfo->fullpath = (char*) fileinfo->path_buf; ++ found = 1; ++ break; ++ } + } + } + @@ -1361,23 +1397,26 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + while((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length])); + if((exec_fname && exec_fname[0] != '[') && exec_fname_length > 0) { + /* not: [no active file] or no path */ -+ memcpy(fileinfo->fullpath, exec_fname, exec_fname_length); -+ fileinfo->fullpath[exec_fname_length] = DEFAULT_SLASH; -+ strlcpy(fileinfo->fullpath +exec_fname_length +1, path_for_open,sizeof(fileinfo->fullpath)-exec_fname_length-1); -+ /* apc_wprint("filename: %s, exec_fname: %s, fileinfo->fullpath: %s", path_for_open, exec_fname, fileinfo->fullpath); */ -+ if (APC_URL_STAT(wrapper, fileinfo->fullpath, &fileinfo->st_buf) == 0) { ++ memcpy(fileinfo->path_buf, exec_fname, exec_fname_length); ++ fileinfo->path_buf[exec_fname_length] = DEFAULT_SLASH; ++ strlcpy(fileinfo->path_buf +exec_fname_length +1, path_for_open,sizeof(fileinfo->path_buf)-exec_fname_length-1); ++ /* apc_warning("filename: %s, exec_fname: %s, fileinfo->path_buf: %s" TSRMLS_CC, path_for_open, exec_fname, fileinfo->path_buf); */ ++ if (APC_URL_STAT(wrapper, fileinfo->path_buf, &fileinfo->st_buf) == 0) { ++ fileinfo->fullpath = (char*) fileinfo->path_buf; + found = 1; + } + } + } + -+ /* free the value returned by apc_tokenize */ -+ for (i = 0; paths[i]; i++) { -+ apc_efree(paths[i]); ++ if(paths) { ++ /* free the value returned by apc_tokenize */ ++ for (i = 0; paths[i]; i++) { ++ apc_efree(paths[i] TSRMLS_CC); ++ } ++ apc_efree(paths TSRMLS_CC); + } -+ apc_efree(paths); + -+ return found ? 0 : -1; ++ return found ? apc_restat(fileinfo TSRMLS_CC) : -1; +} + +/* }}} */ @@ -1406,7 +1445,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c +#define APC_COMPILE_PATTERN(re, match) do {\ + if(match.len > 2) { /* more than just "//" */\ + if (((re) = pcre_get_compiled_regex(match.c, NULL, NULL TSRMLS_CC)) == NULL) {\ -+ apc_wprint("apc_regex_compile_array: invalid expression '%s'", match.c); \ ++ apc_warning("apc_regex_compile_array: invalid expression '%s'" TSRMLS_CC, match.c); \ + smart_str_free(&match);\ + return NULL;\ + }\ @@ -1426,7 +1465,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + if (!patterns) + return NULL; + -+ regs = (apc_regex*) apc_emalloc(sizeof(apc_regex)); ++ regs = (apc_regex*) apc_emalloc(sizeof(apc_regex) TSRMLS_CC); + + smart_str_appendc(&pmatch, '/'); + smart_str_appendc(&nmatch, '/'); @@ -1456,11 +1495,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + return (void*) regs; +} + -+void apc_regex_destroy_array(void* p) ++void apc_regex_destroy_array(void* p TSRMLS_DC) +{ + if (p != NULL) { + apc_regex* regs = (apc_regex*) p; -+ apc_efree(regs); ++ apc_efree(regs TSRMLS_CC); + } +} + @@ -1489,7 +1528,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c +void* apc_regex_compile_array(char* patterns[] TSRMLS_DC) +{ + if(patterns && patterns[0] != NULL) { -+ apc_wprint("pcre missing, disabling filters"); ++ apc_warning("pcre missing, disabling filters" TSRMLS_CC); + } + return NULL; +} @@ -1639,7 +1678,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + Z_ADDREF_P(data); + zend_hash_move_forward_ex(hash, &pos); + } -+ efree(data); ++ zval_ptr_dtor(&data); + + return new_hash; +} @@ -1654,15 +1693,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.c php-5.3.1/ext/apc/apc.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c ---- php-5.3.1.orig/ext/apc/apc_cache.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_cache.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,1183 @@ +--- /dev/null ++++ b/ext/apc/apc_cache.c +@@ -0,0 +1,1295 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -1688,11 +1726,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + + */ + -+/* $Id: apc_cache.c 286717 2009-08-03 05:25:32Z gopalv $ */ ++/* $Id: apc_cache.c 305771 2010-11-26 12:57:16Z gopalv $ */ + +#include "apc_cache.h" ++#include "apc_zend.h" +#include "apc_sma.h" -+#include "apc_main.h" +#include "apc_globals.h" +#include "SAPI.h" + @@ -1704,12 +1742,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +#define key_equals(a, b) (a.inode==b.inode && a.device==b.device) +/* }}} */ + -+static void apc_cache_expunge(apc_cache_t* cache, size_t size); ++static void apc_cache_expunge(apc_cache_t* cache, size_t size TSRMLS_DC); + +/* {{{ hash */ +static unsigned int hash(apc_cache_key_t key) +{ -+ return key.data.file.device + key.data.file.inode; ++ return (unsigned int)(key.data.file.device + key.data.file.inode); +} +/* }}} */ + @@ -1717,21 +1755,60 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +#define string_nhash_8(s,len) (unsigned int)(zend_inline_hash_func(s, len)) +/* }}} */ + ++/* {{{ make_prime */ ++static int const primes[] = { ++ 257, /* 256 */ ++ 521, /* 512 */ ++ 1031, /* 1024 */ ++ 2053, /* 2048 */ ++ 3079, /* 3072 */ ++ 4099, /* 4096 */ ++ 5147, /* 5120 */ ++ 6151, /* 6144 */ ++ 7177, /* 7168 */ ++ 8209, /* 8192 */ ++ 9221, /* 9216 */ ++10243, /* 10240 */ ++#if 0 ++11273, /* 11264 */ ++12289, /* 12288 */ ++13313, /* 13312 */ ++14341, /* 14336 */ ++15361, /* 15360 */ ++16411, /* 16384 */ ++17417, /* 17408 */ ++18433, /* 18432 */ ++19457, /* 19456 */ ++#endif ++0 /* sentinel */ ++}; ++ ++static int make_prime(int n) ++{ ++ int *k = (int*)primes; ++ while(*k) { ++ if((*k) > n) return *k; ++ k++; ++ } ++ return *(k-1); ++} ++/* }}} */ ++ +/* {{{ make_slot */ -+slot_t* make_slot(apc_cache_key_t key, apc_cache_entry_t* value, slot_t* next, time_t t) ++slot_t* make_slot(apc_cache_key_t key, apc_cache_entry_t* value, slot_t* next, time_t t TSRMLS_DC) +{ + slot_t* p = apc_pool_alloc(value->pool, sizeof(slot_t)); + + if (!p) return NULL; + + if(value->type == APC_CACHE_ENTRY_USER) { -+ char *identifier = (char*) apc_pstrdup(key.data.user.identifier, value->pool); ++ char *identifier = (char*) apc_pmemcpy(key.data.user.identifier, key.data.user.identifier_len, value->pool TSRMLS_CC); + if (!identifier) { + return NULL; + } + key.data.user.identifier = identifier; + } else if(key.type == APC_CACHE_KEY_FPFILE) { -+ char *fullpath = (char*) apc_pstrdup(key.data.fpfile.fullpath, value->pool); ++ char *fullpath = (char*) apc_pstrdup(key.data.fpfile.fullpath, value->pool TSRMLS_CC); + if (!fullpath) { + return NULL; + } @@ -1749,14 +1826,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ free_slot */ -+static void free_slot(slot_t* slot) ++static void free_slot(slot_t* slot TSRMLS_DC) +{ -+ apc_pool_destroy(slot->value->pool); ++ apc_pool_destroy(slot->value->pool TSRMLS_CC); +} +/* }}} */ + +/* {{{ remove_slot */ -+static void remove_slot(apc_cache_t* cache, slot_t** slot) ++static void remove_slot(apc_cache_t* cache, slot_t** slot TSRMLS_DC) +{ + slot_t* dead = *slot; + *slot = (*slot)->next; @@ -1764,7 +1841,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + cache->header->mem_size -= dead->value->mem_size; + cache->header->num_entries--; + if (dead->value->ref_count <= 0) { -+ free_slot(dead); ++ free_slot(dead TSRMLS_CC); + } + else { + dead->next = cache->header->deleted_list; @@ -1775,7 +1852,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ process_pending_removals */ -+static void process_pending_removals(apc_cache_t* cache) ++static void process_pending_removals(apc_cache_t* cache TSRMLS_DC) +{ + slot_t** slot; + time_t now; @@ -1801,16 +1878,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if (dead->value->ref_count > 0) { + switch(dead->value->type) { + case APC_CACHE_ENTRY_FILE: -+ apc_wprint("GC cache entry '%s' (dev=%d ino=%d) was on gc-list for %d seconds", ++ apc_warning("GC cache entry '%s' (dev=%d ino=%d) was on gc-list for %d seconds" TSRMLS_CC, + dead->value->data.file.filename, dead->key.data.file.device, dead->key.data.file.inode, gc_sec); + break; + case APC_CACHE_ENTRY_USER: -+ apc_wprint("GC cache entry '%s'was on gc-list for %d seconds", dead->value->data.user.info, gc_sec); ++ apc_warning("GC cache entry '%s'was on gc-list for %d seconds" TSRMLS_CC, dead->value->data.user.info, gc_sec); + break; + } + } + *slot = dead->next; -+ free_slot(dead); ++ free_slot(dead TSRMLS_CC); + } + else { + slot = &(*slot)->next; @@ -1848,21 +1925,20 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_create */ -+apc_cache_t* apc_cache_create(int size_hint, int gc_ttl, int ttl) ++apc_cache_t* apc_cache_create(int size_hint, int gc_ttl, int ttl TSRMLS_DC) +{ + apc_cache_t* cache; + int cache_size; + int num_slots; -+ int i; + -+ num_slots = size_hint > 0 ? size_hint*2 : 2000; ++ num_slots = make_prime(size_hint > 0 ? size_hint : 2000); + -+ cache = (apc_cache_t*) apc_emalloc(sizeof(apc_cache_t)); ++ cache = (apc_cache_t*) apc_emalloc(sizeof(apc_cache_t) TSRMLS_CC); + cache_size = sizeof(cache_header_t) + num_slots*sizeof(slot_t*); + -+ cache->shmaddr = apc_sma_malloc(cache_size); ++ cache->shmaddr = apc_sma_malloc(cache_size TSRMLS_CC); + if(!cache->shmaddr) { -+ apc_eprint("Unable to allocate shared memory for cache structures. (Perhaps your shared memory size isn't large enough?). "); ++ apc_error("Unable to allocate shared memory for cache structures. (Perhaps your shared memory size isn't large enough?). " TSRMLS_CC); + } + memset(cache->shmaddr, 0, cache_size); + @@ -1882,9 +1958,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +#if NONBLOCKING_LOCK_AVAILABLE + CREATE_LOCK(cache->header->wrlock); +#endif -+ for (i = 0; i < num_slots; i++) { -+ cache->slots[i] = NULL; -+ } ++ memset(cache->slots, 0, sizeof(slot_t*)*num_slots); + cache->expunge_cb = apc_cache_expunge; + cache->has_lock = 0; + @@ -1893,18 +1967,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_destroy */ -+void apc_cache_destroy(apc_cache_t* cache) ++void apc_cache_destroy(apc_cache_t* cache TSRMLS_DC) +{ + DESTROY_LOCK(cache->header->lock); +#ifdef NONBLOCKING_LOCK_AVAILABLE + DESTROY_LOCK(cache->header->wrlock); +#endif -+ apc_efree(cache); ++ apc_efree(cache TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_cache_clear */ -+void apc_cache_clear(apc_cache_t* cache) ++void apc_cache_clear(apc_cache_t* cache TSRMLS_DC) +{ + int i; + @@ -1920,7 +1994,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + for (i = 0; i < cache->num_slots; i++) { + slot_t* p = cache->slots[i]; + while (p) { -+ remove_slot(cache, &p); ++ remove_slot(cache, &p TSRMLS_CC); + } + cache->slots[i] = NULL; + } @@ -1933,11 +2007,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_expunge */ -+static void apc_cache_expunge(apc_cache_t* cache, size_t size) ++static void apc_cache_expunge(apc_cache_t* cache, size_t size TSRMLS_DC) +{ + int i; + time_t t; -+ TSRMLS_FETCH(); + + t = apc_time(); + @@ -1949,20 +2022,26 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + * we run out of space. + */ + CACHE_SAFE_LOCK(cache); ++ if (apc_sma_get_avail_mem() > (size_t)(APCG(shm_size)/2)) { ++ /* probably a queued up expunge, we don't need to do this */ ++ CACHE_SAFE_UNLOCK(cache); ++ return; ++ } + cache->header->busy = 1; + cache->header->expunges++; ++clear_all: + for (i = 0; i < cache->num_slots; i++) { + slot_t* p = cache->slots[i]; + while (p) { -+ remove_slot(cache, &p); ++ remove_slot(cache, &p TSRMLS_CC); + } + cache->slots[i] = NULL; + } ++ memset(&cache->header->lastkey, 0, sizeof(apc_keyid_t)); + cache->header->busy = 0; + CACHE_SAFE_UNLOCK(cache); + } else { + slot_t **p; -+ + /* + * If the ttl for the cache is set we walk through and delete stale + * entries. For the user cache that is slightly confusing since @@ -1973,6 +2052,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + */ + + CACHE_SAFE_LOCK(cache); ++ if (apc_sma_get_avail_mem() > (size_t)(APCG(shm_size)/2)) { ++ /* probably a queued up expunge, we don't need to do this */ ++ CACHE_SAFE_UNLOCK(cache); ++ return; ++ } + cache->header->busy = 1; + cache->header->expunges++; + for (i = 0; i < cache->num_slots; i++) { @@ -1985,22 +2069,28 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if((*p)->value->type == APC_CACHE_ENTRY_USER) { + if((*p)->value->data.user.ttl) { + if((time_t) ((*p)->creation_time + (*p)->value->data.user.ttl) < t) { -+ remove_slot(cache, p); ++ remove_slot(cache, p TSRMLS_CC); + continue; + } + } else if(cache->ttl) { + if((*p)->creation_time + cache->ttl < t) { -+ remove_slot(cache, p); ++ remove_slot(cache, p TSRMLS_CC); + continue; + } + } + } else if((*p)->access_time < (t - cache->ttl)) { -+ remove_slot(cache, p); ++ remove_slot(cache, p TSRMLS_CC); + continue; + } + p = &(*p)->next; + } + } ++ ++ if (!apc_sma_get_avail_size(size)) { ++ /* TODO: re-do this to remove goto across locked sections */ ++ goto clear_all; ++ } ++ memset(&cache->header->lastkey, 0, sizeof(apc_keyid_t)); + cache->header->busy = 0; + CACHE_SAFE_UNLOCK(cache); + } @@ -2012,7 +2102,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + apc_cache_key_t key, + apc_cache_entry_t* value, + apc_context_t* ctxt, -+ time_t t) ++ time_t t ++ TSRMLS_DC) +{ + slot_t** slot; + @@ -2020,11 +2111,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + return 0; + } + -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"Inserting [%s]\n", value->data.file.filename); -+#endif ++ apc_debug("Inserting [%s]\n" TSRMLS_CC, value->data.file.filename); + -+ process_pending_removals(cache); ++ process_pending_removals(cache TSRMLS_CC); + + if(key.type == APC_CACHE_KEY_FILE) slot = &cache->slots[hash(key) % cache->num_slots]; + else slot = &cache->slots[string_nhash_8(key.data.fpfile.fullpath, key.data.fpfile.fullpath_len) % cache->num_slots]; @@ -2035,21 +2124,21 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if(key_equals((*slot)->key.data.file, key.data.file)) { + /* If existing slot for the same device+inode is different, remove it and insert the new version */ + if (ctxt->force_update || (*slot)->key.mtime != key.mtime) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + break; + } + return 0; + } else if(cache->ttl && (*slot)->access_time < (t - cache->ttl)) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + continue; + } + } else { /* APC_CACHE_KEY_FPFILE */ + if(!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { + /* Hrm.. it's already here, remove it and insert new one */ -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + break; + } else if(cache->ttl && (*slot)->access_time < (t - cache->ttl)) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + continue; + } + } @@ -2057,7 +2146,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + slot = &(*slot)->next; + } + -+ if ((*slot = make_slot(key, value, *slot, t)) == NULL) { ++ if ((*slot = make_slot(key, value, *slot, t TSRMLS_CC)) == NULL) { + return -1; + } + @@ -2071,18 +2160,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_insert */ -+int apc_cache_insert(apc_cache_t* cache, apc_cache_key_t key, apc_cache_entry_t* value, apc_context_t *ctxt, time_t t) ++int apc_cache_insert(apc_cache_t* cache, apc_cache_key_t key, apc_cache_entry_t* value, apc_context_t *ctxt, time_t t TSRMLS_DC) +{ + int rval; + CACHE_LOCK(cache); -+ rval = _apc_cache_insert(cache, key, value, ctxt, t); ++ rval = _apc_cache_insert(cache, key, value, ctxt, t TSRMLS_CC); + CACHE_UNLOCK(cache); + return rval; +} +/* }}} */ + +/* {{{ apc_cache_insert */ -+int *apc_cache_insert_mult(apc_cache_t* cache, apc_cache_key_t* keys, apc_cache_entry_t** values, apc_context_t *ctxt, time_t t, int num_entries) ++int *apc_cache_insert_mult(apc_cache_t* cache, apc_cache_key_t* keys, apc_cache_entry_t** values, apc_context_t *ctxt, time_t t, int num_entries TSRMLS_DC) +{ + int *rval; + int i; @@ -2092,7 +2181,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + for (i=0; i < num_entries; i++) { + if (values[i]) { + ctxt->pool = values[i]->pool; -+ rval[i] = _apc_cache_insert(cache, keys[i], values[i], ctxt, t); ++ rval[i] = _apc_cache_insert(cache, keys[i], values[i], ctxt, t TSRMLS_CC); + } + } + CACHE_UNLOCK(cache); @@ -2105,7 +2194,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +int apc_cache_user_insert(apc_cache_t* cache, apc_cache_key_t key, apc_cache_entry_t* value, apc_context_t* ctxt, time_t t, int exclusive TSRMLS_DC) +{ + slot_t** slot; -+ unsigned int keylen = key.data.user.identifier_len+1; ++ unsigned int keylen = key.data.user.identifier_len; + unsigned int h = string_nhash_8(key.data.user.identifier, keylen); + apc_keyid_t *lastkey = &cache->header->lastkey; + @@ -2118,8 +2207,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + return 0; + } + -+ if(apc_cache_is_last_key(cache, &key, t)) { ++ if(apc_cache_is_last_key(cache, &key, h, t TSRMLS_CC)) { + /* potential cache slam */ ++ printf("Last key warning for it!"); + return 0; + } + @@ -2130,17 +2220,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + lastkey->h = h; + lastkey->keylen = keylen; + lastkey->mtime = t; ++#ifdef ZTS ++ lastkey->tid = tsrm_thread_id(); ++#else ++ lastkey->pid = getpid(); ++#endif + + /* we do not reset lastkey after the insert. Whether it is inserted + * or not, another insert in the same second is always a bad idea. + */ + -+ process_pending_removals(cache); ++ process_pending_removals(cache TSRMLS_CC); + + slot = &cache->slots[h % cache->num_slots]; + + while (*slot) { -+ if (!memcmp((*slot)->key.data.user.identifier, key.data.user.identifier, keylen)) { ++ if (((*slot)->key.data.user.identifier_len == key.data.user.identifier_len) && ++ (!memcmp((*slot)->key.data.user.identifier, key.data.user.identifier, keylen))) { + /* + * At this point we have found the user cache entry. If we are doing + * an exclusive insert (apc_add) we are going to bail right away if @@ -2152,7 +2248,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + ) ) { + goto fail; + } -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + break; + } else + /* @@ -2164,13 +2260,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + */ + if((cache->ttl && (*slot)->access_time < (t - cache->ttl)) || + ((*slot)->value->data.user.ttl && (time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t)) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + continue; + } + slot = &(*slot)->next; + } + -+ if ((*slot = make_slot(key, value, *slot, t)) == NULL) { ++ if ((*slot = make_slot(key, value, *slot, t TSRMLS_CC)) == NULL) { + goto fail; + } + @@ -2192,7 +2288,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_find_slot */ -+slot_t* apc_cache_find_slot(apc_cache_t* cache, apc_cache_key_t key, time_t t) ++slot_t* apc_cache_find_slot(apc_cache_t* cache, apc_cache_key_t key, time_t t TSRMLS_DC) +{ + slot_t** slot; + volatile slot_t* retval = NULL; @@ -2206,7 +2302,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if(key.type == APC_CACHE_KEY_FILE) { + if(key_equals((*slot)->key.data.file, key.data.file)) { + if((*slot)->key.mtime != key.mtime) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + cache->header->num_misses++; + CACHE_UNLOCK(cache); + return NULL; @@ -2243,15 +2339,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_find */ -+apc_cache_entry_t* apc_cache_find(apc_cache_t* cache, apc_cache_key_t key, time_t t) ++apc_cache_entry_t* apc_cache_find(apc_cache_t* cache, apc_cache_key_t key, time_t t TSRMLS_DC) +{ -+ slot_t * slot = apc_cache_find_slot(cache, key, t); ++ slot_t * slot = apc_cache_find_slot(cache, key, t TSRMLS_CC); + return (slot) ? slot->value : NULL; +} +/* }}} */ + +/* {{{ apc_cache_user_find */ -+apc_cache_entry_t* apc_cache_user_find(apc_cache_t* cache, char *strkey, int keylen, time_t t) ++apc_cache_entry_t* apc_cache_user_find(apc_cache_t* cache, char *strkey, int keylen, time_t t TSRMLS_DC) +{ + slot_t** slot; + volatile apc_cache_entry_t* value = NULL; @@ -2270,7 +2366,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { + /* Check to make sure this entry isn't expired by a hard TTL */ + if((*slot)->value->data.user.ttl && (time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + cache->header->num_misses++; + CACHE_UNLOCK(cache); + return NULL; @@ -2294,6 +2390,41 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +} +/* }}} */ + ++/* {{{ apc_cache_user_exists */ ++apc_cache_entry_t* apc_cache_user_exists(apc_cache_t* cache, char *strkey, int keylen, time_t t TSRMLS_DC) ++{ ++ slot_t** slot; ++ volatile apc_cache_entry_t* value = NULL; ++ ++ if(apc_cache_busy(cache)) ++ { ++ /* cache cleanup in progress */ ++ return NULL; ++ } ++ ++ CACHE_LOCK(cache); ++ ++ slot = &cache->slots[string_nhash_8(strkey, keylen) % cache->num_slots]; ++ ++ while (*slot) { ++ if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { ++ /* Check to make sure this entry isn't expired by a hard TTL */ ++ if((*slot)->value->data.user.ttl && (time_t) ((*slot)->creation_time + (*slot)->value->data.user.ttl) < t) { ++ CACHE_UNLOCK(cache); ++ return NULL; ++ } ++ /* Return the cache entry ptr */ ++ value = (*slot)->value; ++ CACHE_UNLOCK(cache); ++ return (apc_cache_entry_t*)value; ++ } ++ slot = &(*slot)->next; ++ } ++ CACHE_UNLOCK(cache); ++ return NULL; ++} ++/* }}} */ ++ +/* {{{ apc_cache_user_update */ +int _apc_cache_user_update(apc_cache_t* cache, char *strkey, int keylen, apc_cache_updater_t updater, void* data TSRMLS_DC) +{ @@ -2325,7 +2456,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_user_delete */ -+int apc_cache_user_delete(apc_cache_t* cache, char *strkey, int keylen) ++int apc_cache_user_delete(apc_cache_t* cache, char *strkey, int keylen TSRMLS_DC) +{ + slot_t** slot; + @@ -2335,7 +2466,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + + while (*slot) { + if (!memcmp((*slot)->key.data.user.identifier, strkey, keylen)) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + CACHE_UNLOCK(cache); + return 1; + } @@ -2348,19 +2479,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_delete */ -+int apc_cache_delete(apc_cache_t* cache, char *filename, int filename_len) ++int apc_cache_delete(apc_cache_t* cache, char *filename, int filename_len TSRMLS_DC) +{ + slot_t** slot; + time_t t; + apc_cache_key_t key; + -+ TSRMLS_FETCH(); -+ + t = apc_time(); + + /* try to create a cache key; if we fail, give up on caching */ + if (!apc_cache_make_file_key(&key, filename, PG(include_path), t TSRMLS_CC)) { -+ apc_wprint("Could not stat file %s, unable to delete from cache.", filename); ++ apc_warning("Could not stat file %s, unable to delete from cache." TSRMLS_CC, filename); + return -1; + } + @@ -2373,13 +2502,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if(key.type == (*slot)->key.type) { + if(key.type == APC_CACHE_KEY_FILE) { + if(key_equals((*slot)->key.data.file, key.data.file)) { -+ remove_slot(cache, slot); ++ remove_slot(cache, slot TSRMLS_CC); + CACHE_UNLOCK(cache); + return 1; + } + } else { /* APC_CACHE_KEY_FPFILE */ -+ if(!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1)) { -+ remove_slot(cache, slot); ++ if(((*slot)->key.data.fpfile.fullpath_len == key.data.fpfile.fullpath_len) && ++ (!memcmp((*slot)->key.data.fpfile.fullpath, key.data.fpfile.fullpath, key.data.fpfile.fullpath_len+1))) { ++ remove_slot(cache, slot TSRMLS_CC); + CACHE_UNLOCK(cache); + return 1; + } @@ -2387,7 +2517,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + } + slot = &(*slot)->next; + } -+ ++ ++ memset(&cache->header->lastkey, 0, sizeof(apc_keyid_t)); ++ + CACHE_UNLOCK(cache); + return 0; + @@ -2395,7 +2527,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_release */ -+void apc_cache_release(apc_cache_t* cache, apc_cache_entry_t* entry) ++void apc_cache_release(apc_cache_t* cache, apc_cache_entry_t* entry TSRMLS_DC) +{ + CACHE_LOCK(cache); + entry->ref_count--; @@ -2411,16 +2543,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + TSRMLS_DC) +{ + struct stat *tmp_buf=NULL; -+ struct apc_fileinfo_t fileinfo = { {0}, }; ++ struct apc_fileinfo_t *fileinfo = NULL; + int len; + + assert(key != NULL); + + if (!filename || !SG(request_info).path_translated) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"No filename and no path_translated - bailing\n"); -+#endif -+ return 0; ++ apc_debug("No filename and no path_translated - bailing\n" TSRMLS_CC); ++ goto cleanup; + } + + len = strlen(filename); @@ -2430,46 +2560,50 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + key->data.fpfile.fullpath_len = len; + key->mtime = t; + key->type = APC_CACHE_KEY_FPFILE; -+ return 1; ++ goto success; + } else if(APCG(canonicalize)) { -+ if (apc_search_paths(filename, include_path, &fileinfo) != 0) { -+ apc_wprint("apc failed to locate %s - bailing", filename); -+ return 0; ++ ++ fileinfo = apc_php_malloc(sizeof(apc_fileinfo_t) TSRMLS_CC); ++ ++ if (apc_search_paths(filename, include_path, fileinfo TSRMLS_CC) != 0) { ++ apc_warning("apc failed to locate %s - bailing" TSRMLS_CC, filename); ++ goto cleanup; + } + -+ if(!realpath(fileinfo.fullpath, APCG(canon_path))) { -+ apc_wprint("realpath failed to canonicalize %s - bailing", filename); -+ return 0; ++ if(!VCWD_REALPATH(fileinfo->fullpath, APCG(canon_path))) { ++ apc_warning("realpath failed to canonicalize %s - bailing" TSRMLS_CC, filename); ++ goto cleanup; + } + + key->data.fpfile.fullpath = APCG(canon_path); + key->data.fpfile.fullpath_len = strlen(APCG(canon_path)); + key->mtime = t; + key->type = APC_CACHE_KEY_FPFILE; -+ return 1; ++ goto success; + } + /* fall through to stat mode */ + } + ++ fileinfo = apc_php_malloc(sizeof(apc_fileinfo_t) TSRMLS_CC); ++ ++ assert(fileinfo != NULL); ++ + if(!strcmp(SG(request_info).path_translated, filename)) { + tmp_buf = sapi_get_stat(TSRMLS_C); /* Apache has already done this stat() for us */ + } ++ + if(tmp_buf) { -+ fileinfo.st_buf.sb = *tmp_buf; ++ fileinfo->st_buf.sb = *tmp_buf; + } else { -+ if (apc_search_paths(filename, include_path, &fileinfo) != 0) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"Stat failed %s - bailing (%s) (%d)\n",filename,SG(request_info).path_translated); -+#endif -+ return 0; ++ if (apc_search_paths(filename, include_path, fileinfo TSRMLS_CC) != 0) { ++ apc_debug("Stat failed %s - bailing (%s) (%d)\n" TSRMLS_CC, filename,SG(request_info).path_translated); ++ goto cleanup; + } + } + -+ if(APCG(max_file_size) < fileinfo.st_buf.sb.st_size) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"File is too big %s (%d - %ld) - bailing\n",filename,t,fileinfo.st_buf.sb.st_size); -+#endif -+ return 0; ++ if(APCG(max_file_size) < fileinfo->st_buf.sb.st_size) { ++ apc_debug("File is too big %s (%d - %ld) - bailing\n" TSRMLS_CC, filename,t,fileinfo->st_buf.sb.st_size); ++ goto cleanup; + } + + /* @@ -2484,15 +2618,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + * tiny safety is easier than educating the world. This is now + * configurable, but the default is still 2 seconds. + */ -+ if(APCG(file_update_protection) && (t - fileinfo.st_buf.sb.st_mtime < APCG(file_update_protection)) && !APCG(force_file_update)) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"File is too new %s (%d - %d) - bailing\n",filename,t,fileinfo.st_buf.sb.st_mtime); -+#endif -+ return 0; ++ if(APCG(file_update_protection) && (t - fileinfo->st_buf.sb.st_mtime < APCG(file_update_protection)) && !APCG(force_file_update)) { ++ apc_debug("File is too new %s (%d - %d) - bailing\n" TSRMLS_CC,filename,t,fileinfo->st_buf.sb.st_mtime); ++ goto cleanup; + } + -+ key->data.file.device = fileinfo.st_buf.sb.st_dev; -+ key->data.file.inode = fileinfo.st_buf.sb.st_ino; ++ key->data.file.device = fileinfo->st_buf.sb.st_dev; ++ key->data.file.inode = fileinfo->st_buf.sb.st_ino; ++ + /* + * If working with content management systems that like to munge the mtime, + * it might be appropriate to key off of the ctime to be immune to systems @@ -2505,12 +2638,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + * set the apc.stat_ctime=true to enable this check. + */ + if(APCG(stat_ctime)) { -+ key->mtime = (fileinfo.st_buf.sb.st_ctime > fileinfo.st_buf.sb.st_mtime) ? fileinfo.st_buf.sb.st_ctime : fileinfo.st_buf.sb.st_mtime; ++ key->mtime = (fileinfo->st_buf.sb.st_ctime > fileinfo->st_buf.sb.st_mtime) ? fileinfo->st_buf.sb.st_ctime : fileinfo->st_buf.sb.st_mtime; + } else { -+ key->mtime = fileinfo.st_buf.sb.st_mtime; ++ key->mtime = fileinfo->st_buf.sb.st_mtime; + } + key->type = APC_CACHE_KEY_FILE; ++ ++success: ++ ++ if(fileinfo != NULL) { ++ apc_php_free(fileinfo TSRMLS_CC); ++ } ++ + return 1; ++ ++cleanup: ++ ++ if(fileinfo != NULL) { ++ apc_php_free(fileinfo TSRMLS_CC); ++ } ++ ++ return 0; +} +/* }}} */ + @@ -2535,7 +2683,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + zend_op_array* op_array, + apc_function_t* functions, + apc_class_t* classes, -+ apc_context_t* ctxt) ++ apc_context_t* ctxt ++ TSRMLS_DC) +{ + apc_cache_entry_t* entry; + apc_pool* pool = ctxt->pool; @@ -2543,21 +2692,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + entry = (apc_cache_entry_t*) apc_pool_alloc(pool, sizeof(apc_cache_entry_t)); + if (!entry) return NULL; + -+ entry->data.file.filename = apc_pstrdup(filename, pool); ++ entry->data.file.filename = apc_pstrdup(filename, pool TSRMLS_CC); + if(!entry->data.file.filename) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"apc_cache_make_file_entry: entry->data.file.filename is NULL - bailing\n"); -+#endif ++ apc_debug("apc_cache_make_file_entry: entry->data.file.filename is NULL - bailing\n" TSRMLS_CC); + return NULL; + } -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"apc_cache_make_file_entry: entry->data.file.filename is [%s]\n",entry->data.file.filename); -+#endif ++ apc_debug("apc_cache_make_file_entry: entry->data.file.filename is [%s]\n" TSRMLS_CC,entry->data.file.filename); + entry->data.file.op_array = op_array; + entry->data.file.functions = functions; + entry->data.file.classes = classes; + -+ entry->data.file.halt_offset = apc_file_halt_offset(filename); ++ entry->data.file.halt_offset = apc_file_halt_offset(filename TSRMLS_CC); + + entry->type = APC_CACHE_ENTRY_FILE; + entry->ref_count = 0; @@ -2568,18 +2713,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_store_zval */ -+zval* apc_cache_store_zval(zval* dst, const zval* src, apc_context_t* ctxt) ++zval* apc_cache_store_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ TSRMLS_FETCH(); -+ + if (Z_TYPE_P(src) == IS_ARRAY) { + /* Maintain a list of zvals we've copied to properly handle recursive structures */ + zend_hash_init(&APCG(copied_zvals), 0, NULL, NULL, 0); -+ dst = apc_copy_zval(dst, src, ctxt); ++ dst = apc_copy_zval(dst, src, ctxt TSRMLS_CC); + zend_hash_destroy(&APCG(copied_zvals)); + APCG(copied_zvals).nTableSize=0; + } else { -+ dst = apc_copy_zval(dst, src, ctxt); ++ dst = apc_copy_zval(dst, src, ctxt TSRMLS_CC); + } + + @@ -2588,18 +2731,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_fetch_zval */ -+zval* apc_cache_fetch_zval(zval* dst, const zval* src, apc_context_t* ctxt) ++zval* apc_cache_fetch_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ TSRMLS_FETCH(); -+ + if (Z_TYPE_P(src) == IS_ARRAY) { + /* Maintain a list of zvals we've copied to properly handle recursive structures */ + zend_hash_init(&APCG(copied_zvals), 0, NULL, NULL, 0); -+ dst = apc_copy_zval(dst, src, ctxt); ++ dst = apc_copy_zval(dst, src, ctxt TSRMLS_CC); + zend_hash_destroy(&APCG(copied_zvals)); + APCG(copied_zvals).nTableSize=0; + } else { -+ dst = apc_copy_zval(dst, src, ctxt); ++ dst = apc_copy_zval(dst, src, ctxt TSRMLS_CC); + } + + @@ -2608,7 +2749,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_make_user_entry */ -+apc_cache_entry_t* apc_cache_make_user_entry(const char* info, int info_len, const zval* val, apc_context_t* ctxt, const unsigned int ttl) ++apc_cache_entry_t* apc_cache_make_user_entry(const char* info, int info_len, const zval* val, apc_context_t* ctxt, const unsigned int ttl TSRMLS_DC) +{ + apc_cache_entry_t* entry; + apc_pool* pool = ctxt->pool; @@ -2616,12 +2757,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + entry = (apc_cache_entry_t*) apc_pool_alloc(pool, sizeof(apc_cache_entry_t)); + if (!entry) return NULL; + -+ entry->data.user.info = apc_pmemcpy(info, info_len+1, pool); ++ entry->data.user.info = apc_pmemcpy(info, info_len, pool TSRMLS_CC); + entry->data.user.info_len = info_len; + if(!entry->data.user.info) { + return NULL; + } -+ entry->data.user.val = apc_cache_store_zval(NULL, val, ctxt); ++ entry->data.user.val = apc_cache_store_zval(NULL, val, ctxt TSRMLS_CC); + if(!entry->data.user.val) { + return NULL; + } @@ -2636,19 +2777,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_info */ -+apc_cache_info_t* apc_cache_info(apc_cache_t* cache, zend_bool limited) ++apc_cache_info_t* apc_cache_info(apc_cache_t* cache, zend_bool limited TSRMLS_DC) +{ + apc_cache_info_t* info; + slot_t* p; + int i; + -+ TSRMLS_FETCH(); -+ + if(!cache) return NULL; + + CACHE_LOCK(cache); + -+ info = (apc_cache_info_t*) apc_emalloc(sizeof(apc_cache_info_t)); ++ info = (apc_cache_info_t*) apc_php_malloc(sizeof(apc_cache_info_t) TSRMLS_CC); + if(!info) { + CACHE_UNLOCK(cache); + return NULL; @@ -2670,17 +2809,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + for (i = 0; i < info->num_slots; i++) { + p = cache->slots[i]; + for (; p != NULL; p = p->next) { -+ apc_cache_link_t* link = (apc_cache_link_t*) apc_emalloc(sizeof(apc_cache_link_t)); ++ apc_cache_link_t* link = (apc_cache_link_t*) apc_php_malloc(sizeof(apc_cache_link_t) TSRMLS_CC); + + if(p->value->type == APC_CACHE_ENTRY_FILE) { + if(p->key.type == APC_CACHE_KEY_FILE) { + link->data.file.device = p->key.data.file.device; + link->data.file.inode = p->key.data.file.inode; -+ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_emalloc); ++ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_php_malloc TSRMLS_CC); + } else { /* This is a no-stat fullpath file entry */ + link->data.file.device = 0; + link->data.file.inode = 0; -+ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_emalloc); ++ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_php_malloc TSRMLS_CC); + } + link->type = APC_CACHE_ENTRY_FILE; + if (APCG(file_md5)) { @@ -2690,7 +2829,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + link->data.file.md5 = NULL; + } + } else if(p->value->type == APC_CACHE_ENTRY_USER) { -+ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_emalloc); ++ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_php_malloc TSRMLS_CC); + link->data.user.ttl = p->value->data.user.ttl; + link->type = APC_CACHE_ENTRY_USER; + } @@ -2708,17 +2847,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + + /* For each slot pending deletion */ + for (p = cache->header->deleted_list; p != NULL; p = p->next) { -+ apc_cache_link_t* link = (apc_cache_link_t*) apc_emalloc(sizeof(apc_cache_link_t)); ++ apc_cache_link_t* link = (apc_cache_link_t*) apc_php_malloc(sizeof(apc_cache_link_t) TSRMLS_CC); + + if(p->value->type == APC_CACHE_ENTRY_FILE) { + if(p->key.type == APC_CACHE_KEY_FILE) { + link->data.file.device = p->key.data.file.device; + link->data.file.inode = p->key.data.file.inode; -+ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_emalloc); ++ link->data.file.filename = apc_xstrdup(p->value->data.file.filename, apc_php_malloc TSRMLS_CC); + } else { /* This is a no-stat fullpath file entry */ + link->data.file.device = 0; + link->data.file.inode = 0; -+ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_emalloc); ++ link->data.file.filename = apc_xstrdup(p->key.data.fpfile.fullpath, apc_php_malloc TSRMLS_CC); + } + link->type = APC_CACHE_ENTRY_FILE; + if (APCG(file_md5)) { @@ -2728,7 +2867,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + link->data.file.md5 = NULL; + } + } else if(p->value->type == APC_CACHE_ENTRY_USER) { -+ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_emalloc); ++ link->data.user.info = apc_xmemcpy(p->value->data.user.info, p->value->data.user.info_len+1, apc_php_malloc TSRMLS_CC); + link->data.user.ttl = p->value->data.user.ttl; + link->type = APC_CACHE_ENTRY_USER; + } @@ -2750,7 +2889,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_free_info */ -+void apc_cache_free_info(apc_cache_info_t* info) ++void apc_cache_free_info(apc_cache_info_t* info TSRMLS_DC) +{ + apc_cache_link_t* p = info->list; + apc_cache_link_t* q = NULL; @@ -2761,10 +2900,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if(q->data.file.md5) { + efree(q->data.file.md5); + } -+ apc_efree(q->data.file.filename); ++ apc_php_free(q->data.file.filename TSRMLS_CC); + } -+ else if(q->type == APC_CACHE_ENTRY_USER) apc_efree(q->data.user.info); -+ apc_efree(q); ++ else if(q->type == APC_CACHE_ENTRY_USER) apc_php_free(q->data.user.info TSRMLS_CC); ++ apc_php_free(q TSRMLS_CC); + } + p = info->deleted_list; + while (p != NULL) { @@ -2774,17 +2913,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + if(q->data.file.md5) { + efree(q->data.file.md5); + } -+ apc_efree(q->data.file.filename); ++ apc_php_free(q->data.file.filename TSRMLS_CC); + } -+ else if(q->type == APC_CACHE_ENTRY_USER) apc_efree(q->data.user.info); -+ apc_efree(q); ++ else if(q->type == APC_CACHE_ENTRY_USER) apc_php_free(q->data.user.info TSRMLS_CC); ++ apc_php_free(q TSRMLS_CC); + } -+ apc_efree(info); ++ apc_php_free(info TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_cache_unlock */ -+void apc_cache_unlock(apc_cache_t* cache) ++void apc_cache_unlock(apc_cache_t* cache TSRMLS_DC) +{ + CACHE_UNLOCK(cache); +} @@ -2798,18 +2937,29 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c +/* }}} */ + +/* {{{ apc_cache_is_last_key */ -+zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t) ++zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, unsigned int h, time_t t TSRMLS_DC) +{ + apc_keyid_t *lastkey = &cache->header->lastkey; -+ unsigned int keylen = key->data.user.identifier_len+1; -+ unsigned int h = string_nhash_8(key->data.user.identifier, keylen); ++ unsigned int keylen = key->data.user.identifier_len; ++#ifdef ZTS ++ THREAD_T tid = tsrm_thread_id(); ++ #define FROM_DIFFERENT_THREAD(k) (memcmp(&((k)->tid), &tid, sizeof(THREAD_T))!=0) ++#else ++ pid_t pid = getpid(); ++ #define FROM_DIFFERENT_THREAD(k) (pid != (k)->pid) ++#endif ++ ++ ++ if(!h) h = string_nhash_8(key->data.user.identifier, keylen); + + /* unlocked reads, but we're not shooting for 100% success with this */ + if(lastkey->h == h && keylen == lastkey->keylen) { -+ if(lastkey->mtime == t) { ++ if(lastkey->mtime == t && FROM_DIFFERENT_THREAD(lastkey)) { + /* potential cache slam */ -+ apc_wprint("Potential cache slam averted for key '%s'", key->data.user.identifier); -+ return 1; ++ if(APCG(slam_defense)) { ++ apc_warning("Potential cache slam averted for key '%s'" TSRMLS_CC, key->data.user.identifier); ++ return 1; ++ } + } + } + @@ -2819,14 +2969,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + +#if NONBLOCKING_LOCK_AVAILABLE +/* {{{ apc_cache_write_lock */ -+zend_bool apc_cache_write_lock(apc_cache_t* cache) ++zend_bool apc_cache_write_lock(apc_cache_t* cache TSRMLS_DC) +{ + return apc_lck_nb_lock(cache->header->wrlock); +} +/* }}} */ + +/* {{{ apc_cache_write_unlock */ -+void apc_cache_write_unlock(apc_cache_t* cache) ++void apc_cache_write_unlock(apc_cache_t* cache TSRMLS_DC) +{ + apc_lck_unlock(cache->header->wrlock); +} @@ -2841,15 +2991,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.c php-5.3.1/ext/apc/apc_cache.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h ---- php-5.3.1.orig/ext/apc/apc_cache.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_cache.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,378 @@ +--- /dev/null ++++ b/ext/apc/apc_cache.h +@@ -0,0 +1,403 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -2873,7 +3022,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + + */ + -+/* $Id: apc_cache.h 281919 2009-06-10 11:23:55Z gopalv $ */ ++/* $Id: apc_cache.h 305258 2010-11-10 19:02:06Z gopalv $ */ + +#ifndef APC_CACHE_H +#define APC_CACHE_H @@ -2888,6 +3037,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +#include "apc_lock.h" +#include "apc_pool.h" +#include "apc_main.h" ++#include "TSRM.h" + +#define APC_CACHE_ENTRY_FILE 1 +#define APC_CACHE_ENTRY_USER 2 @@ -2896,6 +3046,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +#define APC_CACHE_KEY_USER 2 +#define APC_CACHE_KEY_FPFILE 3 + ++#ifdef PHP_WIN32 ++typedef unsigned __int64 apc_ino_t; ++typedef unsigned __int64 apc_dev_t; ++#else ++typedef ino_t apc_ino_t; ++typedef dev_t apc_dev_t; ++#endif ++ +/* {{{ cache locking macros */ +#define CACHE_LOCK(cache) { LOCK(cache->header->lock); cache->has_lock = 1; } +#define CACHE_UNLOCK(cache) { UNLOCK(cache->header->lock); cache->has_lock = 0; } @@ -2909,8 +3067,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + +typedef union _apc_cache_key_data_t { + struct { -+ dev_t device; /* the filesystem device */ -+ ino_t inode; /* the filesystem inode */ ++ apc_dev_t device; /* the filesystem device */ ++ apc_ino_t inode; /* the filesystem inode */ + } file; + struct { + const char *identifier; @@ -2937,6 +3095,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + unsigned int h; + unsigned int keylen; + time_t mtime; ++#ifdef ZTS ++ THREAD_T tid; ++#else ++ pid_t pid; ++#endif +}; +/* }}} */ + @@ -2985,20 +3148,20 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * is needed. This helps in cleaning up the cache and ensuring that entries + * hit frequently stay cached and ones not hit very often eventually disappear. + */ -+extern T apc_cache_create(int size_hint, int gc_ttl, int ttl); ++extern T apc_cache_create(int size_hint, int gc_ttl, int ttl TSRMLS_DC); + +/* + * apc_cache_destroy releases any OS resources associated with a cache object. + * Under apache, this function can be safely called by the child processes + * when they exit. + */ -+extern void apc_cache_destroy(T cache); ++extern void apc_cache_destroy(T cache TSRMLS_DC); + +/* + * apc_cache_clear empties a cache. This can safely be called at any time, + * even while other server processes are executing cached source files. + */ -+extern void apc_cache_clear(T cache); ++extern void apc_cache_clear(T cache TSRMLS_DC); + +/* + * apc_cache_insert adds an entry to the cache, using a filename as a key. @@ -3013,13 +3176,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * value is a cache entry returned by apc_cache_make_entry (see below). + */ +extern int apc_cache_insert(T cache, apc_cache_key_t key, -+ apc_cache_entry_t* value, apc_context_t* ctxt, time_t t); ++ apc_cache_entry_t* value, apc_context_t* ctxt, time_t t TSRMLS_DC); + +extern int apc_cache_user_insert(T cache, apc_cache_key_t key, + apc_cache_entry_t* value, apc_context_t* ctxt, time_t t, int exclusive TSRMLS_DC); + +extern int *apc_cache_insert_mult(apc_cache_t* cache, apc_cache_key_t* keys, -+ apc_cache_entry_t** values, apc_context_t *ctxt, time_t t, int num_entries); ++ apc_cache_entry_t** values, apc_context_t *ctxt, time_t t, int num_entries TSRMLS_DC); + +/* + * apc_cache_find searches for a cache entry by filename, and returns a @@ -3027,26 +3190,35 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * + * key is a value created by apc_cache_make_file_key for file keys. + */ -+extern apc_cache_entry_t* apc_cache_find(T cache, apc_cache_key_t key, time_t t); ++extern apc_cache_entry_t* apc_cache_find(T cache, apc_cache_key_t key, time_t t TSRMLS_DC); + +/* + * apc_cache_user_find searches for a cache entry by its hashed identifier, + * and returns a pointer to the entry if found, NULL otherwise. + * + */ -+extern apc_cache_entry_t* apc_cache_user_find(T cache, char* strkey, int keylen, time_t t); ++extern apc_cache_entry_t* apc_cache_user_find(T cache, char* strkey, int keylen, time_t t TSRMLS_DC); ++ ++/* ++ * apc_cache_user_exists searches for a cache entry by its hashed identifier, ++ * and returns a pointer to the entry if found, NULL otherwise. This is a ++ * quick non-locking version of apc_cache_user_find that does not modify the ++ * shared memory segment in any way. ++ * ++ */ ++extern apc_cache_entry_t* apc_cache_user_exists(T cache, char* strkey, int keylen, time_t t TSRMLS_DC); + +/* + * apc_cache_delete and apc_cache_user_delete finds an entry in the cache and deletes it. + */ -+extern int apc_cache_delete(apc_cache_t* cache, char *filename, int filename_len); -+extern int apc_cache_user_delete(apc_cache_t* cache, char *strkey, int keylen); ++extern int apc_cache_delete(apc_cache_t* cache, char *filename, int filename_len TSRMLS_DC); ++extern int apc_cache_user_delete(apc_cache_t* cache, char *strkey, int keylen TSRMLS_DC); + +/* apc_cach_fetch_zval takes a zval in the cache and reconstructs a runtime + * zval from it. + * + */ -+zval* apc_cache_fetch_zval(zval* dst, const zval* src, apc_context_t* ctxt); ++zval* apc_cache_fetch_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC); + +/* + * apc_cache_release decrements the reference count associated with a cache @@ -3057,7 +3229,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * + * entry is the cache entry whose ref count you want to decrement. + */ -+extern void apc_cache_release(T cache, apc_cache_entry_t* entry); ++extern void apc_cache_release(T cache, apc_cache_entry_t* entry TSRMLS_DC); + +/* + * apc_cache_make_file_key creates a key object given a relative or absolute @@ -3089,7 +3261,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + zend_op_array* op_array, + apc_function_t* functions, + apc_class_t* classes, -+ apc_context_t* ctxt); ++ apc_context_t* ctxt ++ TSRMLS_DC); + + +zend_bool apc_compile_cache_entry(apc_cache_key_t key, zend_file_handle* h, int type, time_t t, zend_op_array** op_array_pp, apc_cache_entry_t** cache_entry_pp TSRMLS_DC); @@ -3098,7 +3271,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * apc_cache_make_user_entry creates an apc_cache_entry_t object given an info string + * and the zval to be stored. + */ -+extern apc_cache_entry_t* apc_cache_make_user_entry(const char* info, int info_len, const zval *val, apc_context_t* ctxt, const unsigned int ttl); ++extern apc_cache_entry_t* apc_cache_make_user_entry(const char* info, int info_len, const zval *val, apc_context_t* ctxt, const unsigned int ttl TSRMLS_DC); + +extern int apc_cache_make_user_key(apc_cache_key_t* key, char* identifier, int identifier_len, const time_t t); + @@ -3106,8 +3279,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +typedef union _apc_cache_link_data_t { + struct { + char *filename; -+ dev_t device; -+ ino_t inode; ++ apc_ino_t device; ++ apc_dev_t inode; + unsigned char *md5; + } file; + struct { @@ -3133,6 +3306,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +}; +/* }}} */ + ++ +/* {{{ struct definition: apc_cache_info_t */ +typedef struct apc_cache_info_t apc_cache_info_t; +struct apc_cache_info_t { @@ -3182,7 +3356,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +}; +/* }}} */ + -+typedef void (*apc_expunge_cb_t)(T cache, size_t n); ++typedef void (*apc_expunge_cb_t)(T cache, size_t n TSRMLS_DC); + +/* {{{ struct definition: apc_cache_t */ +struct apc_cache_t { @@ -3197,13 +3371,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h +}; +/* }}} */ + -+extern apc_cache_info_t* apc_cache_info(T cache, zend_bool limited); -+extern void apc_cache_free_info(apc_cache_info_t* info); -+extern void apc_cache_unlock(apc_cache_t* cache); ++extern apc_cache_info_t* apc_cache_info(T cache, zend_bool limited TSRMLS_DC); ++extern void apc_cache_free_info(apc_cache_info_t* info TSRMLS_DC); ++extern void apc_cache_unlock(apc_cache_t* cache TSRMLS_DC); +extern zend_bool apc_cache_busy(apc_cache_t* cache); -+extern zend_bool apc_cache_write_lock(apc_cache_t* cache); -+extern void apc_cache_write_unlock(apc_cache_t* cache); -+extern zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, time_t t); ++extern zend_bool apc_cache_write_lock(apc_cache_t* cache TSRMLS_DC); ++extern void apc_cache_write_unlock(apc_cache_t* cache TSRMLS_DC); ++extern zend_bool apc_cache_is_last_key(apc_cache_t* cache, apc_cache_key_t* key, unsigned int h, time_t t TSRMLS_DC); + +/* used by apc_rfc1867 to update data in-place - not to be used elsewhere */ + @@ -3223,15 +3397,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_cache.h php-5.3.1/ext/apc/apc_cache.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c ---- php-5.3.1.orig/ext/apc/apc_compile.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_compile.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,1775 @@ +--- /dev/null ++++ b/ext/apc/apc_compile.c +@@ -0,0 +1,2102 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -3257,11 +3430,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + */ + -+/* $Id: apc_compile.c 284580 2009-07-22 06:05:31Z kalle $ */ ++/* $Id: apc_compile.c 303796 2010-09-27 17:14:18Z gopalv $ */ + +#include "apc_compile.h" +#include "apc_globals.h" +#include "apc_zend.h" ++#include "apc_string.h" +#include "ext/standard/php_var.h" +#include "ext/standard/php_smart_str.h" + @@ -3269,7 +3443,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +#define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) +#endif + -+typedef void* (*ht_copy_fun_t)(void*, void*, apc_context_t*); ++typedef void* (*ht_copy_fun_t)(void*, void*, apc_context_t* TSRMLS_DC); +//typedef void (*ht_free_fun_t)(void*, apc_context_t*); +typedef int (*ht_check_copy_fun_t)(Bucket*, va_list); + @@ -3279,27 +3453,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + +/* {{{ internal function declarations */ + -+static zend_function* my_bitwise_copy_function(zend_function*, zend_function*, apc_context_t*); ++static zend_function* my_bitwise_copy_function(zend_function*, zend_function*, apc_context_t* TSRMLS_DC); + +/* + * The "copy" functions perform deep-copies on a particular data structure + * (passed as the second argument). They also optionally allocate space for + * the destination data structure if the first argument is null. + */ -+static zval** my_copy_zval_ptr(zval**, const zval**, apc_context_t*); -+static zval* my_copy_zval(zval*, const zval*, apc_context_t*); -+static znode* my_copy_znode(znode*, znode*, apc_context_t*); -+static zend_op* my_copy_zend_op(zend_op*, zend_op*, apc_context_t*); -+static zend_function* my_copy_function(zend_function*, zend_function*, apc_context_t*); -+static zend_function_entry* my_copy_function_entry(zend_function_entry*, const zend_function_entry*, apc_context_t*); -+static zend_class_entry* my_copy_class_entry(zend_class_entry*, zend_class_entry*, apc_context_t*); -+static HashTable* my_copy_hashtable_ex(HashTable*, HashTable*, ht_copy_fun_t, int, apc_context_t*, ht_check_copy_fun_t, ...); ++static zval** my_copy_zval_ptr(zval**, const zval**, apc_context_t* TSRMLS_DC); ++static zval* my_copy_zval(zval*, const zval*, apc_context_t* TSRMLS_DC); ++static znode* my_copy_znode(znode*, znode*, apc_context_t* TSRMLS_DC); ++static zend_op* my_copy_zend_op(zend_op*, zend_op*, apc_context_t* TSRMLS_DC); ++static zend_function* my_copy_function(zend_function*, zend_function*, apc_context_t* TSRMLS_DC); ++static zend_function_entry* my_copy_function_entry(zend_function_entry*, const zend_function_entry*, apc_context_t* TSRMLS_DC); ++static zend_class_entry* my_copy_class_entry(zend_class_entry*, zend_class_entry*, apc_context_t* TSRMLS_DC); ++static HashTable* my_copy_hashtable_ex(HashTable*, HashTable* TSRMLS_DC, ht_copy_fun_t, int, apc_context_t*, ht_check_copy_fun_t, ...); +#define my_copy_hashtable( dst, src, copy_fn, holds_ptr, ctxt) \ -+ my_copy_hashtable_ex(dst, src, copy_fn, holds_ptr, ctxt, NULL) -+static HashTable* my_copy_static_variables(zend_op_array* src, apc_context_t*); -+static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_context_t*); -+static zend_arg_info* my_copy_arg_info_array(zend_arg_info*, const zend_arg_info*, uint, apc_context_t*); -+static zend_arg_info* my_copy_arg_info(zend_arg_info*, const zend_arg_info*, apc_context_t*); ++ my_copy_hashtable_ex(dst, src TSRMLS_CC, copy_fn, holds_ptr, ctxt, NULL) ++static HashTable* my_copy_static_variables(zend_op_array* src, apc_context_t* TSRMLS_DC); ++static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_context_t* TSRMLS_DC); ++static zend_arg_info* my_copy_arg_info_array(zend_arg_info*, const zend_arg_info*, uint, apc_context_t* TSRMLS_DC); ++static zend_arg_info* my_copy_arg_info(zend_arg_info*, const zend_arg_info*, apc_context_t* TSRMLS_DC); + +/* + * The "fixup" functions need for ZEND_ENGINE_2 @@ -3324,6 +3498,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +static int my_check_copy_default_property(Bucket* p, va_list args); +static int my_check_copy_property_info(Bucket* src, va_list args); +static int my_check_copy_static_member(Bucket* src, va_list args); ++static int my_check_copy_constant(Bucket* src, va_list args); + +/* }}} */ + @@ -3371,7 +3546,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_bitwise_copy_function */ -+static zend_function* my_bitwise_copy_function(zend_function* dst, zend_function* src, apc_context_t* ctxt) ++static zend_function* my_bitwise_copy_function(zend_function* dst, zend_function* src, apc_context_t* ctxt TSRMLS_DC) +{ + apc_pool* pool = ctxt->pool; + @@ -3389,7 +3564,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_zval_ptr */ -+static zval** my_copy_zval_ptr(zval** dst, const zval** src, apc_context_t* ctxt) ++static zval** my_copy_zval_ptr(zval** dst, const zval** src, apc_context_t* ctxt TSRMLS_DC) +{ + zval* dst_new; + apc_pool* pool = ctxt->pool; @@ -3408,11 +3583,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + CHECK((dst[0] = (zval*) apc_pool_alloc(pool, sizeof(zval)))); + } + -+ CHECK((dst_new = my_copy_zval(*dst, *src, ctxt))); ++ CHECK((dst_new = my_copy_zval(*dst, *src, ctxt TSRMLS_CC))); + + if(dst_new != *dst) { + if(usegc) { -+ TSRMLS_FETCH(); + FREE_ZVAL(dst[0]); + } + *dst = dst_new; @@ -3423,14 +3597,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_serialize_object */ -+static zval* my_serialize_object(zval* dst, const zval* src, apc_context_t* ctxt) ++static zval* my_serialize_object(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + smart_str buf = {0}; + php_serialize_data_t var_hash; + apc_pool* pool = ctxt->pool; + -+ TSRMLS_FETCH(); -+ + PHP_VAR_SERIALIZE_INIT(var_hash); + php_var_serialize(&buf, (zval**)&src, &var_hash TSRMLS_CC); + PHP_VAR_SERIALIZE_DESTROY(var_hash); @@ -3438,7 +3610,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + if(buf.c) { + dst->type = src->type & ~IS_CONSTANT_INDEX; + dst->value.str.len = buf.len; -+ CHECK(dst->value.str.val = apc_pmemcpy(buf.c, buf.len+1, pool)); ++ CHECK(dst->value.str.val = apc_pmemcpy(buf.c, (buf.len + 1), pool TSRMLS_CC)); + dst->type = src->type; + smart_str_free(&buf); + } @@ -3448,13 +3620,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_unserialize_object */ -+static zval* my_unserialize_object(zval* dst, const zval* src, apc_context_t* ctxt) ++static zval* my_unserialize_object(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + php_unserialize_data_t var_hash; + const unsigned char *p = (unsigned char*)Z_STRVAL_P(src); + -+ TSRMLS_FETCH(); -+ + PHP_VAR_UNSERIALIZE_INIT(var_hash); + if(!php_var_unserialize(&dst, &p, p + Z_STRLEN_P(src), &var_hash TSRMLS_CC)) { + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); @@ -3467,12 +3637,24 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +} +/* }}} */ + ++static char *apc_string_pmemcpy(char *str, size_t len, apc_pool* pool TSRMLS_DC) ++{ ++#ifdef ZEND_ENGINE_2_4 ++ if (pool->type != APC_UNPOOL) { ++ char * ret = apc_new_interned_string(str, len TSRMLS_CC); ++ if (ret) { ++ return ret; ++ } ++ } ++#endif ++ return apc_pmemcpy(str, len, pool TSRMLS_CC); ++} ++ +/* {{{ my_copy_zval */ -+static zval* my_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt) ++static zval* my_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + zval **tmp; + apc_pool* pool = ctxt->pool; -+ TSRMLS_FETCH(); + + assert(dst != NULL); + assert(src != NULL); @@ -3514,9 +3696,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + case IS_CONSTANT: + case IS_STRING: + if (src->value.str.val) { -+ CHECK(dst->value.str.val = apc_pmemcpy(src->value.str.val, ++ CHECK(dst->value.str.val = apc_string_pmemcpy(src->value.str.val, + src->value.str.len+1, -+ pool)); ++ pool TSRMLS_CC)); + } + break; + @@ -3535,9 +3717,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + dst->type = IS_NULL; + if(ctxt->copy == APC_COPY_IN_USER) { -+ dst = my_serialize_object(dst, src, ctxt); ++ dst = my_serialize_object(dst, src, ctxt TSRMLS_CC); + } else if(ctxt->copy == APC_COPY_OUT_USER) { -+ dst = my_unserialize_object(dst, src, ctxt); ++ dst = my_unserialize_object(dst, src, ctxt TSRMLS_CC); + } + break; + @@ -3549,8 +3731,36 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +} +/* }}} */ + ++#ifdef ZEND_ENGINE_2_4 ++/* {{{ my_copy_znode */ ++static void my_check_znode(zend_uchar op_type, apc_context_t* ctxt TSRMLS_DC) ++{ ++ assert(op_type == IS_CONST || ++ op_type == IS_VAR || ++ op_type == IS_CV || ++ op_type == IS_TMP_VAR || ++ op_type == IS_UNUSED); ++} ++/* }}} */ ++ ++/* {{{ my_copy_zend_op */ ++static zend_op* my_copy_zend_op(zend_op* dst, zend_op* src, apc_context_t* ctxt TSRMLS_DC) ++{ ++ assert(dst != NULL); ++ assert(src != NULL); ++ ++ memcpy(dst, src, sizeof(src[0])); ++ ++ my_check_znode(dst->result_type & ~EXT_TYPE_UNUSED, ctxt TSRMLS_CC); ++ my_check_znode(dst->op1_type, ctxt TSRMLS_CC); ++ my_check_znode(dst->op2_type, ctxt TSRMLS_CC); ++ ++ return dst; ++} ++/* }}} */ ++#else +/* {{{ my_copy_znode */ -+static znode* my_copy_znode(znode* dst, znode* src, apc_context_t* ctxt) ++static znode* my_copy_znode(znode* dst, znode* src, apc_context_t* ctxt TSRMLS_DC) +{ + assert(dst != NULL); + assert(src != NULL); @@ -3571,7 +3781,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +#endif + + if (src->op_type == IS_CONST) { -+ if(!my_copy_zval(&dst->u.constant, &src->u.constant, ctxt)) { ++ if(!my_copy_zval(&dst->u.constant, &src->u.constant, ctxt TSRMLS_CC)) { + return NULL; + } + } @@ -3581,29 +3791,28 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_zend_op */ -+static zend_op* my_copy_zend_op(zend_op* dst, zend_op* src, apc_context_t* ctxt) ++static zend_op* my_copy_zend_op(zend_op* dst, zend_op* src, apc_context_t* ctxt TSRMLS_DC) +{ + assert(dst != NULL); + assert(src != NULL); + + memcpy(dst, src, sizeof(src[0])); + -+ CHECK(my_copy_znode(&dst->result, &src->result, ctxt)); -+ CHECK(my_copy_znode(&dst->op1, &src->op1, ctxt)); -+ CHECK(my_copy_znode(&dst->op2, &src->op2, ctxt)); ++ CHECK(my_copy_znode(&dst->result, &src->result, ctxt TSRMLS_CC)); ++ CHECK(my_copy_znode(&dst->op1, &src->op1, ctxt TSRMLS_CC)); ++ CHECK(my_copy_znode(&dst->op2, &src->op2, ctxt TSRMLS_CC)); + + return dst; +} +/* }}} */ ++#endif + +/* {{{ my_copy_function */ -+static zend_function* my_copy_function(zend_function* dst, zend_function* src, apc_context_t* ctxt) ++static zend_function* my_copy_function(zend_function* dst, zend_function* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ TSRMLS_FETCH(); -+ + assert(src != NULL); + -+ CHECK(dst = my_bitwise_copy_function(dst, src, ctxt)); ++ CHECK(dst = my_bitwise_copy_function(dst, src, ctxt TSRMLS_CC)); + + switch (src->type) { + case ZEND_INTERNAL_FUNCTION: @@ -3646,7 +3855,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_function_entry */ -+static zend_function_entry* my_copy_function_entry(zend_function_entry* dst, const zend_function_entry* src, apc_context_t* ctxt) ++static zend_function_entry* my_copy_function_entry(zend_function_entry* dst, const zend_function_entry* src, apc_context_t* ctxt TSRMLS_DC) +{ + assert(src != NULL); + @@ -3661,14 +3870,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + dst->arg_info = NULL; + + if (src->fname) { -+ CHECK((dst->fname = apc_pstrdup(src->fname, ctxt->pool))); ++ CHECK((dst->fname = apc_pstrdup(src->fname, ctxt->pool TSRMLS_CC))); + } + + if (src->arg_info) { + CHECK((dst->arg_info = my_copy_arg_info_array(NULL, + src->arg_info, + src->num_args, -+ ctxt))); ++ ctxt TSRMLS_CC))); + } + + return dst; @@ -3676,7 +3885,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_property_info */ -+static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt) ++static zend_property_info* my_copy_property_info(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt TSRMLS_DC) +{ + apc_pool* pool = ctxt->pool; + @@ -3699,12 +3908,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + * string of the form: + * \0\0\0 + */ -+ CHECK((dst->name = apc_pmemcpy(src->name, src->name_length+1, pool))); ++ CHECK((dst->name = apc_string_pmemcpy(src->name, src->name_length+1, pool TSRMLS_CC))); + } + +#if defined(ZEND_ENGINE_2) && PHP_MINOR_VERSION > 0 + if (src->doc_comment) { -+ CHECK((dst->doc_comment = apc_pmemcpy(src->doc_comment, src->doc_comment_len+1, pool))); ++ CHECK((dst->doc_comment = apc_pmemcpy(src->doc_comment, (src->doc_comment_len + 1), pool TSRMLS_CC))); + } +#endif + @@ -3713,12 +3922,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_property_info_for_execution */ -+static zend_property_info* my_copy_property_info_for_execution(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt) ++static zend_property_info* my_copy_property_info_for_execution(zend_property_info* dst, zend_property_info* src, apc_context_t* ctxt TSRMLS_DC) +{ + assert(src != NULL); + + if (!dst) { -+ CHECK(dst = (zend_property_info*) apc_pool_alloc(ctxt->pool, (sizeof(*src)))); ++ CHECK(dst = (zend_property_info*) apc_pool_alloc(ctxt->pool, sizeof(*src))); + } + + /* We need only a shallow copy */ @@ -3729,20 +3938,20 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_arg_info_array */ -+static zend_arg_info* my_copy_arg_info_array(zend_arg_info* dst, const zend_arg_info* src, uint num_args, apc_context_t* ctxt) ++static zend_arg_info* my_copy_arg_info_array(zend_arg_info* dst, const zend_arg_info* src, uint num_args, apc_context_t* ctxt TSRMLS_DC) +{ + uint i = 0; + + + if (!dst) { -+ CHECK(dst = (zend_arg_info*) apc_pool_alloc(ctxt->pool, sizeof(*src)*num_args)); ++ CHECK(dst = (zend_arg_info*) apc_pool_alloc(ctxt->pool, (sizeof(*src) * num_args))); + } + + /* Start with a bitwise copy */ + memcpy(dst, src, sizeof(*src)*num_args); + + for(i=0; i < num_args; i++) { -+ CHECK((my_copy_arg_info( &dst[i], &src[i], ctxt))); ++ CHECK((my_copy_arg_info( &dst[i], &src[i], ctxt TSRMLS_CC))); + } + + return dst; @@ -3750,7 +3959,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_arg_info */ -+static zend_arg_info* my_copy_arg_info(zend_arg_info* dst, const zend_arg_info* src, apc_context_t* ctxt) ++static zend_arg_info* my_copy_arg_info(zend_arg_info* dst, const zend_arg_info* src, apc_context_t* ctxt TSRMLS_DC) +{ + apc_pool* pool = ctxt->pool; + @@ -3767,11 +3976,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + dst->class_name = NULL; + + if (src->name) { -+ CHECK((dst->name = apc_pmemcpy(src->name, src->name_len+1, pool))); ++ CHECK((dst->name = apc_string_pmemcpy((char *) src->name, src->name_len+1, pool TSRMLS_CC))); + } + + if (src->class_name) { -+ CHECK((dst->class_name = apc_pmemcpy(src->class_name, src->class_name_len+1, pool))); ++ CHECK((dst->class_name = apc_string_pmemcpy((char *) src->class_name, src->class_name_len+1, pool TSRMLS_CC))); + } + + return dst; @@ -3779,15 +3988,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ apc_copy_class_entry */ -+zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt) ++zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ return my_copy_class_entry(dst, src, ctxt); ++ return my_copy_class_entry(dst, src, ctxt TSRMLS_CC); +} + +/* {{{ my_copy_class_entry */ -+static zend_class_entry* my_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt) ++static zend_class_entry* my_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt TSRMLS_DC) +{ -+ uint i = 0; ++ int i = 0; + apc_pool* pool = ctxt->pool; + + assert(src != NULL); @@ -3800,22 +4009,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + memcpy(dst, src, sizeof(*src)); + + dst->name = NULL; -+ dst->builtin_functions = NULL; + memset(&dst->function_table, 0, sizeof(dst->function_table)); -+ memset(&dst->default_properties, 0, sizeof(dst->default_properties)); -+ dst->static_members = NULL; -+ dst->doc_comment = NULL; -+ dst->filename = NULL; ++ ZEND_CE_DOC_COMMENT(dst) = NULL; ++ ZEND_CE_FILENAME(dst) = NULL; + memset(&dst->properties_info, 0, sizeof(dst->properties_info)); + memset(&dst->constants_table, 0, sizeof(dst->constants_table)); -+ memset(&dst->default_static_members, 0, sizeof(dst->default_static_members)); + + if (src->name) { -+ CHECK((dst->name = apc_pstrdup(src->name, pool))); ++ CHECK((dst->name = apc_pstrdup(src->name, pool TSRMLS_CC))); + } + + if(!(my_copy_hashtable_ex(&dst->function_table, -+ &src->function_table, ++ &src->function_table TSRMLS_CC, + (ht_copy_fun_t) my_copy_function, + 0, + ctxt, @@ -3830,7 +4035,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + /* the current count includes inherited interfaces as well, + the real dynamic ones are the first which are zero'd + out in zend_do_end_class_declaration */ -+ for(i = 0 ; i < src->num_interfaces ; i++) { ++ for(i = 0 ; (uint)i < src->num_interfaces ; i++) { + if(src->interfaces[i]) + { + dst->num_interfaces = i; @@ -3863,16 +4068,33 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + my_fixup_hashtable(&dst->function_table, (ht_fixup_fun_t)my_fixup_function, src, dst); + ++#ifdef ZEND_ENGINE_2_4 ++ dst->default_properties_count = src->default_properties_count; ++ if (src->default_properties_count) { ++ CHECK(dst->default_properties_table = (zval**) apc_pool_alloc(pool, (sizeof(zval*) * src->default_properties_count))); ++ for (i = 0; i < src->default_properties_count; i++) { ++ if (src->default_properties_table[i]) { ++ my_copy_zval_ptr(&dst->default_properties_table[i], (const zval**)&src->default_properties_table[i], ctxt TSRMLS_CC); ++ } else { ++ dst->default_properties_table[i] = NULL; ++ } ++ } ++ } else { ++ dst->default_properties_table = NULL; ++ } ++#else ++ memset(&dst->default_properties, 0, sizeof(dst->default_properties)); + CHECK((my_copy_hashtable_ex(&dst->default_properties, -+ &src->default_properties, ++ &src->default_properties TSRMLS_CC, + (ht_copy_fun_t) my_copy_zval_ptr, + 1, + ctxt, + (ht_check_copy_fun_t) my_check_copy_default_property, + src))); ++#endif + + CHECK((my_copy_hashtable_ex(&dst->properties_info, -+ &src->properties_info, ++ &src->properties_info TSRMLS_CC, + (ht_copy_fun_t) my_copy_property_info, + 0, + ctxt, @@ -3884,8 +4106,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + my_fixup_hashtable(&dst->properties_info, (ht_fixup_fun_t)my_fixup_property_info_for_execution, src, dst); +#endif + ++#ifdef ZEND_ENGINE_2_4 ++ dst->default_static_members_count = src->default_static_members_count; ++ ++ if (src->default_static_members_count) { ++ CHECK(dst->default_static_members_table = (zval**) apc_pool_alloc(pool, (sizeof(zval*) * src->default_static_members_count))); ++ for (i = 0; i < src->default_static_members_count; i++) { ++ if (src->default_static_members_table[i]) { ++ my_copy_zval_ptr(&dst->default_static_members_table[i], (const zval**)&src->default_static_members_table[i], ctxt TSRMLS_CC); ++ } else { ++ dst->default_static_members_table[i] = NULL; ++ } ++ } ++ } else { ++ dst->default_static_members_table = NULL; ++ } ++ dst->static_members_table = dst->default_static_members_table; ++#else ++ memset(&dst->default_static_members, 0, sizeof(dst->default_static_members)); ++ dst->static_members = NULL; + CHECK(my_copy_hashtable_ex(&dst->default_static_members, -+ &src->default_static_members, ++ &src->default_static_members TSRMLS_CC, + (ht_copy_fun_t) my_copy_zval_ptr, + 1, + ctxt, @@ -3896,7 +4137,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + if(src->static_members != &src->default_static_members) + { + CHECK((dst->static_members = my_copy_hashtable_ex(NULL, -+ src->static_members, ++ src->static_members TSRMLS_CC, + (ht_copy_fun_t) my_copy_zval_ptr, + 1, + ctxt, @@ -3908,45 +4149,48 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + { + dst->static_members = &dst->default_static_members; + } ++#endif + -+ CHECK((my_copy_hashtable(&dst->constants_table, -+ &src->constants_table, ++ CHECK((my_copy_hashtable_ex(&dst->constants_table, ++ &src->constants_table TSRMLS_CC, + (ht_copy_fun_t) my_copy_zval_ptr, + 1, -+ ctxt))); ++ ctxt, ++ (ht_check_copy_fun_t) my_check_copy_constant, ++ src))); + -+ if (src->doc_comment) { -+ CHECK(dst->doc_comment = -+ apc_pmemcpy(src->doc_comment, src->doc_comment_len+1, pool)); ++ if (src->type == ZEND_USER_CLASS && ZEND_CE_DOC_COMMENT(src)) { ++ CHECK(ZEND_CE_DOC_COMMENT(dst) = ++ apc_pmemcpy(ZEND_CE_DOC_COMMENT(src), (ZEND_CE_DOC_COMMENT_LEN(src) + 1), pool TSRMLS_CC)); + } + -+ if (src->builtin_functions) { ++ if (src->type == ZEND_INTERNAL_CLASS && ZEND_CE_BUILTIN_FUNCTIONS(src)) { + int i, n; + -+ for (n = 0; src->type == ZEND_INTERNAL_CLASS && src->builtin_functions[n].fname != NULL; n++) {} ++ for (n = 0; src->type == ZEND_INTERNAL_CLASS && ZEND_CE_BUILTIN_FUNCTIONS(src)[n].fname != NULL; n++) {} + -+ CHECK((dst->builtin_functions = -+ (zend_function_entry*) apc_pool_alloc(pool, (n + 1) * sizeof(zend_function_entry)))); ++ CHECK((ZEND_CE_BUILTIN_FUNCTIONS(dst) = ++ (zend_function_entry*) apc_pool_alloc(pool, ((n + 1) * sizeof(zend_function_entry))))); + + for (i = 0; i < n; i++) { -+ CHECK(my_copy_function_entry((zend_function_entry*)(&dst->builtin_functions[i]), -+ &src->builtin_functions[i], -+ ctxt)); ++ CHECK(my_copy_function_entry((zend_function_entry*)(&ZEND_CE_BUILTIN_FUNCTIONS(dst)[i]), ++ &ZEND_CE_BUILTIN_FUNCTIONS(src)[i], ++ ctxt TSRMLS_CC)); + } -+ *(char**)&(dst->builtin_functions[n].fname) = NULL; ++ *(char**)&(ZEND_CE_BUILTIN_FUNCTIONS(dst)[n].fname) = NULL; + } + -+ if (src->filename) { -+ CHECK((dst->filename = apc_pstrdup(src->filename, pool))); ++ if (src->type == ZEND_USER_CLASS && ZEND_CE_FILENAME(src)) { ++ CHECK((ZEND_CE_FILENAME(dst) = apc_pstrdup(ZEND_CE_FILENAME(src), pool TSRMLS_CC))); + } + + return dst; +} +/* }}} */ + -+/* {{{ my_copy_hashtable */ ++/* {{{ my_copy_hashtable_ex */ +static HashTable* my_copy_hashtable_ex(HashTable* dst, -+ HashTable* src, ++ HashTable* src TSRMLS_DC, + ht_copy_fun_t copy_fn, + int holds_ptrs, + apc_context_t* ctxt, @@ -3968,7 +4212,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + memcpy(dst, src, sizeof(src[0])); + + /* allocate buckets for the new hashtable */ -+ CHECK((dst->arBuckets = apc_pool_alloc(pool, dst->nTableSize * sizeof(Bucket*)))); ++ CHECK((dst->arBuckets = apc_pool_alloc(pool, (dst->nTableSize * sizeof(Bucket*))))); + + memset(dst->arBuckets, 0, dst->nTableSize * sizeof(Bucket*)); + dst->pInternalPointer = NULL; @@ -3986,6 +4230,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + */ + if(!check_fn(curr, args)) { + dst->nNumOfElements--; ++ va_end(args); + continue; + } + @@ -3993,9 +4238,31 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + } + + /* create a copy of the bucket 'curr' */ ++#ifdef ZEND_ENGINE_2_4 ++ if (!curr->nKeyLength) { ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); ++ } else if (IS_INTERNED(curr->arKey)) { ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); ++ } else if (pool->type != APC_UNPOOL) { ++ char *arKey; ++ ++ arKey = apc_new_interned_string(curr->arKey, curr->nKeyLength TSRMLS_CC); ++ if (!arKey) { ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, (sizeof(Bucket) + curr->nKeyLength), pool TSRMLS_CC))); ++ newp->arKey = ((char*)newp) + sizeof(Bucket); ++ } else { ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC))); ++ newp->arKey = arKey; ++ } ++ } else { ++ CHECK((newp = (Bucket*) apc_pmemcpy(curr, (sizeof(Bucket) + curr->nKeyLength), pool TSRMLS_CC))); ++ newp->arKey = ((char*)newp) + sizeof(Bucket); ++ } ++#else + CHECK((newp = (Bucket*) apc_pmemcpy(curr, -+ sizeof(Bucket) + curr->nKeyLength - 1, -+ pool))); ++ (sizeof(Bucket) + curr->nKeyLength - 1), ++ pool TSRMLS_CC))); ++#endif + + /* insert 'newp' into the linked list at its hashed index */ + if (dst->arBuckets[n]) { @@ -4010,7 +4277,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + dst->arBuckets[n] = newp; + + /* copy the bucket data using our 'copy_fn' callback function */ -+ CHECK((newp->pData = copy_fn(NULL, curr->pData, ctxt))); ++ CHECK((newp->pData = copy_fn(NULL, curr->pData, ctxt TSRMLS_CC))); + + if (holds_ptrs) { + memcpy(&newp->pDataPtr, newp->pData, sizeof(void*)); @@ -4042,7 +4309,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ my_copy_static_variables */ -+static HashTable* my_copy_static_variables(zend_op_array* src, apc_context_t* ctxt) ++static HashTable* my_copy_static_variables(zend_op_array* src, apc_context_t* ctxt TSRMLS_DC) +{ + if (src->static_variables == NULL) { + return NULL; @@ -4057,7 +4324,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ apc_copy_zval */ -+zval* apc_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt) ++zval* apc_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC) +{ + apc_pool* pool = ctxt->pool; + int usegc = (ctxt->copy == APC_COPY_OUT_OPCODE) || (ctxt->copy == APC_COPY_OUT_USER); @@ -4073,7 +4340,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + } + } + -+ CHECK(dst = my_copy_zval(dst, src, ctxt)); ++ CHECK(dst = my_copy_zval(dst, src, ctxt TSRMLS_CC)); + return dst; +} +/* }}} */ @@ -4087,9 +4354,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + zend_op *zo = &(dst->opcodes[i]); + /*convert opline number to jump address*/ + switch (zo->opcode) { ++#ifdef ZEND_ENGINE_2_3 ++ case ZEND_GOTO: ++#endif + case ZEND_JMP: + /*Note: if src->opcodes != dst->opcodes then we need to the opline according to src*/ ++#ifdef ZEND_ENGINE_2_4 ++ zo->op1.jmp_addr = dst->opcodes + (zo->op1.jmp_addr - src->opcodes); ++#else + zo->op1.u.jmp_addr = dst->opcodes + (zo->op1.u.jmp_addr - src->opcodes); ++#endif + break; + case ZEND_JMPZ: + case ZEND_JMPNZ: @@ -4098,7 +4372,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +#ifdef ZEND_ENGINE_2_3 + case ZEND_JMP_SET: +#endif ++#ifdef ZEND_ENGINE_2_4 ++ zo->op2.jmp_addr = dst->opcodes + (zo->op2.jmp_addr - src->opcodes); ++#else + zo->op2.u.jmp_addr = dst->opcodes + (zo->op2.u.jmp_addr - src->opcodes); ++#endif + break; + default: + break; @@ -4111,7 +4389,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_context_t* ctxt TSRMLS_DC) +{ + int i; -+ apc_fileinfo_t fileinfo; ++ apc_fileinfo_t *fileinfo = NULL; + char canon_path[MAXPATHLEN]; + char *fullpath = NULL; + apc_opflags_t * flags = NULL; @@ -4148,35 +4426,54 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + CHECK(dst->arg_info = my_copy_arg_info_array(NULL, + src->arg_info, + src->num_args, -+ ctxt)); ++ ctxt TSRMLS_CC)); + } + + if (src->function_name) { -+ CHECK(dst->function_name = apc_pstrdup(src->function_name, pool)); ++ CHECK(dst->function_name = apc_pstrdup(src->function_name, pool TSRMLS_CC)); + } + if (src->filename) { -+ CHECK(dst->filename = apc_pstrdup(src->filename, pool)); ++ CHECK(dst->filename = apc_pstrdup(src->filename, pool TSRMLS_CC)); + } + + CHECK(dst->refcount = apc_pmemcpy(src->refcount, + sizeof(src->refcount[0]), -+ pool)); ++ pool TSRMLS_CC)); ++ ++#ifdef ZEND_ENGINE_2_4 ++ if (src->literals) { ++ zend_literal *p, *q, *end; ++ ++ q = src->literals; ++ p = dst->literals = (zend_literal*) apc_pool_alloc(pool, (sizeof(zend_literal) * src->last_literal)); ++ end = p + src->last_literal; ++ while (p < end) { ++ *p = *q; ++ my_copy_zval(&p->constant, &q->constant, ctxt TSRMLS_CC); ++ p++; ++ q++; ++ } ++ } ++#endif + + /* deep-copy the opcodes */ -+ CHECK(dst->opcodes = (zend_op*) apc_pool_alloc(pool, sizeof(zend_op) * src->last)); ++ CHECK(dst->opcodes = (zend_op*) apc_pool_alloc(pool, (sizeof(zend_op) * src->last))); + + if(apc_reserved_offset != -1) { + /* Insanity alert: the void* pointer is cast into an apc_opflags_t + * struct. apc_zend_init() checks to ensure that it fits in a void* */ + flags = (apc_opflags_t*) & (dst->reserved[apc_reserved_offset]); + memset(flags, 0, sizeof(apc_opflags_t)); -+ /* assert(sizeof(apc_opflags_t) < sizeof(dst->reserved)); */ ++ /* assert(sizeof(apc_opflags_t) <= sizeof(dst->reserved)); */ + } + + for (i = 0; (uint) i < src->last; i++) { + zend_op *zo = &(src->opcodes[i]); + /* a lot of files are merely constant arrays with no jumps */ + switch (zo->opcode) { ++#ifdef ZEND_ENGINE_2_3 ++ case ZEND_GOTO: ++#endif + case ZEND_JMP: + case ZEND_JMPZ: + case ZEND_JMPNZ: @@ -4194,17 +4491,29 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + case ZEND_FETCH_W: + case ZEND_FETCH_IS: + case ZEND_FETCH_FUNC_ARG: ++ case ZEND_FETCH_RW: ++ case ZEND_FETCH_UNSET: + if(PG(auto_globals_jit) && flags != NULL) + { + /* The fetch is only required if auto_globals_jit=1 */ ++#ifdef ZEND_ENGINE_2_4 ++ if((zo->extended_value & ZEND_FETCH_TYPE_MASK) == ZEND_FETCH_GLOBAL && ++ zo->op1_type == IS_CONST && ++ Z_TYPE_P(zo->op1.zv) == IS_STRING) { ++ if (Z_STRVAL_P(zo->op1.zv)[0] == '_') { ++# define SET_IF_AUTOGLOBAL(member) \ ++ if(!strcmp(Z_STRVAL_P(zo->op1.zv), #member)) \ ++ flags->member = 1 /* no ';' here */ ++#else + if(zo->op2.u.EA.type == ZEND_FETCH_GLOBAL && + zo->op1.op_type == IS_CONST && + zo->op1.u.constant.type == IS_STRING) { + znode * varname = &zo->op1; + if (varname->u.constant.value.str.val[0] == '_') { -+#define SET_IF_AUTOGLOBAL(member) \ ++# define SET_IF_AUTOGLOBAL(member) \ + if(!strcmp(varname->u.constant.value.str.val, #member)) \ + flags->member = 1 /* no ';' here */ ++#endif + SET_IF_AUTOGLOBAL(_GET); + else SET_IF_AUTOGLOBAL(_POST); + else SET_IF_AUTOGLOBAL(_COOKIE); @@ -4212,30 +4521,54 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + else SET_IF_AUTOGLOBAL(_ENV); + else SET_IF_AUTOGLOBAL(_FILES); + else SET_IF_AUTOGLOBAL(_REQUEST); ++ else SET_IF_AUTOGLOBAL(_SESSION); ++#ifdef ZEND_ENGINE_2_4 ++ else if(zend_is_auto_global( ++ Z_STRVAL_P(zo->op1.zv), ++ Z_STRLEN_P(zo->op1.zv) ++ TSRMLS_CC)) ++#else + else if(zend_is_auto_global( + varname->u.constant.value.str.val, + varname->u.constant.value.str.len + TSRMLS_CC)) ++#endif + { + flags->unknown_global = 1; + } ++#ifdef ZEND_ENGINE_2_4 ++ } else SET_IF_AUTOGLOBAL(GLOBALS); ++#else + } ++#endif + } + } + break; + case ZEND_RECV_INIT: ++#ifdef ZEND_ENGINE_2_4 ++ if(zo->op2_type == IS_CONST && ++ Z_TYPE_P(zo->op2.zv) == IS_CONSTANT_ARRAY) { ++#else + if(zo->op2.op_type == IS_CONST && + zo->op2.u.constant.type == IS_CONSTANT_ARRAY) { ++#endif + if(flags != NULL) { + flags->deep_copy = 1; + } + } + break; + default: ++#ifdef ZEND_ENGINE_2_4 ++ if((zo->op1_type == IS_CONST && ++ Z_TYPE_P(zo->op1.zv) == IS_CONSTANT_ARRAY) || ++ (zo->op2_type == IS_CONST && ++ Z_TYPE_P(zo->op2.zv) == IS_CONSTANT_ARRAY)) { ++#else + if((zo->op1.op_type == IS_CONST && + zo->op1.u.constant.type == IS_CONSTANT_ARRAY) || + (zo->op2.op_type == IS_CONST && + zo->op2.u.constant.type == IS_CONSTANT_ARRAY)) { ++#endif + if(flags != NULL) { + flags->deep_copy = 1; + } @@ -4243,26 +4576,58 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + break; + } + -+ if(!(my_copy_zend_op(dst->opcodes+i, src->opcodes+i, ctxt))) { ++ if(!(my_copy_zend_op(dst->opcodes+i, src->opcodes+i, ctxt TSRMLS_CC))) { + return NULL; + } + -+/* This code breaks apc's rule#1 - cache what you compile */ ++#ifdef ZEND_ENGINE_2_4 ++ if (zo->op1_type == IS_CONST) { ++ dst->opcodes[i].op1.literal = src->opcodes[i].op1.literal - src->literals + dst->literals; ++ } ++ if (zo->op2_type == IS_CONST) { ++ dst->opcodes[i].op2.literal = src->opcodes[i].op2.literal - src->literals + dst->literals; ++ } ++ if (zo->result_type == IS_CONST) { ++ dst->opcodes[i].result.literal = src->opcodes[i].result.literal - src->literals + dst->literals; ++ } ++#endif ++ ++ /* This code breaks apc's rule#1 - cache what you compile */ + if((APCG(fpstat)==0) && APCG(canonicalize)) { ++ /* not pool allocated, because the pool allocations eat up shm space */ ++ fileinfo = (apc_fileinfo_t*) apc_php_malloc(sizeof(apc_fileinfo_t) TSRMLS_CC); ++#ifdef ZEND_ENGINE_2_4 ++ if((zo->opcode == ZEND_INCLUDE_OR_EVAL) && ++ (zo->op1_type == IS_CONST && Z_TYPE_P(zo->op1.zv) == IS_STRING)) { ++ /* constant includes */ ++ if(!IS_ABSOLUTE_PATH(Z_STRVAL_P(zo->op1.zv),Z_STRLEN_P(zo->op1.zv))) { ++ if (apc_search_paths(Z_STRVAL_P(zo->op1.zv), PG(include_path), fileinfo TSRMLS_CC) == 0) { ++#else + if((zo->opcode == ZEND_INCLUDE_OR_EVAL) && + (zo->op1.op_type == IS_CONST && zo->op1.u.constant.type == IS_STRING)) { + /* constant includes */ + if(!IS_ABSOLUTE_PATH(Z_STRVAL_P(&zo->op1.u.constant),Z_STRLEN_P(&zo->op1.u.constant))) { -+ if (apc_search_paths(Z_STRVAL_P(&zo->op1.u.constant), PG(include_path), &fileinfo) == 0) { -+ if((fullpath = realpath(fileinfo.fullpath, canon_path))) { ++ if (apc_search_paths(Z_STRVAL_P(&zo->op1.u.constant), PG(include_path), fileinfo TSRMLS_CC) == 0) { ++#endif ++ if((fullpath = realpath(fileinfo->fullpath, canon_path))) { + /* everything has to go through a realpath() */ + zend_op *dzo = &(dst->opcodes[i]); ++#ifdef ZEND_ENGINE_2_4 ++ dzo->op1.literal = (zend_literal*) apc_pool_alloc(pool, sizeof(zend_literal)); ++ Z_STRLEN_P(dzo->op1.zv) = strlen(fullpath); ++ Z_STRVAL_P(dzo->op1.zv) = apc_pstrdup(fullpath, pool TSRMLS_CC); ++ Z_SET_REFCOUNT_P(dzo->op1.zv, 2); ++ Z_SET_ISREF_P(dzo->op1.zv); ++ dzo->op1.literal->hash_value = zend_hash_func(Z_STRVAL_P(dzo->op1.zv), Z_STRLEN_P(dzo->op1.zv)+1); ++#else + dzo->op1.u.constant.value.str.len = strlen(fullpath); -+ dzo->op1.u.constant.value.str.val = apc_pstrdup(fullpath, pool); ++ dzo->op1.u.constant.value.str.val = apc_pstrdup(fullpath, pool TSRMLS_CC); ++#endif + } + } + } + } ++ apc_php_free(fileinfo TSRMLS_CC); + } + } + @@ -4274,39 +4639,39 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + if (src->brk_cont_array) { + CHECK(dst->brk_cont_array = apc_pmemcpy(src->brk_cont_array, + sizeof(src->brk_cont_array[0]) * src->last_brk_cont, -+ pool)); ++ pool TSRMLS_CC)); + } + + /* copy the table of static variables */ + if (src->static_variables) { -+ CHECK(dst->static_variables = my_copy_static_variables(src, ctxt)); ++ CHECK(dst->static_variables = my_copy_static_variables(src, ctxt TSRMLS_CC)); + } + + if (src->try_catch_array) { + CHECK(dst->try_catch_array = apc_pmemcpy(src->try_catch_array, + sizeof(src->try_catch_array[0]) * src->last_try_catch, -+ pool)); ++ pool TSRMLS_CC)); + } + +#ifdef ZEND_ENGINE_2_1 /* PHP 5.1 */ + if (src->vars) { + CHECK(dst->vars = apc_pmemcpy(src->vars, + sizeof(src->vars[0]) * src->last_var, -+ pool)); ++ pool TSRMLS_CC)); + + for(i = 0; i < src->last_var; i++) dst->vars[i].name = NULL; + + for(i = 0; i < src->last_var; i++) { -+ CHECK(dst->vars[i].name = apc_pmemcpy(src->vars[i].name, ++ CHECK(dst->vars[i].name = apc_string_pmemcpy(src->vars[i].name, + src->vars[i].name_len + 1, -+ pool)); ++ pool TSRMLS_CC)); + } + } +#endif + + if (src->doc_comment) { + CHECK(dst->doc_comment -+ = apc_pmemcpy(src->doc_comment, src->doc_comment_len+1, pool)); ++ = apc_pmemcpy(src->doc_comment, (src->doc_comment_len + 1), pool TSRMLS_CC)); + } + + return dst; @@ -4327,7 +4692,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + CHECK(array = + (apc_function_t*) -+ apc_pool_alloc(pool, sizeof(apc_function_t) * (new_count+1))); ++ apc_pool_alloc(pool, (sizeof(apc_function_t) * (new_count + 1)))); + + if (new_count == 0) { + array[0].function = NULL; @@ -4355,9 +4720,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + zend_hash_get_current_data(CG(function_table), (void**) &fun); + -+ CHECK(array[i].name = apc_pmemcpy(key, (int) key_size, pool)); ++ CHECK(array[i].name = apc_pmemcpy(key, (int) key_size, pool TSRMLS_CC)); + array[i].name_len = (int) key_size-1; -+ CHECK(array[i].function = my_copy_function(NULL, fun, ctxt)); ++ CHECK(array[i].function = my_copy_function(NULL, fun, ctxt TSRMLS_CC)); + zend_hash_move_forward(CG(function_table)); + } + @@ -4379,7 +4744,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + CHECK(array = + (apc_class_t*) -+ apc_pool_alloc(pool, sizeof(apc_class_t)*(new_count+1))); ++ apc_pool_alloc(pool, (sizeof(apc_class_t) * (new_count + 1)))); + + if (new_count == 0) { + array[0].class_entry = NULL; @@ -4412,9 +4777,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + elem = *((zend_class_entry**)elem); + -+ CHECK(array[i].name = apc_pmemcpy(key, (int) key_size, pool)); ++ CHECK(array[i].name = apc_pmemcpy(key, (int) key_size, pool TSRMLS_CC)); + array[i].name_len = (int) key_size-1; -+ CHECK(array[i].class_entry = my_copy_class_entry(NULL, elem, ctxt)); ++ CHECK(array[i].class_entry = my_copy_class_entry(NULL, elem, ctxt TSRMLS_CC)); + + /* + * If the class has a pointer to its parent class, save the parent @@ -4425,7 +4790,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + */ + + if (elem->parent) { -+ CHECK(array[i].parent_name = apc_pstrdup(elem->parent->name, pool)); ++ CHECK(array[i].parent_name = apc_pstrdup(elem->parent->name, pool TSRMLS_CC)); + } + else { + array[i].parent_name = NULL; @@ -4440,7 +4805,19 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* Used only by my_prepare_op_array_for_execution */ -+#define APC_PREPARE_FETCH_GLOBAL_FOR_EXECUTION() \ ++#ifdef ZEND_ENGINE_2_4 ++# define APC_PREPARE_FETCH_GLOBAL_FOR_EXECUTION() \ ++ /* The fetch is only required if auto_globals_jit=1 */ \ ++ if((zo->extended_value & ZEND_FETCH_TYPE_MASK) == ZEND_FETCH_GLOBAL && \ ++ zo->op1_type == IS_CONST && \ ++ Z_TYPE_P(zo->op1.zv) == IS_STRING && \ ++ Z_STRVAL_P(zo->op1.zv)[0] == '_') { \ ++ (void)zend_is_auto_global(Z_STRVAL_P(zo->op1.zv), \ ++ Z_STRLEN_P(zo->op1.zv) \ ++ TSRMLS_CC); \ ++ } ++#else ++# define APC_PREPARE_FETCH_GLOBAL_FOR_EXECUTION() \ + /* The fetch is only required if auto_globals_jit=1 */ \ + if(zo->op2.u.EA.type == ZEND_FETCH_GLOBAL && \ + zo->op1.op_type == IS_CONST && \ @@ -4451,7 +4828,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + (void)zend_is_auto_global(varname->u.constant.value.str.val, \ + varname->u.constant.value.str.len \ + TSRMLS_CC); \ -+ } \ ++ } ++#endif + +/* {{{ my_prepare_op_array_for_execution */ +static int my_prepare_op_array_for_execution(zend_op_array* dst, zend_op_array* src, apc_context_t* ctxt TSRMLS_DC) @@ -4485,30 +4863,73 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + FETCH_AUTOGLOBAL(_ENV); + FETCH_AUTOGLOBAL(_FILES); + FETCH_AUTOGLOBAL(_REQUEST); ++ FETCH_AUTOGLOBAL(_SESSION); ++#ifdef ZEND_ENGINE_2_4 ++ FETCH_AUTOGLOBAL(GLOBALS); ++#endif + + if(needcopy) { + ++#ifdef ZEND_ENGINE_2_4 ++ if (src->literals) { ++ zend_literal *p, *q, *end; ++ ++ q = src->literals; ++ p = dst->literals = (zend_literal*) apc_xmemcpy(src->literals, ++ sizeof(zend_literal) * src->last_literal, ++ apc_php_malloc TSRMLS_CC); ++ end = p + src->last_literal; ++ while (p < end) { ++ if (Z_TYPE(q->constant) == IS_CONSTANT_ARRAY) { ++ my_copy_zval(&p->constant, &q->constant, ctxt TSRMLS_CC); ++ } ++ p++; ++ q++; ++ } ++ } ++#endif ++ + dst->opcodes = (zend_op*) apc_xmemcpy(src->opcodes, + sizeof(zend_op) * src->last, -+ apc_php_malloc); ++ apc_php_malloc TSRMLS_CC); + zo = src->opcodes; + dzo = dst->opcodes; + while(i > 0) { + ++#ifdef ZEND_ENGINE_2_4 ++ if(zo->op1_type == IS_CONST) { ++ dzo->op1.literal = zo->op1.literal - src->literals + dst->literals; ++ } ++ if(zo->op2_type == IS_CONST) { ++ dzo->op2.literal = zo->op2.literal - src->literals + dst->literals; ++ } ++ if(zo->result_type == IS_CONST) { ++ dzo->result.literal = zo->result.literal - src->literals + dst->literals; ++ } ++#else + if( ((zo->op1.op_type == IS_CONST && + zo->op1.u.constant.type == IS_CONSTANT_ARRAY)) || + ((zo->op2.op_type == IS_CONST && + zo->op2.u.constant.type == IS_CONSTANT_ARRAY))) { + -+ if(!(my_copy_zend_op(dzo, zo, ctxt))) { ++ if(!(my_copy_zend_op(dzo, zo, ctxt TSRMLS_CC))) { + assert(0); /* emalloc failed or a bad constant array */ + } + } ++#endif + + switch(zo->opcode) { ++#ifdef ZEND_ENGINE_2_3 ++ case ZEND_GOTO: ++#endif + case ZEND_JMP: ++#ifdef ZEND_ENGINE_2_4 ++ dzo->op1.jmp_addr = dst->opcodes + ++ (zo->op1.jmp_addr - src->opcodes); ++#else + dzo->op1.u.jmp_addr = dst->opcodes + + (zo->op1.u.jmp_addr - src->opcodes); ++#endif + break; + case ZEND_JMPZ: + case ZEND_JMPNZ: @@ -4517,8 +4938,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +#ifdef ZEND_ENGINE_2_3 + case ZEND_JMP_SET: +#endif ++#ifdef ZEND_ENGINE_2_4 ++ dzo->op2.jmp_addr = dst->opcodes + ++ (zo->op2.jmp_addr - src->opcodes); ++#else + dzo->op2.u.jmp_addr = dst->opcodes + + (zo->op2.u.jmp_addr - src->opcodes); ++#endif + break; + case ZEND_FETCH_R: + case ZEND_FETCH_W: @@ -4567,12 +4993,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + dst = (zend_op_array*) emalloc(sizeof(src[0])); + } + memcpy(dst, src, sizeof(src[0])); -+ dst->static_variables = my_copy_static_variables(src, ctxt); ++ dst->static_variables = my_copy_static_variables(src, ctxt TSRMLS_CC); + + /* memory leak */ + dst->refcount = apc_pmemcpy(src->refcount, + sizeof(src->refcount[0]), -+ ctxt->pool); ++ ctxt->pool TSRMLS_CC); + + my_prepare_op_array_for_execution(dst,src, ctxt TSRMLS_CC); + @@ -4581,10 +5007,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ apc_copy_function_for_execution */ -+zend_function* apc_copy_function_for_execution(zend_function* src, apc_context_t* ctxt) ++zend_function* apc_copy_function_for_execution(zend_function* src, apc_context_t* ctxt TSRMLS_DC) +{ + zend_function* dst; -+ TSRMLS_FETCH(); + + dst = (zend_function*) emalloc(sizeof(src[0])); + memcpy(dst, src, sizeof(src[0])); @@ -4594,16 +5019,19 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ apc_copy_function_for_execution_ex */ -+zend_function* apc_copy_function_for_execution_ex(void *dummy, zend_function* src, apc_context_t* ctxt) ++zend_function* apc_copy_function_for_execution_ex(void *dummy, zend_function* src, apc_context_t* ctxt TSRMLS_DC) +{ + if(src->type==ZEND_INTERNAL_FUNCTION || src->type==ZEND_OVERLOADED_FUNCTION) return src; -+ return apc_copy_function_for_execution(src, ctxt); ++ return apc_copy_function_for_execution(src, ctxt TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_copy_class_entry_for_execution */ -+zend_class_entry* apc_copy_class_entry_for_execution(zend_class_entry* src, apc_context_t* ctxt) ++zend_class_entry* apc_copy_class_entry_for_execution(zend_class_entry* src, apc_context_t* ctxt TSRMLS_DC) +{ ++#ifdef ZEND_ENGINE_2_4 ++ int i; ++#endif + zend_class_entry* dst = (zend_class_entry*) apc_pool_alloc(ctxt->pool, sizeof(src[0])); + memcpy(dst, src, sizeof(src[0])); + @@ -4611,7 +5039,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + { + /* These are slots to be populated later by ADD_INTERFACE insns */ + dst->interfaces = apc_php_malloc( -+ sizeof(zend_class_entry*) * src->num_interfaces); ++ (sizeof(zend_class_entry*) * src->num_interfaces) TSRMLS_CC); + memset(dst->interfaces, 0, + sizeof(zend_class_entry*) * src->num_interfaces); + } @@ -4622,11 +5050,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + + /* Deep-copy the class properties, because they will be modified */ + ++#ifdef ZEND_ENGINE_2_4 ++ dst->default_properties_count = src->default_properties_count; ++ if (src->default_properties_count) { ++ dst->default_properties_table = (zval**) apc_php_malloc((sizeof(zval*) * src->default_properties_count) TSRMLS_CC); ++ for (i = 0; i < src->default_properties_count; i++) { ++ if (src->default_properties_table[i]) { ++ my_copy_zval_ptr(&dst->default_properties_table[i], (const zval**)&src->default_properties_table[i], ctxt TSRMLS_CC); ++ } else { ++ dst->default_properties_table[i] = NULL; ++ } ++ } ++ } else { ++ dst->default_properties_table = NULL; ++ } ++#else + my_copy_hashtable(&dst->default_properties, + &src->default_properties, + (ht_copy_fun_t) my_copy_zval_ptr, + 1, + ctxt); ++#endif + + /* For derived classes, we must also copy the function hashtable (although + * we can merely bitwise copy the functions it contains) */ @@ -4663,6 +5107,22 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + 1, + ctxt); + ++#ifdef ZEND_ENGINE_2_4 ++ dst->default_static_members_count = src->default_static_members_count; ++ if (src->default_static_members_count) { ++ dst->default_static_members_table = (zval**) apc_php_malloc((sizeof(zval*) * src->default_static_members_count) TSRMLS_CC); ++ for (i = 0; i < src->default_static_members_count; i++) { ++ if (src->default_static_members_table[i]) { ++ my_copy_zval_ptr(&dst->default_static_members_table[i], (const zval**)&src->default_static_members_table[i], ctxt TSRMLS_CC); ++ } else { ++ dst->default_static_members_table[i] = NULL; ++ } ++ } ++ } else { ++ dst->default_static_members_table = NULL; ++ } ++ dst->static_members_table = dst->default_static_members_table; ++#else + my_copy_hashtable(&dst->default_static_members, + &src->default_static_members, + (ht_copy_fun_t) my_copy_zval_ptr, @@ -4681,34 +5141,59 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + { + dst->static_members = &(dst->default_static_members); + } -+ ++#endif + + return dst; +} +/* }}} */ + +/* {{{ apc_free_class_entry_after_execution */ -+void apc_free_class_entry_after_execution(zend_class_entry* src) ++void apc_free_class_entry_after_execution(zend_class_entry* src TSRMLS_DC) +{ + if(src->num_interfaces > 0 && src->interfaces) { -+ apc_php_free(src->interfaces); ++ apc_php_free(src->interfaces TSRMLS_CC); + src->interfaces = NULL; + src->num_interfaces = 0; + } + /* my_destroy_hashtable() does not play nice with refcounts */ + ++#ifdef ZEND_ENGINE_2_4 ++ if (src->default_static_members_table) { ++ int i; ++ ++ for (i = 0; i < src->default_static_members_count; i++) { ++ zval_ptr_dtor(&src->default_static_members_table[i]); ++ } ++ efree(src->default_static_members_table); ++ src->default_static_members_table = NULL; ++ } ++ src->static_members_table = NULL; ++ if (src->default_properties_table) { ++ int i; ++ ++ for (i = 0; i < src->default_properties_count; i++) { ++ if (src->default_properties_table[i]) { ++ zval_ptr_dtor(&src->default_properties_table[i]); ++ } ++ } ++ efree(src->default_properties_table); ++ src->default_properties_table = NULL; ++ } ++#else + zend_hash_clean(&src->default_static_members); + if(src->static_members != &(src->default_static_members)) + { + zend_hash_destroy(src->static_members); -+ apc_php_free(src->static_members); ++ apc_php_free(src->static_members TSRMLS_CC); + src->static_members = NULL; + } + else + { + src->static_members = NULL; + } ++ + zend_hash_clean(&src->default_properties); ++#endif + zend_hash_clean(&src->constants_table); + + /* TODO: more cleanup */ @@ -4716,14 +5201,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +/* }}} */ + +/* {{{ apc_file_halt_offset */ -+long apc_file_halt_offset(const char *filename) ++long apc_file_halt_offset(const char *filename TSRMLS_DC) +{ + zend_constant *c; + char *name; + int len; + char haltoff[] = "__COMPILER_HALT_OFFSET__"; + long value = -1; -+ TSRMLS_FETCH(); + + zend_mangle_property_name(&name, &len, haltoff, sizeof(haltoff) - 1, filename, strlen(filename), 0); + @@ -4856,6 +5340,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +} +/* }}} */ + ++#ifndef ZEND_ENGINE_2_4 +/* {{{ my_check_copy_default_property */ +static int my_check_copy_default_property(Bucket* p, va_list args) +{ @@ -4878,7 +5363,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + return 1; +} +/* }}} */ -+ ++#endif + +/* {{{ my_check_copy_property_info */ +static int my_check_copy_property_info(Bucket* p, va_list args) @@ -4915,6 +5400,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c +} +/* }}} */ + ++#ifndef ZEND_ENGINE_2_4 +/* {{{ my_check_copy_static_member */ +static int my_check_copy_static_member(Bucket* p, va_list args) +{ @@ -4950,16 +5436,6 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + (zend_hash_find(&src->properties_info, member_name, + strlen(member_name)+1, (void**)&child_info) == SUCCESS)) + { -+ if(child_info->flags & ZEND_ACC_STATIC && -+ (parent_info->flags & ZEND_ACC_PROTECTED && -+ child_info->flags & ZEND_ACC_PUBLIC)) -+ { -+ /* Do not copy into static_members. zend_do_inheritance -+ * will automatically insert a NULL value. -+ * TODO: decrement refcount or fixup when copying out for exec ? -+ */ -+ return 0; -+ } + if(ht == &(src->default_static_members)) + { + parent_ht = &parent->default_static_members; @@ -4983,6 +5459,30 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + return 1; +} +/* }}} */ ++#endif ++ ++/* {{{ my_check_copy_constant */ ++static int my_check_copy_constant(Bucket* p, va_list args) ++{ ++ zend_class_entry* src = va_arg(args, zend_class_entry*); ++ zend_class_entry* parent = src->parent; ++ zval ** child_const = (zval**)p->pData; ++ zval ** parent_const = NULL; ++ ++ if (parent && ++ zend_hash_quick_find(&parent->constants_table, p->arKey, ++ p->nKeyLength, p->h, (void **) &parent_const)==SUCCESS) { ++ ++ if((parent_const && child_const) && (*parent_const) == (*child_const)) ++ { ++ return 0; ++ } ++ } ++ ++ /* possibly not in the parent */ ++ return 1; ++} ++/* }}} */ + +/* {{{ apc_register_optimizer(apc_optimize_function_t optimizer) + * register a optimizer callback function, returns the previous callback @@ -5002,15 +5502,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.c php-5.3.1/ext/apc/apc_compile.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h ---- php-5.3.1.orig/ext/apc/apc_compile.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_compile.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,142 @@ +--- /dev/null ++++ b/ext/apc/apc_compile.h +@@ -0,0 +1,146 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5035,7 +5534,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h + + */ + -+/* $Id: apc_compile.h 275218 2009-02-05 13:16:06Z gopalv $ */ ++/* $Id: apc_compile.h 303388 2010-09-15 09:50:28Z dmitry $ */ + +#ifndef APC_COMPILE_H +#define APC_COMPILE_H @@ -5083,6 +5582,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h + unsigned int _ENV : 1; + unsigned int _FILES : 1; + unsigned int _REQUEST : 1; ++ unsigned int _SESSION : 1; ++#ifdef ZEND_ENGINE_2_4 ++ unsigned int GLOBALS : 1; ++#endif + unsigned int unknown_global : 1; +}; +/* }}} */ @@ -5092,10 +5595,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h + */ + +extern zend_op_array* apc_copy_op_array(zend_op_array* dst, zend_op_array* src, apc_context_t* ctxt TSRMLS_DC); -+extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt); ++extern zend_class_entry* apc_copy_class_entry(zend_class_entry* dst, zend_class_entry* src, apc_context_t* ctxt TSRMLS_DC); +extern apc_function_t* apc_copy_new_functions(int old_count, apc_context_t* ctxt TSRMLS_DC); +extern apc_class_t* apc_copy_new_classes(zend_op_array* op_array, int old_count, apc_context_t* ctxt TSRMLS_DC); -+extern zval* apc_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt); ++extern zval* apc_copy_zval(zval* dst, const zval* src, apc_context_t* ctxt TSRMLS_DC); + +#if 0 +/* @@ -5116,15 +5619,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h + */ + +extern zend_op_array* apc_copy_op_array_for_execution(zend_op_array* dst, zend_op_array* src, apc_context_t* ctxt TSRMLS_DC); -+extern zend_function* apc_copy_function_for_execution(zend_function* src, apc_context_t* ctxt); -+extern zend_class_entry* apc_copy_class_entry_for_execution(zend_class_entry* src, apc_context_t* ctxt); ++extern zend_function* apc_copy_function_for_execution(zend_function* src, apc_context_t* ctxt TSRMLS_DC); ++extern zend_class_entry* apc_copy_class_entry_for_execution(zend_class_entry* src, apc_context_t* ctxt TSRMLS_DC); + +/* + * The "free-after-execution" function performs a cursory clean up of the class data + * This is required to minimize memory leak warnings and to ensure correct destructor + * ordering of some variables. + */ -+extern void apc_free_class_entry_after_execution(zend_class_entry* src); ++extern void apc_free_class_entry_after_execution(zend_class_entry* src TSRMLS_DC); + +/* + * Optimization callback definition and registration function. @@ -5135,7 +5638,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h +/* + * To handle __COMPILER_HALT_OFFSET__ + */ -+long apc_file_halt_offset(const char* filename); ++long apc_file_halt_offset(const char* filename TSRMLS_DC); +void apc_do_halt_compiler_register(const char *filename, long halt_offset TSRMLS_DC); + +#endif @@ -5148,15 +5651,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_compile.h php-5.3.1/ext/apc/apc_compile.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_debug.c php-5.3.1/ext/apc/apc_debug.c ---- php-5.3.1.orig/ext/apc/apc_debug.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_debug.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,57 @@ +--- /dev/null ++++ b/ext/apc/apc_debug.c +@@ -0,0 +1,70 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5180,14 +5682,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_debug.c php-5.3.1/ext/apc/apc_debug.c + All other licensing and usage conditions are those of the PHP Group. +*/ + -+/* $Id: apc_debug.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_debug.c 304107 2010-10-05 15:14:06Z kalle $ */ +#include "apc.h" +#include ++#include "zend.h" +#include "zend_compile.h" + -+#ifdef __DEBUG_APC__ -+ -+#include ++#if defined(__DEBUG_APC__) + +/* keep track of vld_dump_oparray() signature */ +typedef void (*vld_dump_f) (zend_op_array * TSRMLS_DC); @@ -5196,244 +5697,73 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_debug.c php-5.3.1/ext/apc/apc_debug.c + +void dump(zend_op_array *op_array TSRMLS_DC) +{ -+#ifdef __DEBUG_APC__ -+ vld_dump_f dump_op_array = dlsym(NULL, "vld_dump_oparray"); ++#if defined(__DEBUG_APC__) ++ vld_dump_f dump_op_array; ++ DL_HANDLE handle = NULL; + -+ if(dump_op_array) -+ { -+ dump_op_array(op_array TSRMLS_CC); ++#ifdef PHP_WIN32 ++ handle = GetModuleHandle(NULL); ++ ++ if (!handle) { ++ apc_warning("unable to fetch current module handle." TSRMLS_CC); + } -+ else -+ { -+ apc_wprint("vld is not installed or something even worse."); ++#endif ++ ++ dump_op_array = (vld_dump_f) DL_FETCH_SYMBOL(handle, "vld_dump_oparray"); ++ ++#ifdef PHP_WIN32 ++ DL_UNLOAD(handle); ++#endif ++ ++ if(dump_op_array) { ++ dump_op_array(op_array TSRMLS_CC); ++ ++ return; + } ++ ++ apc_warning("vld is not installed or something even worse." TSRMLS_CC); +#endif +} -diff -Naur php-5.3.1.orig/ext/apc/apc_debug.h php-5.3.1/ext/apc/apc_debug.h ---- php-5.3.1.orig/ext/apc/apc_debug.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_debug.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1 @@ -+void dump(zend_op_array * TSRMLS_DC); -diff -Naur php-5.3.1.orig/ext/apc/apc.dsp php-5.3.1/ext/apc/apc.dsp ---- php-5.3.1.orig/ext/apc/apc.dsp 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc.dsp 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,207 @@ -+# Microsoft Developer Studio Project File - Name="apc" - Package Owner=<4> -+# Microsoft Developer Studio Generated Build File, Format Version 6.00 -+# ** DO NOT EDIT ** -+ -+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 -+ -+CFG=apc - Win32 Debug_TS -+!MESSAGE This is not a valid makefile. To build this project using NMAKE, -+!MESSAGE use the Export Makefile command and run -+!MESSAGE -+!MESSAGE NMAKE /f "apc.mak". -+!MESSAGE -+!MESSAGE You can specify a configuration when running NMAKE -+!MESSAGE by defining the macro CFG on the command line. For example: -+!MESSAGE -+!MESSAGE NMAKE /f "apc.mak" CFG="apc - Win32 Debug_TS" -+!MESSAGE -+!MESSAGE Possible choices for configuration are: -+!MESSAGE -+!MESSAGE "apc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") -+!MESSAGE "apc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") -+!MESSAGE -+ -+# Begin Project -+# PROP AllowPerConfigDependencies 0 -+# PROP Scc_ProjName "" -+# PROP Scc_LocalPath "" -+CPP=cl.exe -+MTL=midl.exe -+RSC=rc.exe -+ -+!IF "$(CFG)" == "apc - Win32 Debug_TS" -+ -+# PROP BASE Use_MFC 0 -+# PROP BASE Use_Debug_Libraries 1 -+# PROP BASE Output_Dir "Debug_TS" -+# PROP BASE Intermediate_Dir "Debug_TS" -+# PROP BASE Target_Dir "" -+# PROP Use_MFC 0 -+# PROP Use_Debug_Libraries 1 -+# PROP Output_Dir "Debug_TS" -+# PROP Intermediate_Dir "Debug_TS" -+# PROP Ignore_Export_Lib 0 -+# PROP Target_Dir "" -+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APC_EXPORTS" /YX /FD /GZ /c -+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\php4" /I "..\..\..\php4\main" /I "..\..\..\php4\Zend" /I "..\..\..\php4\TSRM" /I "..\..\..\php4\win32" /I "..\..\..\php4\regex" /D "TSRM_LOCKS" /D HAVE_APC=1 /D "COMPILE_DL_APC" /D ZEND_DEBUG=1 /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APC_EXPORTS" /YX /FD /GZ /c -+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -+# ADD BASE RSC /l 0x409 /d "_DEBUG" -+# ADD RSC /l 0x409 /d "_DEBUG" -+BSC32=bscmake.exe -+# ADD BASE BSC32 /nologo -+# ADD BSC32 /nologo -+LINK32=link.exe -+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -+# ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug_TS/php_apc.dll" /pdbtype:sept /libpath:"..\..\..\php4\Debug_TS" -+ -+!ELSEIF "$(CFG)" == "apc - Win32 Release_TS" -+ -+# PROP BASE Use_MFC 0 -+# PROP BASE Use_Debug_Libraries 0 -+# PROP BASE Output_Dir "Release_TS" -+# PROP BASE Intermediate_Dir "Release_TS" -+# PROP BASE Target_Dir "" -+# PROP Use_MFC 0 -+# PROP Use_Debug_Libraries 0 -+# PROP Output_Dir "Release_TS" -+# PROP Intermediate_Dir "Release_TS" -+# PROP Ignore_Export_Lib 0 -+# PROP Target_Dir "" -+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APC_EXPORTS" /YX /FD /c -+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\php4" /I "..\..\..\php4\main" /I "..\..\..\php4\Zend" /I "..\..\..\php4\TSRM" /I "..\..\..\php4\win32" /I "..\..\..\php4\regex" /D "TSRM_LOCKS" /D HAVE_APC=1 /D "COMPILE_DL_APC" /D ZEND_DEBUG=0 /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APC_EXPORTS" /YX /FD /c -+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -+# ADD BASE RSC /l 0x409 /d "NDEBUG" -+# ADD RSC /l 0x409 /d "NDEBUG" -+BSC32=bscmake.exe -+# ADD BASE BSC32 /nologo -+# ADD BSC32 /nologo -+LINK32=link.exe -+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -+# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../Release_TS/php_apc.dll" /libpath:"..\..\..\php4\Release_TS" /libpath:"..\..\..\php4\Release_TS_Inline" -+ -+!ENDIF -+ -+# Begin Target -+ -+# Name "apc - Win32 Debug_TS" -+# Name "apc - Win32 Release_TS" -+# Begin Group "Source Files" -+ -+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -+# Begin Source File -+ -+SOURCE=.\apc.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_cache.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_compile.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_debug.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_fcntl_win32.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_main.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_rfc1867.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_shm.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_sma.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_stack.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_zend.c -+# End Source File -+# Begin Source File -+ -+SOURCE=.\php_apc.c -+# End Source File -+# End Group -+# Begin Group "Header Files" -+ -+# PROP Default_Filter "h;hpp;hxx;hm;inl" -+# Begin Source File -+ -+SOURCE=.\apc.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_cache.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_compile.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_debug.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_fcntl.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_globals.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_lock.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_main.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_php.h -+# End Source File -+# Begin Source File +--- /dev/null ++++ b/ext/apc/apc_debug.h +@@ -0,0 +1,29 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2010 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.txt | ++ | If you did not receive a copy of the PHP license and are unable to | ++ | obtain it through the world-wide-web, please send a note to | ++ | license@php.net so we can mail you a copy immediately. | ++ +----------------------------------------------------------------------+ ++ | Authors: Daniel Cowgill | ++ | Arun C. Murthy | ++ | Gopal Vijayaraghavan | ++ +----------------------------------------------------------------------+ + -+SOURCE=.\apc_shm.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_sma.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_stack.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\apc_zend.h -+# End Source File -+# Begin Source File -+ -+SOURCE=.\php_apc.h -+# End Source File -+# End Group -+# Begin Group "Resource Files" -+ -+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -+# End Group -+# End Target -+# End Project -diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c ---- php-5.2.5-orig/ext/apc/apc_fcntl.c 1969-12-31 18:00:00.000000000 -0600 -+++ php-5.2.5/ext/apc/apc_fcntl.c 2007-12-26 16:51:32.000000000 -0600 -@@ -0,0 +1,118 @@ ++ This software was contributed to PHP by Community Connect Inc. in 2002 ++ and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. ++ Future revisions and derivatives of this source code must acknowledge ++ Community Connect Inc. as the original contributor of this module by ++ leaving this note intact in the source code. ++ ++ All other licensing and usage conditions are those of the PHP Group. ++*/ ++ ++void dump(zend_op_array * TSRMLS_DC); +--- /dev/null ++++ b/ext/apc/apc_fcntl.c +@@ -0,0 +1,123 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5457,7 +5787,7 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c + + */ + -+/* $Id: apc_fcntl.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_fcntl.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc.h" + @@ -5467,7 +5797,7 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c +#include +#include + -+int apc_fcntl_create(const char* pathname) ++int apc_fcntl_create(const char* pathname TSRMLS_DC) +{ + int fd; + if(pathname == NULL) { @@ -5478,7 +5808,7 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c + unlink(lock_path); + return fd; + } else { -+ apc_eprint("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:", lock_path); ++ apc_error("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:" TSRMLS_CC, lock_path); + return -1; + } + } @@ -5487,7 +5817,7 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c + unlink(pathname); + return fd; + } -+ apc_eprint("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:", pathname); ++ apc_error("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:" TSRMLS_CC, pathname); + return -1; +} + @@ -5512,33 +5842,33 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c + return(ret); +} + -+void apc_fcntl_lock(int fd) ++void apc_fcntl_lock(int fd TSRMLS_DC) +{ + if(lock_reg(fd, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) { -+ apc_eprint("apc_fcntl_lock failed:"); ++ apc_error("apc_fcntl_lock failed:" TSRMLS_CC); + } +} + -+void apc_fcntl_rdlock(int fd) ++void apc_fcntl_rdlock(int fd TSRMLS_DC) +{ + if(lock_reg(fd, F_SETLKW, F_RDLCK, 0, SEEK_SET, 0) < 0) { -+ apc_eprint("apc_fcntl_rdlock failed:"); ++ apc_error("apc_fcntl_rdlock failed:" TSRMLS_CC); + } +} + -+zend_bool apc_fcntl_nonblocking_lock(int fd) ++zend_bool apc_fcntl_nonblocking_lock(int fd TSRMLS_DC) +{ + if(lock_reg(fd, F_SETLK, F_WRLCK, 0, SEEK_SET, 0) < 0) { + if(errno==EACCES||errno==EAGAIN) return 0; -+ else apc_eprint("apc_fcntl_lock failed:"); ++ else apc_error("apc_fcntl_lock failed:" TSRMLS_CC); + } + return 1; +} + -+void apc_fcntl_unlock(int fd) ++void apc_fcntl_unlock(int fd TSRMLS_DC) +{ + if(lock_reg(fd, F_SETLKW, F_UNLCK, 0, SEEK_SET, 0) < 0) { -+ apc_eprint("apc_fcntl_unlock failed:"); ++ apc_error("apc_fcntl_unlock failed:" TSRMLS_CC); + } +} + @@ -5552,15 +5882,14 @@ diff -ubrN php-5.2.5-orig/ext/apc/apc_fcntl.c php-5.2.5/ext/apc/apc_fcntl.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl.h php-5.3.1/ext/apc/apc_fcntl.h ---- php-5.3.1.orig/ext/apc/apc_fcntl.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_fcntl.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_fcntl.h @@ -0,0 +1,50 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5584,18 +5913,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl.h php-5.3.1/ext/apc/apc_fcntl.h + + */ + -+/* $Id: apc_fcntl.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_fcntl.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_FCNTL_H +#define APC_FCNTL_H + + -+extern int apc_fcntl_create(const char* pathname); ++extern int apc_fcntl_create(const char* pathname TSRMLS_DC); +extern void apc_fcntl_destroy(int fd); -+extern void apc_fcntl_lock(int fd); -+extern void apc_fcntl_rdlock(int fd); -+extern void apc_fcntl_unlock(int fd); -+extern unsigned char apc_fcntl_nonblocking_lock(int fd); ++extern void apc_fcntl_lock(int fd TSRMLS_DC); ++extern void apc_fcntl_rdlock(int fd TSRMLS_DC); ++extern void apc_fcntl_unlock(int fd TSRMLS_DC); ++extern unsigned char apc_fcntl_nonblocking_lock(int fd TSRMLS_DC); +#endif + +/* @@ -5606,15 +5935,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl.h php-5.3.1/ext/apc/apc_fcntl.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_win32.c ---- php-5.3.1.orig/ext/apc/apc_fcntl_win32.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_fcntl_win32.c 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_fcntl_win32.c @@ -0,0 +1,117 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5638,10 +5966,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ + + */ + -+/* $Id: apc_fcntl_win32.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_fcntl_win32.c 302175 2010-08-13 06:20:28Z kalle $ */ + -+#include "apc_fcntl.h" +#include "apc.h" ++#include "apc_fcntl.h" +#include +#include +#include @@ -5649,7 +5977,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ +#include +#include + -+int apc_fcntl_create(const char* pathname) ++int apc_fcntl_create(const char* pathname TSRMLS_DC) +{ + char *lock_file = emalloc(MAXPATHLEN); + HANDLE fd; @@ -5674,7 +6002,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ + + + if (fd == INVALID_HANDLE_VALUE) { -+ apc_eprint("apc_fcntl_create: could not open %s", lock_file); ++ apc_error("apc_fcntl_create: could not open %s" TSRMLS_CC, lock_file); + efree(lock_file); + return -1; + } @@ -5688,25 +6016,25 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ + CloseHandle((HANDLE)fd); +} + -+void apc_fcntl_lock(int fd) ++void apc_fcntl_lock(int fd TSRMLS_DC) +{ + OVERLAPPED offset = {0, 0, 0, 0, NULL}; + + if (!LockFileEx((HANDLE)fd, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &offset)) { -+ apc_eprint("apc_fcntl_lock failed errno:%d", GetLastError()); ++ apc_error("apc_fcntl_lock failed errno:%d" TSRMLS_CC, GetLastError()); + } +} + -+void apc_fcntl_rdlock(int fd) ++void apc_fcntl_rdlock(int fd TSRMLS_DC) +{ + OVERLAPPED offset = {0, 0, 0, 0, NULL}; + + if (!LockFileEx((HANDLE)fd, 0, 0, 1, 0, &offset)) { -+ apc_eprint("apc_fcntl_rdlock failed errno:%d", GetLastError()); ++ apc_error("apc_fcntl_rdlock failed errno:%d" TSRMLS_CC, GetLastError()); + } +} + -+void apc_fcntl_unlock(int fd) ++void apc_fcntl_unlock(int fd TSRMLS_DC) +{ + OVERLAPPED offset = {0, 0, 0, 0, NULL}; + @@ -5714,7 +6042,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ + DWORD error_code = GetLastError(); + /* Ignore already unlocked error */ + if (error_code != ERROR_NOT_LOCKED) { -+ apc_eprint("apc_fcntl_unlock failed errno:%d", error_code); ++ apc_error("apc_fcntl_unlock failed errno:%d" TSRMLS_CC, error_code); + } + } +} @@ -5727,15 +6055,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_fcntl_win32.c php-5.3.1/ext/apc/apc_fcntl_ + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h ---- php-5.3.1.orig/ext/apc/apc_globals.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_globals.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,143 @@ +--- /dev/null ++++ b/ext/apc/apc_globals.h +@@ -0,0 +1,148 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5762,7 +6089,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + + */ + -+/* $Id: apc_globals.h 284222 2009-07-17 01:23:57Z shire $ */ ++/* $Id: apc_globals.h 301232 2010-07-13 12:23:35Z gopalv $ */ + +#ifndef APC_GLOBALS_H +#define APC_GLOBALS_H @@ -5788,6 +6115,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + size_t prev_bytes_processed; + int update_freq; + double rate; ++ int started; +}; +/* }}} */ + @@ -5819,6 +6147,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + zend_bool canonicalize; /* true if relative paths should be canonicalized in no-stat mode */ + zend_bool stat_ctime; /* true if ctime in addition to mtime should be checked */ + zend_bool write_lock; /* true for a global write lock */ ++ zend_bool slam_defense; /* true for user cache slam defense */ + zend_bool report_autofilter; /* true for auto-filter warnings */ + zend_bool include_once; /* Override the ZEND_INCLUDE_OR_EVAL opcode handler to avoid pointless fopen()s [still experimental] */ + apc_optimize_function_t apc_optimize_function; /* optimizer function callback */ @@ -5833,7 +6162,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + HashTable copied_zvals; /* my_copy recursion detection list */ + zend_bool force_file_update; /* force files to be updated during apc_compile_file */ + char canon_path[MAXPATHLEN]; /* canonical path for key data */ -+#if APC_FILEHITS ++#ifdef APC_FILEHITS + zval *filehits; /* Files that came from the cache for this request */ +#endif + zend_bool coredump_unmap; /* Trap signals that coredump and unmap shared memory */ @@ -5848,6 +6177,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + HashTable *lazy_function_table; /* lazy function entry table */ + zend_bool lazy_classes; /* enable/disable lazy class loading */ + HashTable *lazy_class_table; /* lazy class entry table */ ++#ifdef ZEND_ENGINE_2_4 ++ long shm_strings_buffer; ++#endif +ZEND_END_MODULE_GLOBALS(apc) + +/* (the following declaration is defined in php_apc.c) */ @@ -5874,15 +6206,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_globals.h php-5.3.1/ext/apc/apc_globals.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc.h php-5.3.1/ext/apc/apc.h ---- php-5.3.1.orig/ext/apc/apc.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,126 @@ +--- /dev/null ++++ b/ext/apc/apc.h +@@ -0,0 +1,124 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -5909,7 +6240,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.h php-5.3.1/ext/apc/apc.h + + */ + -+/* $Id: apc.h 276125 2009-02-19 01:02:59Z shire $ */ ++/* $Id: apc.h 304310 2010-10-11 12:19:24Z gopalv $ */ + +#ifndef APC_H +#define APC_H @@ -5941,45 +6272,43 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.h php-5.3.1/ext/apc/apc.h +#include "php.h" +#include "main/php_streams.h" + -+/* log levels constants (see my_log) */ -+enum { APC_DBG, APC_NOTICE, APC_WARNING, APC_ERROR }; -+ +/* typedefs for extensible memory allocators */ -+typedef void* (*apc_malloc_t)(size_t); -+typedef void (*apc_free_t) (void*); ++typedef void* (*apc_malloc_t)(size_t TSRMLS_DC); ++typedef void (*apc_free_t) (void * TSRMLS_DC); + +/* wrappers for memory allocation routines */ -+extern void* apc_emalloc(size_t n); -+extern void* apc_erealloc(void* p, size_t n); -+extern void apc_efree(void* p); -+extern char* apc_estrdup(const char* s); -+extern void* apc_xstrdup(const char* s, apc_malloc_t f); -+extern void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f); ++extern void* apc_emalloc(size_t n TSRMLS_DC); ++extern void* apc_erealloc(void* p, size_t n TSRMLS_DC); ++extern void apc_efree(void* p TSRMLS_DC); ++extern char* apc_estrdup(const char* s TSRMLS_DC); ++extern void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC); ++extern void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC); + +/* console display functions */ -+extern void apc_eprint(const char* fmt, ...); -+extern void apc_wprint(const char* fmt, ...); -+extern void apc_dprint(const char* fmt, ...); -+extern void apc_nprint(const char* fmt, ...); ++extern void apc_error(const char *format TSRMLS_DC, ...); ++extern void apc_warning(const char *format TSRMLS_DC, ...); ++extern void apc_notice(const char *format TSRMLS_DC, ...); ++extern void apc_debug(const char *format TSRMLS_DC, ...); + +/* string and text manipulation */ -+extern char* apc_append(const char* s, const char* t); -+extern char* apc_substr(const char* s, int start, int length); -+extern char** apc_tokenize(const char* s, char delim); ++extern char* apc_append(const char* s, const char* t TSRMLS_DC); ++extern char* apc_substr(const char* s, int start, int length TSRMLS_DC); ++extern char** apc_tokenize(const char* s, char delim TSRMLS_DC); + +/* filesystem functions */ + +typedef struct apc_fileinfo_t +{ -+ char fullpath[MAXPATHLEN+1]; ++ char *fullpath; ++ char path_buf[MAXPATHLEN]; + php_stream_statbuf st_buf; +} apc_fileinfo_t; + -+extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo); ++extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC); + +/* regular expression wrapper functions */ +extern void* apc_regex_compile_array(char* patterns[] TSRMLS_DC); -+extern void apc_regex_destroy_array(void* p); ++extern void apc_regex_destroy_array(void* p TSRMLS_DC); +extern int apc_regex_match_array(void* p, const char* input); + +/* apc_crc32: returns the CRC-32 checksum of the first len bytes in buf */ @@ -6004,15 +6333,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.h php-5.3.1/ext/apc/apc.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator.c ---- php-5.3.1.orig/ext/apc/apc_iterator.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_iterator.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,634 @@ +--- /dev/null ++++ b/ext/apc/apc_iterator.c +@@ -0,0 +1,710 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6022,12 +6350,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ -+ | Authors: Brian Shire | ++ | Authors: Brian Shire | + +----------------------------------------------------------------------+ + + */ + -+/* $Id: apc_iterator.c 284698 2009-07-24 11:35:52Z kalle $ */ ++/* $Id: apc_iterator.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "php_apc.h" +#include "apc_iterator.h" @@ -6043,7 +6371,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + + +/* {{{ apc_iterator_item */ -+static apc_iterator_item_t* apc_iterator_item_ctor(apc_iterator_t *iterator, slot_t **slot_pp) { ++static apc_iterator_item_t* apc_iterator_item_ctor(apc_iterator_t *iterator, slot_t **slot_pp TSRMLS_DC) { + zval *zvalue; + char md5str[33]; + slot_t *slot = *slot_pp; @@ -6052,7 +6380,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + + if (slot->key.type == APC_CACHE_KEY_FILE) { + /* keys should be unique and with stat=1 we could have multiple files with the same name, so use ' ' instead */ ++#ifdef PHP_WIN32 ++ item->key_len = spprintf(&item->key, 0, "%I64d %I64d", slot->key.data.file.device, slot->key.data.file.inode); ++#else + item->key_len = spprintf(&item->key, 0, "%ld %ld", (ulong)slot->key.data.file.device, (ulong)slot->key.data.file.inode); ++#endif + item->filename_key = estrdup(slot->value->data.file.filename); + } else if (slot->key.type == APC_CACHE_KEY_USER) { + item->key = estrndup((char*)slot->key.data.user.identifier, slot->key.data.user.identifier_len); @@ -6061,8 +6393,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + } else if (slot->key.type == APC_CACHE_KEY_FPFILE) { + item->key = estrndup((char*)slot->key.data.fpfile.fullpath, slot->key.data.fpfile.fullpath_len); + item->key_len = slot->key.data.fpfile.fullpath_len; ++ item->filename_key = item->key; + } else { -+ apc_eprint("Internal error, invalid entry type."); ++ apc_error("Internal error, invalid entry type." TSRMLS_CC); + } + + ALLOC_INIT_ZVAL(item->value); @@ -6086,26 +6419,38 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + } + if (APC_ITER_DEVICE & iterator->format) { + if(slot->key.type == APC_CACHE_KEY_FILE) { ++#ifdef PHP_WIN32 ++ char buf[20]; ++ sprintf(buf, "%I64d", slot->key.data.file.device); ++ add_assoc_string(item->value, "device", buf, 1); ++#else + add_assoc_long(item->value, "device", slot->key.data.file.device); ++#endif + } + } + if (APC_ITER_INODE & iterator->format) { + if(slot->key.type == APC_CACHE_KEY_FILE) { ++#ifdef PHP_WIN32 ++ char buf[20]; ++ sprintf(buf, "%I64d", slot->key.data.file.device); ++ add_assoc_string(item->value, "device", buf, 1); ++#else + add_assoc_long(item->value, "inode", slot->key.data.file.inode); ++#endif + } + } + if (APC_ITER_KEY & iterator->format) { -+ add_assoc_stringl(item->value, "key", item->key, item->key_len, 1); ++ add_assoc_stringl(item->value, "key", item->key, (item->key_len - 1), 1); + } + if (APC_ITER_VALUE & iterator->format) { + if(slot->value->type == APC_CACHE_ENTRY_USER) { + -+ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL); ++ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL TSRMLS_CC); + ctxt.copy = APC_COPY_OUT_USER; + + MAKE_STD_ZVAL(zvalue); -+ apc_cache_fetch_zval(zvalue, slot->value->data.user.val, &ctxt); -+ apc_pool_destroy(ctxt.pool); ++ apc_cache_fetch_zval(zvalue, slot->value->data.user.val, &ctxt TSRMLS_CC); ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); + add_assoc_zval(item->value, "value", zvalue); + } + } @@ -6151,7 +6496,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. +/* {{{ apc_iterator_clone */ +static zend_object_value apc_iterator_clone(zval *zobject TSRMLS_DC) { + zend_object_value value = {0}; -+ apc_eprint("APCIterator object cannot be cloned."); ++ apc_error("APCIterator object cannot be cloned." TSRMLS_CC); + return value; +} +/* }}} */ @@ -6248,7 +6593,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. +#endif + + if (iterator->search_hash) { -+ rval = zend_hash_exists(iterator->search_hash, key, key_len+1); ++ rval = zend_hash_exists(iterator->search_hash, key, key_len); + if (!rval && fname_key) { + rval = zend_hash_exists(iterator->search_hash, fname_key, fname_key_len+1); + } @@ -6259,7 +6604,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. +/* }}} */ + +/* {{{ apc_iterator_fetch_active */ -+static int apc_iterator_fetch_active(apc_iterator_t *iterator) { ++static int apc_iterator_fetch_active(apc_iterator_t *iterator TSRMLS_DC) { + int count=0; + slot_t **slot; + apc_iterator_item_t *item; @@ -6274,9 +6619,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + while(*slot) { + if (apc_iterator_search_match(iterator, slot)) { + count++; -+ item = apc_iterator_item_ctor(iterator, slot); ++ item = apc_iterator_item_ctor(iterator, slot TSRMLS_CC); + if (item) { -+ apc_stack_push(iterator->stack, item); ++ apc_stack_push(iterator->stack, item TSRMLS_CC); + } + } + slot = &(*slot)->next; @@ -6290,7 +6635,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. +/* }}} */ + +/* {{{ apc_iterator_fetch_deleted */ -+static int apc_iterator_fetch_deleted(apc_iterator_t *iterator) { ++static int apc_iterator_fetch_deleted(apc_iterator_t *iterator TSRMLS_DC) { + int count=0; + slot_t **slot; + apc_iterator_item_t *item; @@ -6305,9 +6650,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + while ((*slot) && count < iterator->chunk_size) { + if (apc_iterator_search_match(iterator, slot)) { + count++; -+ item = apc_iterator_item_ctor(iterator, slot); ++ item = apc_iterator_item_ctor(iterator, slot TSRMLS_CC); + if (item) { -+ apc_stack_push(iterator->stack, item); ++ apc_stack_push(iterator->stack, item TSRMLS_CC); + } + } + slot = &(*slot)->next; @@ -6320,7 +6665,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. +/* }}} */ + +/* {{{ apc_iterator_totals */ -+static void apc_iterator_totals(apc_iterator_t *iterator) { ++static void apc_iterator_totals(apc_iterator_t *iterator TSRMLS_DC) { + slot_t **slot; + int i; + @@ -6356,13 +6701,17 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + return; + } + ++ if (!APCG(enabled)) { ++ apc_error("APC must be enabled to use APCIterator." TSRMLS_CC); ++ } ++ + if (chunk_size < 0) { -+ apc_eprint("APCIterator chunk size must be greater than 0."); ++ apc_error("APCIterator chunk size must be 0 or greater." TSRMLS_CC); + return; + } + + if (format > APC_ITER_ALL) { -+ apc_eprint("APCIterator format is invalid."); ++ apc_error("APCIterator format is invalid." TSRMLS_CC); + return; + } + @@ -6371,7 +6720,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + } else if (list == APC_LIST_DELETED) { + iterator->fetch = apc_iterator_fetch_deleted; + } else { -+ apc_wprint("APCIterator invalid list type."); ++ apc_warning("APCIterator invalid list type." TSRMLS_CC); + return; + } + @@ -6385,7 +6734,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + iterator->stack_idx = 0; + iterator->key_idx = 0; + iterator->chunk_size = chunk_size == 0 ? APC_DEFAULT_CHUNK_SIZE : chunk_size; -+ iterator->stack = apc_stack_create(chunk_size); ++ iterator->stack = apc_stack_create(chunk_size TSRMLS_CC); + iterator->format = format; + iterator->totals_flag = 0; + iterator->count = 0; @@ -6401,10 +6750,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + iterator->re = pcre_get_compiled_regex(Z_STRVAL_P(search), NULL, NULL TSRMLS_CC); + + if(!iterator->re) { -+ apc_eprint("Could not compile regular expression: %s", Z_STRVAL_P(search)); ++ apc_error("Could not compile regular expression: %s" TSRMLS_CC, Z_STRVAL_P(search)); + } +#else -+ apc_eprint("Regular expressions support is not enabled, please enable PCRE for APCIterator regex support"); ++ apc_error("Regular expressions support is not enabled, please enable PCRE for APCIterator regex support" TSRMLS_CC); +#endif + } else if (search && Z_TYPE_P(search) == IS_ARRAY) { + Z_ADDREF_P(search); @@ -6416,8 +6765,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + +/* {{{ proto APCIterator::rewind() */ +PHP_METHOD(apc_iterator, rewind) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } + + if (iterator->initialized == 0) { + RETURN_FALSE; @@ -6426,21 +6778,24 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + iterator->slot_idx = 0; + iterator->stack_idx = 0; + iterator->key_idx = 0; -+ iterator->fetch(iterator); ++ iterator->fetch(iterator TSRMLS_CC); +} +/* }}} */ + +/* {{{ proto boolean APCIterator::valid() */ +PHP_METHOD(apc_iterator, valid) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } + + if (iterator->initialized == 0) { + RETURN_FALSE; + } + + if (apc_stack_size(iterator->stack) == iterator->stack_idx) { -+ iterator->fetch(iterator); ++ iterator->fetch(iterator TSRMLS_CC); + } + + RETURN_BOOL(apc_stack_size(iterator->stack) == 0 ? 0 : 1); @@ -6449,17 +6804,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + +/* {{{ proto mixed APCIterator::current() */ +PHP_METHOD(apc_iterator, current) { -+ zval *object = getThis(); + apc_iterator_item_t *item; -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } ++ + if (iterator->initialized == 0) { + RETURN_FALSE; + } ++ + if (apc_stack_size(iterator->stack) == iterator->stack_idx) { -+ if (iterator->fetch(iterator) == 0) { ++ if (iterator->fetch(iterator TSRMLS_CC) == 0) { + RETURN_FALSE; + } + } ++ + item = apc_stack_get(iterator->stack, iterator->stack_idx); + RETURN_ZVAL(item->value, 1, 0); +} @@ -6467,20 +6828,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + +/* {{{ proto string APCIterator::key() */ +PHP_METHOD(apc_iterator, key) { -+ zval *object = getThis(); + apc_iterator_item_t *item; -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } ++ + if (iterator->initialized == 0 || apc_stack_size(iterator->stack) == 0) { + RETURN_FALSE; + } ++ + if (apc_stack_size(iterator->stack) == iterator->stack_idx) { -+ if (iterator->fetch(iterator) == 0) { ++ if (iterator->fetch(iterator TSRMLS_CC) == 0) { + RETURN_FALSE; + } + } ++ + item = apc_stack_get(iterator->stack, iterator->stack_idx); ++ + if (item->key) { -+ RETURN_STRINGL(item->key, item->key_len, 1); ++ RETURN_STRINGL(item->key, (item->key_len-1), 1); + } else { + RETURN_LONG(iterator->key_idx); + } @@ -6489,45 +6857,57 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + +/* {{{ proto APCIterator::next() */ +PHP_METHOD(apc_iterator, next) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } ++ + if (iterator->initialized == 0 || apc_stack_size(iterator->stack) == 0) { + RETURN_FALSE; + } ++ + iterator->stack_idx++; + iterator->key_idx++; ++ + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto long APCIterator::getTotalHits() */ +PHP_METHOD(apc_iterator, getTotalHits) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } + + if (iterator->initialized == 0) { + RETURN_FALSE; + } + + if (iterator->totals_flag == 0) { -+ apc_iterator_totals(iterator); ++ apc_iterator_totals(iterator TSRMLS_CC); + } + + RETURN_LONG(iterator->hits); +} +/* }}} */ + -+/* {{{ proto long APCIterator:;getTotalSize() */ ++/* {{{ proto long APCIterator::getTotalSize() */ +PHP_METHOD(apc_iterator, getTotalSize) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } + + if (iterator->initialized == 0) { + RETURN_FALSE; + } + + if (iterator->totals_flag == 0) { -+ apc_iterator_totals(iterator); ++ apc_iterator_totals(iterator TSRMLS_CC); + } + + RETURN_LONG(iterator->size); @@ -6536,32 +6916,56 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + +/* {{{ proto long APCIterator::getTotalCount() */ +PHP_METHOD(apc_iterator, getTotalCount) { -+ zval *object = getThis(); -+ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(object TSRMLS_CC); ++ apc_iterator_t *iterator = (apc_iterator_t*)zend_object_store_get_object(getThis() TSRMLS_CC); ++ ++ if (zend_parse_parameters_none() == FAILURE) { ++ return; ++ } + + if (iterator->initialized == 0) { + RETURN_FALSE; + } + + if (iterator->totals_flag == 0) { -+ apc_iterator_totals(iterator); ++ apc_iterator_totals(iterator TSRMLS_CC); + } + + RETURN_LONG(iterator->count); +} +/* }}} */ + ++/* {{{ arginfo */ ++#if (PHP_MAJOR_VERSION >= 6 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3)) ++# define PHP_APC_ARGINFO ++#else ++# define PHP_APC_ARGINFO static ++#endif ++ ++PHP_APC_ARGINFO ++ZEND_BEGIN_ARG_INFO_EX(arginfo_apc_iterator___construct, 0, 0, 1) ++ ZEND_ARG_INFO(0, cache) ++ ZEND_ARG_INFO(0, search) ++ ZEND_ARG_INFO(0, format) ++ ZEND_ARG_INFO(0, chunk_size) ++ ZEND_ARG_INFO(0, list) ++ZEND_END_ARG_INFO() ++ ++PHP_APC_ARGINFO ++ZEND_BEGIN_ARG_INFO_EX(arginfo_apc_iterator_void, 0, 0, 0) ++ZEND_END_ARG_INFO() ++/* }}} */ ++ +/* {{{ apc_iterator_functions */ -+static function_entry apc_iterator_functions[] = { -+ PHP_ME(apc_iterator, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) -+ PHP_ME(apc_iterator, rewind, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, current, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, key, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, next, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, valid, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, getTotalHits, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, getTotalSize, NULL, ZEND_ACC_PUBLIC) -+ PHP_ME(apc_iterator, getTotalCount, NULL, ZEND_ACC_PUBLIC) ++static zend_function_entry apc_iterator_functions[] = { ++ PHP_ME(apc_iterator, __construct, arginfo_apc_iterator___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) ++ PHP_ME(apc_iterator, rewind, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, current, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, key, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, next, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, valid, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, getTotalHits, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, getTotalSize, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) ++ PHP_ME(apc_iterator, getTotalCount, arginfo_apc_iterator_void, ZEND_ACC_PUBLIC) + {NULL, NULL, NULL} +}; +/* }}} */ @@ -6610,7 +7014,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + apc_iterator_item_t *item; + + if (!ce || !instanceof_function(ce, apc_iterator_ce TSRMLS_CC)) { -+ apc_eprint("apc_delete object argument must be instance of APCIterator"); ++ apc_error("apc_delete object argument must be instance of APCIterator" TSRMLS_CC); + return 0; + } + iterator = (apc_iterator_t*)zend_object_store_get_object(zobj TSRMLS_CC); @@ -6619,13 +7023,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + return 0; + } + -+ while (iterator->fetch(iterator)) { ++ while (iterator->fetch(iterator TSRMLS_CC)) { + while (iterator->stack_idx < apc_stack_size(iterator->stack)) { + item = apc_stack_get(iterator->stack, iterator->stack_idx++); + if (iterator->cache == apc_cache) { -+ apc_cache_delete(apc_cache, item->filename_key, strlen(item->filename_key)+1); ++ apc_cache_delete(apc_cache, item->filename_key, strlen(item->filename_key) + 1 TSRMLS_CC); + } else { -+ apc_cache_user_delete(apc_user_cache, item->key, item->key_len+1); ++ apc_cache_user_delete(apc_user_cache, item->key, item->key_len TSRMLS_CC); + } + } + } @@ -6642,15 +7046,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.c php-5.3.1/ext/apc/apc_iterator. + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.h php-5.3.1/ext/apc/apc_iterator.h ---- php-5.3.1.orig/ext/apc/apc_iterator.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_iterator.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_iterator.h @@ -0,0 +1,117 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6665,7 +7068,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.h php-5.3.1/ext/apc/apc_iterator. + + */ + -+/* $Id: apc_iterator.h 277132 2009-03-14 01:50:57Z shire $ */ ++/* $Id: apc_iterator.h 300979 2010-07-04 10:15:05Z kalle $ */ + +#ifndef APC_ITERATOR_H +#define APC_ITERATOR_H @@ -6719,7 +7122,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.h php-5.3.1/ext/apc/apc_iterator. + zend_object obj; /* must always be first */ + short int initialized; /* sanity check in case __construct failed */ + long format; /* format bitmask of the return values ie: key, value, info */ -+ int (*fetch)(struct _apc_iterator_t *iterator); ++ int (*fetch)(struct _apc_iterator_t *iterator TSRMLS_DC); + /* fetch callback to fetch items from cache slots or lists */ + apc_cache_t *cache; /* cache which we are iterating on */ + long slot_idx; /* index to the slot array or linked list */ @@ -6763,15 +7166,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_iterator.h php-5.3.1/ext/apc/apc_iterator. + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_lock.h php-5.3.1/ext/apc/apc_lock.h ---- php-5.3.1.orig/ext/apc/apc_lock.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_lock.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,100 @@ +--- /dev/null ++++ b/ext/apc/apc_lock.h +@@ -0,0 +1,101 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6795,11 +7197,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_lock.h php-5.3.1/ext/apc/apc_lock.h + + */ + -+/* $Id: apc_lock.h 268620 2008-11-09 02:30:49Z shire $ */ ++/* $Id: apc_lock.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_LOCK +#define APC_LOCK + ++#include "apc.h" +#include "apc_sem.h" +#include "apc_fcntl.h" +#include "apc_pthreadmutex.h" @@ -6821,23 +7224,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_lock.h php-5.3.1/ext/apc/apc_lock.h +#define RDLOCK_AVAILABLE 0 +#define NONBLOCKING_LOCK_AVAILABLE 1 +#define apc_lck_t int -+#define apc_lck_create(a,b,c,d) d=apc_sem_create(NULL,(b),(c)) ++#define apc_lck_create(a,b,c,d) d=apc_sem_create((b),(c) TSRMLS_CC) +#define apc_lck_destroy(a) apc_sem_destroy(a) -+#define apc_lck_lock(a) apc_sem_lock(a) -+#define apc_lck_nb_lock(a) apc_sem_nonblocking_lock(a) -+#define apc_lck_rdlock(a) apc_sem_lock(a) -+#define apc_lck_unlock(a) apc_sem_unlock(a) ++#define apc_lck_lock(a) apc_sem_lock(a TSRMLS_CC) ++#define apc_lck_nb_lock(a) apc_sem_nonblocking_lock(a TSRMLS_CC) ++#define apc_lck_rdlock(a) apc_sem_lock(a TSRMLS_CC) ++#define apc_lck_unlock(a) apc_sem_unlock(a TSRMLS_CC) +#elif defined(APC_PTHREADMUTEX_LOCKS) +#define APC_LOCK_TYPE "pthread mutex Locks" +#define RDLOCK_AVAILABLE 0 +#define NONBLOCKING_LOCK_AVAILABLE 1 +#define apc_lck_t pthread_mutex_t -+#define apc_lck_create(a,b,c,d) apc_pthreadmutex_create((pthread_mutex_t*)&d) ++#define apc_lck_create(a,b,c,d) apc_pthreadmutex_create((pthread_mutex_t*)&d TSRMLS_CC) +#define apc_lck_destroy(a) apc_pthreadmutex_destroy(&a) -+#define apc_lck_lock(a) apc_pthreadmutex_lock(&a) -+#define apc_lck_nb_lock(a) apc_pthreadmutex_nonblocking_lock(&a) -+#define apc_lck_rdlock(a) apc_pthreadmutex_lock(&a) -+#define apc_lck_unlock(a) apc_pthreadmutex_unlock(&a) ++#define apc_lck_lock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) ++#define apc_lck_nb_lock(a) apc_pthreadmutex_nonblocking_lock(&a TSRMLS_CC) ++#define apc_lck_rdlock(a) apc_pthreadmutex_lock(&a TSRMLS_CC) ++#define apc_lck_unlock(a) apc_pthreadmutex_unlock(&a TSRMLS_CC) +#elif defined(APC_SPIN_LOCKS) +#define APC_LOCK_TYPE "spin Locks" +#define RDLOCK_AVAILABLE 0 @@ -6845,9 +7248,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_lock.h php-5.3.1/ext/apc/apc_lock.h +#define apc_lck_t slock_t +#define apc_lck_create(a,b,c,d) apc_slock_create((slock_t*)&(d)) +#define apc_lck_destroy(a) apc_slock_destroy(&a) -+#define apc_lck_lock(a) apc_slock_lock(&a) ++#define apc_lck_lock(a) apc_slock_lock(&a TSRMLS_CC) +#define apc_lck_nb_lock(a) apc_slock_nonblocking_lock(&a) -+#define apc_lck_rdlock(a) apc_slock_lock(&a) ++#define apc_lck_rdlock(a) apc_slock_lock(&a TSRMLS_CC) +#define apc_lck_unlock(a) apc_slock_unlock(&a) +#else +#define APC_LOCK_TYPE "File Locks" @@ -6858,24 +7261,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_lock.h php-5.3.1/ext/apc/apc_lock.h +#define NONBLOCKING_LOCK_AVAILABLE 1 +#endif +#define apc_lck_t int -+#define apc_lck_create(a,b,c,d) d=apc_fcntl_create((a)) ++#define apc_lck_create(a,b,c,d) d=apc_fcntl_create((a) TSRMLS_CC) +#define apc_lck_destroy(a) apc_fcntl_destroy(a) -+#define apc_lck_lock(a) apc_fcntl_lock(a) -+#define apc_lck_nb_lock(a) apc_fcntl_nonblocking_lock(a) -+#define apc_lck_rdlock(a) apc_fcntl_rdlock(a) -+#define apc_lck_unlock(a) apc_fcntl_unlock(a) ++#define apc_lck_lock(a) apc_fcntl_lock(a TSRMLS_CC) ++#define apc_lck_nb_lock(a) apc_fcntl_nonblocking_lock(a TSRMLS_CC) ++#define apc_lck_rdlock(a) apc_fcntl_rdlock(a TSRMLS_CC) ++#define apc_lck_unlock(a) apc_fcntl_unlock(a TSRMLS_CC) +#endif + +#endif -diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c ---- php-5.3.1.orig/ext/apc/apc_main.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_main.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,957 @@ +--- /dev/null ++++ b/ext/apc/apc_main.c +@@ -0,0 +1,969 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -6901,7 +7303,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + + */ + -+/* $Id: apc_main.c 284282 2009-07-17 21:50:33Z shire $ */ ++/* $Id: apc_main.c 304994 2010-10-30 20:33:46Z gopalv $ */ + +#include "apc_php.h" +#include "apc_main.h" @@ -6914,6 +7316,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +#include "apc_stack.h" +#include "apc_zend.h" +#include "apc_pool.h" ++#include "apc_string.h" +#include "SAPI.h" +#include "php_scandir.h" +#include "ext/standard/php_var.h" @@ -6942,7 +7345,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +{ + int status; + -+ ++#if APC_HAVE_LOOKUP_HOOKS + if(lazy && fn.name[0] != '\0' && strncmp(fn.name, "__autoload", fn.name_len) != 0) { + status = zend_hash_add(APCG(lazy_function_table), + fn.name, @@ -6950,8 +7353,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + &fn, + sizeof(apc_function_t), + NULL); ++#else ++ if(0) { ++#endif + } else { -+ zend_function *func = apc_copy_function_for_execution(fn.function, ctxt); ++ zend_function *func = apc_copy_function_for_execution(fn.function, ctxt TSRMLS_CC); + status = zend_hash_add(EG(function_table), + fn.name, + fn.name_len+1, @@ -6962,7 +7368,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + } + + if (status == FAILURE) { -+ /* apc_eprint("Cannot redeclare %s()", fn.name); */ ++ /* apc_error("Cannot redeclare %s()" TSRMLS_CC, fn.name); */ + } + + return status; @@ -6976,11 +7382,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + apc_context_t ctxt = {0,}; + TSRMLS_FETCH(); + -+ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect); ++ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + ctxt.copy = APC_COPY_OUT_OPCODE; + + if(zend_hash_quick_find(APCG(lazy_function_table), name, len, hash, (void**)&fn) == SUCCESS) { -+ *fe = apc_copy_function_for_execution(fn->function, &ctxt); ++ *fe = apc_copy_function_for_execution(fn->function, &ctxt TSRMLS_CC); + status = zend_hash_add(EG(function_table), + fn->name, + fn->name_len+1, @@ -7031,7 +7437,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + /* + * XXX: We need to free this somewhere... + */ -+ allocated_ce = apc_php_malloc(sizeof(zend_class_entry*)); ++ allocated_ce = apc_php_malloc(sizeof(zend_class_entry*) TSRMLS_CC); + + if(!allocated_ce) { + return FAILURE; @@ -7039,7 +7445,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + + *allocated_ce = + class_entry = -+ apc_copy_class_entry_for_execution(cl.class_entry, ctxt); ++ apc_copy_class_entry_for_execution(cl.class_entry, ctxt TSRMLS_CC); + + + /* restore parent class pointer for compile-time inheritance */ @@ -7062,11 +7468,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + */ + status = zend_lookup_class_ex(cl.parent_name, + strlen(cl.parent_name), ++#ifdef ZEND_ENGINE_2_4 ++ NULL, ++#endif + 0, + &parent_ptr TSRMLS_CC); + if (status == FAILURE) { + if(APCG(report_autofilter)) { -+ apc_wprint("Dynamic inheritance detected for class %s", cl.name); ++ apc_warning("Dynamic inheritance detected for class %s" TSRMLS_CC, cl.name); + } + class_entry->parent = NULL; + return status; @@ -7088,7 +7497,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + NULL); + + if (status == FAILURE) { -+ apc_eprint("Cannot redeclare class %s", cl.name); ++ apc_error("Cannot redeclare class %s" TSRMLS_CC, cl.name); + } + return status; +} @@ -7107,16 +7516,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + return FAILURE; + } + -+ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect); ++ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + ctxt.copy = APC_COPY_OUT_OPCODE; + + if(install_class(*cl, &ctxt, 0 TSRMLS_CC) == FAILURE) { -+ apc_wprint("apc_lookup_class_hook: could not install %s", name); ++ apc_warning("apc_lookup_class_hook: could not install %s" TSRMLS_CC, name); + return FAILURE; + } + + if(zend_hash_quick_find(EG(class_table), name, len, hash, (void**)ce) == FAILURE) { -+ apc_wprint("apc_lookup_class_hook: known error trying to fetch class %s", name); ++ apc_warning("apc_lookup_class_hook: known error trying to fetch class %s" TSRMLS_CC, name); + return FAILURE; + } + @@ -7134,7 +7543,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + cl.name, + cl.name_len+1); + if (status == FAILURE) { -+ apc_eprint("Cannot delete class %s", cl.name); ++ apc_error("Cannot delete class %s" TSRMLS_CC, cl.name); + } + return status; +} @@ -7182,7 +7591,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +/* {{{ apc_defined_function_hook */ +int apc_defined_function_hook(zval *internal, zval *user) { + TSRMLS_FETCH(); -+ zend_hash_apply_with_arguments(APCG(lazy_function_table) TSRMLS_CC, (apply_func_args_t) copy_function_name, 2, internal, user); ++ zend_hash_apply_with_arguments(APCG(lazy_function_table) ++#ifdef ZEND_ENGINE_2_3 ++ TSRMLS_CC ++#endif ++ ,(apply_func_args_t) copy_function_name, 2, internal, user); + return 1; +} +/* }}} */ @@ -7190,22 +7603,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +/* {{{ apc_declared_class_hook */ +int apc_declared_class_hook(zval *classes, zend_uint mask, zend_uint comply) { + TSRMLS_FETCH(); -+ zend_hash_apply_with_arguments(APCG(lazy_class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, classes, mask, comply); ++ zend_hash_apply_with_arguments(APCG(lazy_class_table) ++#ifdef ZEND_ENGINE_2_3 ++ TSRMLS_CC ++#endif ++ , (apply_func_args_t) copy_class_or_interface_name, 3, classes, mask, comply); + return 1; +} +/* }}} */ + -+/* {{{ compare_file_handles */ -+static int compare_file_handles(void* a, void* b) -+{ -+ zend_file_handle* fh1 = (zend_file_handle*)a; -+ zend_file_handle* fh2 = (zend_file_handle*)b; -+ return (fh1->type == fh2->type && -+ fh1->filename == fh2->filename && -+ fh1->opened_path == fh2->opened_path); -+} -+/* }}} */ -+ +/* {{{ cached_compile */ +static zend_op_array* cached_compile(zend_file_handle* h, + int type, @@ -7218,16 +7624,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + assert(cache_entry != NULL); + + if (cache_entry->data.file.classes) { ++ int lazy_classes = APCG(lazy_classes); + for (i = 0; cache_entry->data.file.classes[i].class_entry != NULL; i++) { -+ if(install_class(cache_entry->data.file.classes[i], ctxt, APCG(lazy_classes) TSRMLS_CC) == FAILURE) { ++ if(install_class(cache_entry->data.file.classes[i], ctxt, lazy_classes TSRMLS_CC) == FAILURE) { + goto default_compile; + } + } + } + + if (cache_entry->data.file.functions) { ++ int lazy_functions = APCG(lazy_functions); + for (i = 0; cache_entry->data.file.functions[i].function != NULL; i++) { -+ install_function(cache_entry->data.file.functions[i], ctxt, APCG(lazy_functions) TSRMLS_CC); ++ install_function(cache_entry->data.file.functions[i], ctxt, lazy_functions TSRMLS_CC); + } + } + @@ -7238,10 +7646,6 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + +default_compile: + -+ if(APCG(report_autofilter)) { -+ apc_wprint("Autofiltering %s", h->opened_path); -+ } -+ + if(cache_entry->data.file.classes) { + for(ii = 0; ii < i ; ii++) { + uninstall_class(cache_entry->data.file.classes[ii] TSRMLS_CC); @@ -7250,20 +7654,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + + apc_stack_pop(APCG(cache_stack)); /* pop out cache_entry */ + -+ apc_cache_release(apc_cache, cache_entry); ++ apc_cache_release(apc_cache, cache_entry TSRMLS_CC); + + /* cannot free up cache data yet, it maybe in use */ + -+ zend_llist_del_element(&CG(open_files), h, compare_file_handles); /* We leak fds without this hack */ -+ -+ /* WARNING: zend_llist shallow copies - so element delete via the -+ * zend_file_handle_dtor leaves h->opened_path dangling onto bad memory. -+ */ -+ -+ h->opened_path = NULL; -+ h->type = ZEND_HANDLE_FILENAME; -+ if(h->free_filename) h->filename = NULL; -+ + return NULL; +} +/* }}} */ @@ -7290,9 +7684,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + } + + ctxt.pool = apc_pool_create(APC_MEDIUM_POOL, apc_sma_malloc, apc_sma_free, -+ apc_sma_protect, apc_sma_unprotect); ++ apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + if (!ctxt.pool) { -+ apc_wprint("Unable to allocate memory for pool."); ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + return FAILURE; + } + ctxt.copy = APC_COPY_IN_OPCODE; @@ -7318,10 +7712,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + PHP_MD5Final(key.md5, &context); + php_stream_close(stream); + if(n<0) { -+ apc_wprint("Error while reading '%s' for md5 generation.", filename); ++ apc_warning("Error while reading '%s' for md5 generation." TSRMLS_CC, filename); + } + } else { -+ apc_wprint("Unable to open '%s' for md5 generation.", filename); ++ apc_warning("Unable to open '%s' for md5 generation." TSRMLS_CC, filename); + } + } + @@ -7339,18 +7733,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + path = h->opened_path; + if(!path) path=h->filename; + -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"2. h->opened_path=[%s] h->filename=[%s]\n", h->opened_path?h->opened_path:"null",h->filename); -+#endif ++ apc_debug("2. h->opened_path=[%s] h->filename=[%s]\n" TSRMLS_CC, h->opened_path?h->opened_path:"null",h->filename); + -+ if(!(*cache_entry = apc_cache_make_file_entry(path, alloc_op_array, alloc_functions, alloc_classes, &ctxt))) { ++ if(!(*cache_entry = apc_cache_make_file_entry(path, alloc_op_array, alloc_functions, alloc_classes, &ctxt TSRMLS_CC))) { + goto freepool; + } + + return SUCCESS; + +freepool: -+ apc_pool_destroy(ctxt.pool); ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); + ctxt.pool = NULL; + + return FAILURE; @@ -7369,14 +7761,21 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + time_t t; + apc_context_t ctxt = {0,}; + int bailout=0; ++ const char* filename = NULL; + + if (!APCG(enabled) || apc_cache_busy(apc_cache)) { + return old_compile_file(h, type TSRMLS_CC); + } + ++ if(h->opened_path) { ++ filename = h->opened_path; ++ } else { ++ filename = h->filename; ++ } ++ + /* check our regular expression filters */ -+ if (APCG(filters) && APCG(compiled_filters) && h->opened_path) { -+ int ret = apc_regex_match_array(APCG(compiled_filters), h->opened_path); ++ if (APCG(filters) && APCG(compiled_filters) && filename) { ++ int ret = apc_regex_match_array(APCG(compiled_filters), filename); + + if(ret == APC_NEGATIVE_MATCH || (ret != APC_POSITIVE_MATCH && !APCG(cache_by_default))) { + return old_compile_file(h, type TSRMLS_CC); @@ -7389,19 +7788,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + + t = apc_time(); + -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"1. h->opened_path=[%s] h->filename=[%s]\n", h->opened_path?h->opened_path:"null",h->filename); -+#endif ++ apc_debug("1. h->opened_path=[%s] h->filename=[%s]\n" TSRMLS_CC, h->opened_path?h->opened_path:"null",h->filename); + + /* try to create a cache key; if we fail, give up on caching */ + if (!apc_cache_make_file_key(&key, h->filename, PG(include_path), t TSRMLS_CC)) { + return old_compile_file(h, type TSRMLS_CC); + } + -+ + if(!APCG(force_file_update)) { + /* search for the file in the cache */ -+ cache_entry = apc_cache_find(apc_cache, key, t); ++ cache_entry = apc_cache_find(apc_cache, key, t TSRMLS_CC); + ctxt.force_update = 0; + } else { + cache_entry = NULL; @@ -7410,40 +7806,45 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + + if (cache_entry != NULL) { + int dummy = 1; -+ ++ + ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, -+ apc_sma_protect, apc_sma_unprotect); ++ apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + if (!ctxt.pool) { -+ apc_wprint("Unable to allocate memory for pool."); ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + return old_compile_file(h, type TSRMLS_CC); + } + ctxt.copy = APC_COPY_OUT_OPCODE; ++ ++ zend_hash_add(&EG(included_files), cache_entry->data.file.filename, ++ strlen(cache_entry->data.file.filename)+1, ++ (void *)&dummy, sizeof(int), NULL); + -+ if (h->opened_path == NULL) { -+ h->opened_path = estrdup(cache_entry->data.file.filename); -+ } -+ zend_hash_add(&EG(included_files), h->opened_path, strlen(h->opened_path)+1, (void *)&dummy, sizeof(int), NULL); -+ -+ zend_llist_add_element(&CG(open_files), h); /* We leak fds without this hack */ -+ -+ apc_stack_push(APCG(cache_stack), cache_entry); ++ apc_stack_push(APCG(cache_stack), cache_entry TSRMLS_CC); + op_array = cached_compile(h, type, &ctxt TSRMLS_CC); ++ + if(op_array) { +#ifdef APC_FILEHITS + /* If the file comes from the cache, add it to the global request file list */ + add_next_index_string(APCG(filehits), h->filename, 1); +#endif + /* this is an unpool, which has no cleanup - this only free's the pool header */ -+ apc_pool_destroy(ctxt.pool); ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); ++ ++ /* We might leak fds without this hack */ ++ if (h->type != ZEND_HANDLE_FILENAME) { ++ zend_llist_add_element(&CG(open_files), h); ++ } + return op_array; + } + if(APCG(report_autofilter)) { -+ apc_wprint("Recompiling %s", cache_entry->data.file.filename); ++ apc_warning("Autofiltering %s" TSRMLS_CC, ++ (h->opened_path ? h->opened_path : h->filename)); ++ apc_warning("Recompiling %s" TSRMLS_CC, cache_entry->data.file.filename); + } + /* TODO: check what happens with EG(included_files) */ + } + -+ /* Make sure the mtime reflects the files last known mtime in the case of fpstat==0 */ ++ /* Make sure the mtime reflects the files last known mtime, and we respect max_file_size in the case of fpstat==0 */ + if(key.type == APC_CACHE_KEY_FPFILE) { + apc_fileinfo_t fileinfo; + struct stat *tmp_buf = NULL; @@ -7453,13 +7854,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + if(tmp_buf) { + fileinfo.st_buf.sb = *tmp_buf; + } else { -+ if (apc_search_paths(h->filename, PG(include_path), &fileinfo) != 0) { -+#ifdef __DEBUG_APC__ -+ fprintf(stderr,"Stat failed %s - bailing (%s) (%d)\n",h->filename,SG(request_info).path_translated); -+#endif -+ return op_array; ++ if (apc_search_paths(h->filename, PG(include_path), &fileinfo TSRMLS_CC) != 0) { ++ apc_debug("Stat failed %s - bailing (%s) (%d)\n" TSRMLS_CC,h->filename,SG(request_info).path_translated); ++ return old_compile_file(h, type TSRMLS_CC); + } + } ++ if (APCG(max_file_size) < fileinfo.st_buf.sb.st_size) { ++ apc_debug("File is too big %s (%ld) - bailing\n" TSRMLS_CC, h->filename, fileinfo.st_buf.sb.st_size); ++ return old_compile_file(h, type TSRMLS_CC); ++ } + key.mtime = fileinfo.st_buf.sb.st_mtime; + } + @@ -7467,7 +7870,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + +#if NONBLOCKING_LOCK_AVAILABLE + if(APCG(write_lock)) { -+ if(!apc_cache_write_lock(apc_cache)) { ++ if(!apc_cache_write_lock(apc_cache TSRMLS_CC)) { + HANDLE_UNBLOCK_INTERRUPTIONS(); + return old_compile_file(h, type TSRMLS_CC); + } @@ -7478,8 +7881,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + if (apc_compile_cache_entry(key, h, type, t, &op_array, &cache_entry TSRMLS_CC) == SUCCESS) { + ctxt.pool = cache_entry->pool; + ctxt.copy = APC_COPY_IN_OPCODE; -+ if (apc_cache_insert(apc_cache, key, cache_entry, &ctxt, t) != 1) { -+ apc_pool_destroy(ctxt.pool); ++ if (apc_cache_insert(apc_cache, key, cache_entry, &ctxt, t TSRMLS_CC) != 1) { ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); + ctxt.pool = NULL; + } + } @@ -7491,7 +7894,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + +#if NONBLOCKING_LOCK_AVAILABLE + if(APCG(write_lock)) { -+ apc_cache_write_unlock(apc_cache); ++ apc_cache_write_unlock(apc_cache TSRMLS_CC); + } +#endif + HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -7506,7 +7909,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + +extern int _apc_store(char *strkey, int strkey_len, const zval *val, const unsigned int ttl, const int exclusive TSRMLS_DC); + -+static zval* data_unserialize(const char *filename) ++static zval* data_unserialize(const char *filename TSRMLS_DC) +{ + zval* retval; + long len = 0; @@ -7514,7 +7917,6 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + char *contents, *tmp; + FILE *fp; + php_unserialize_data_t var_hash; -+ TSRMLS_FETCH(); + + if(VCWD_STAT(filename, &sb) == -1) { + return NULL; @@ -7570,7 +7972,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + p[0] = '\0'; + key_len = strlen(key); + -+ data = data_unserialize(data_file); ++ data = data_unserialize(data_file TSRMLS_CC); + if(data) { + _apc_store(key, key_len, data, 0, 1 TSRMLS_CC); + } @@ -7627,12 +8029,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +{ + /* apc initialization */ +#if APC_MMAP -+ apc_sma_init(APCG(shm_segments), APCG(shm_size)*1024*1024, APCG(mmap_file_mask)); ++ apc_sma_init(APCG(shm_segments), APCG(shm_size), APCG(mmap_file_mask) TSRMLS_CC); +#else -+ apc_sma_init(APCG(shm_segments), APCG(shm_size)*1024*1024, NULL); ++ apc_sma_init(APCG(shm_segments), APCG(shm_size), NULL TSRMLS_CC); +#endif -+ apc_cache = apc_cache_create(APCG(num_files_hint), APCG(gc_ttl), APCG(ttl)); -+ apc_user_cache = apc_cache_create(APCG(user_entries_hint), APCG(gc_ttl), APCG(user_ttl)); ++ apc_cache = apc_cache_create(APCG(num_files_hint), APCG(gc_ttl), APCG(ttl) TSRMLS_CC); ++ apc_user_cache = apc_cache_create(APCG(user_entries_hint), APCG(gc_ttl), APCG(user_ttl) TSRMLS_CC); + + /* override compilation */ + old_compile_file = zend_compile_file; @@ -7655,11 +8057,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + } +#else + if(APCG(lazy_functions) || APCG(lazy_classes)) { -+ apc_wprint("Lazy function/class loading not available with this version of PHP, please disable APC lazy loading."); ++ apc_warning("Lazy function/class loading not available with this version of PHP, please disable APC lazy loading." TSRMLS_CC); + APCG(lazy_functions) = APCG(lazy_classes) = 0; + } +#endif + ++#ifdef ZEND_ENGINE_2_4 ++ apc_interned_strings_init(TSRMLS_C); ++#endif ++ + APCG(initialized) = 1; + return 0; +} @@ -7699,12 +8105,16 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + cache_entry->data.file.classes[i].name_len+1); + } + } -+ apc_cache_release(apc_cache, cache_entry); ++ apc_cache_release(apc_cache, cache_entry TSRMLS_CC); + } + -+ apc_cache_destroy(apc_cache); -+ apc_cache_destroy(apc_user_cache); -+ apc_sma_cleanup(); ++ apc_cache_destroy(apc_cache TSRMLS_CC); ++ apc_cache_destroy(apc_user_cache TSRMLS_CC); ++ apc_sma_cleanup(TSRMLS_C); ++ ++#ifdef ZEND_ENGINE_2_4 ++ apc_interned_strings_shutdown(TSRMLS_C); ++#endif + + APCG(initialized) = 0; + return 0; @@ -7760,10 +8170,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + cache_entry->data.file.classes[i].name, + cache_entry->data.file.classes[i].name_len+1); + -+ apc_free_class_entry_after_execution(zce); ++ apc_free_class_entry_after_execution(zce TSRMLS_CC); + } + } -+ apc_cache_release(apc_cache, cache_entry); ++ apc_cache_release(apc_cache, cache_entry TSRMLS_CC); + } +} +/* }}} */ @@ -7779,6 +8189,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + APCG(compiled_filters) = apc_regex_compile_array(APCG(filters) TSRMLS_CC); + } + ++#if APC_HAVE_LOOKUP_HOOKS + if(APCG(lazy_functions)) { + APCG(lazy_function_table) = emalloc(sizeof(HashTable)); + zend_hash_init(APCG(lazy_function_table), 0, NULL, NULL, 0); @@ -7787,6 +8198,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + APCG(lazy_class_table) = emalloc(sizeof(HashTable)); + zend_hash_init(APCG(lazy_class_table), 0, NULL, NULL, 0); + } ++#endif + +#ifdef APC_FILEHITS + ALLOC_INIT_ZVAL(APCG(filehits)); @@ -7799,6 +8211,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c +int apc_request_shutdown(TSRMLS_D) +{ + ++#if APC_HAVE_LOOKUP_HOOKS + if(APCG(lazy_class_table)) { + zend_hash_destroy(APCG(lazy_class_table)); + efree(APCG(lazy_class_table)); @@ -7807,6 +8220,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + zend_hash_destroy(APCG(lazy_function_table)); + efree(APCG(lazy_function_table)); + } ++#endif + + apc_deactivate(TSRMLS_C); + @@ -7828,15 +8242,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.c php-5.3.1/ext/apc/apc_main.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_main.h php-5.3.1/ext/apc/apc_main.h ---- php-5.3.1.orig/ext/apc/apc_main.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_main.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_main.h @@ -0,0 +1,74 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -7863,7 +8276,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.h php-5.3.1/ext/apc/apc_main.h + + */ + -+/* $Id: apc_main.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_main.h 300979 2010-07-04 10:15:05Z kalle $ */ + +#ifndef APC_MAIN_H +#define APC_MAIN_H @@ -7906,15 +8319,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_main.h php-5.3.1/ext/apc/apc_main.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c ---- php-5.3.1.orig/ext/apc/apc_mmap.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_mmap.c 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_mmap.c @@ -0,0 +1,175 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -7937,7 +8349,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + + */ + -+/* $Id: apc_mmap.c 287248 2009-08-13 15:13:52Z gopalv $ */ ++/* $Id: apc_mmap.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc.h" +#include "apc_mmap.h" @@ -7965,7 +8377,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c +# define MAP_ANON MAP_ANONYMOUS +#endif + -+apc_segment_t apc_mmap(char *file_mask, size_t size) ++apc_segment_t apc_mmap(char *file_mask, size_t size TSRMLS_DC) +{ + apc_segment_t segment; + @@ -7976,7 +8388,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + /* If no filename was provided, do an anonymous mmap */ + if(!file_mask || (file_mask && !strlen(file_mask))) { +#if !defined(MAP_ANON) -+ apc_eprint("Anonymous mmap does not apear to be available on this system (MAP_ANON/MAP_ANONYMOUS). Please see the apc.mmap_file_mask INI option."); ++ apc_error("Anonymous mmap does not apear to be available on this system (MAP_ANON/MAP_ANONYMOUS). Please see the apc.mmap_file_mask INI option." TSRMLS_CC); +#else + fd = -1; + flags = MAP_SHARED | MAP_ANON; @@ -7985,7 +8397,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + } else if(!strcmp(file_mask,"/dev/zero")) { + fd = open("/dev/zero", O_RDWR, S_IRUSR | S_IWUSR); + if(fd == -1) { -+ apc_eprint("apc_mmap: open on /dev/zero failed:"); ++ apc_error("apc_mmap: open on /dev/zero failed:" TSRMLS_CC); + goto error; + } + remap = 0; /* cannot remap */ @@ -8001,18 +8413,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + * path you want here. + */ + if(!mktemp(file_mask)) { -+ apc_eprint("apc_mmap: mktemp on %s failed:", file_mask); ++ apc_error("apc_mmap: mktemp on %s failed:" TSRMLS_CC, file_mask); + goto error; + } + fd = shm_open(file_mask, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); + if(fd == -1) { -+ apc_eprint("apc_mmap: shm_open on %s failed:", file_mask); ++ apc_error("apc_mmap: shm_open on %s failed:" TSRMLS_CC, file_mask); + goto error; + } + if (ftruncate(fd, size) < 0) { + close(fd); + shm_unlink(file_mask); -+ apc_eprint("apc_mmap: ftruncate failed:"); ++ apc_error("apc_mmap: ftruncate failed:" TSRMLS_CC); + goto error; + } + shm_unlink(file_mask); @@ -8022,13 +8434,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + */ + fd = mkstemp(file_mask); + if(fd == -1) { -+ apc_eprint("apc_mmap: mkstemp on %s failed:", file_mask); ++ apc_error("apc_mmap: mkstemp on %s failed:" TSRMLS_CC, file_mask); + goto error; + } + if (ftruncate(fd, size) < 0) { + close(fd); + unlink(file_mask); -+ apc_eprint("apc_mmap: ftruncate failed:"); ++ apc_error("apc_mmap: ftruncate failed:" TSRMLS_CC); + goto error; + } + unlink(file_mask); @@ -8045,7 +8457,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c +#endif + + if((long)segment.shmaddr == -1) { -+ apc_eprint("apc_mmap: mmap failed:"); ++ apc_error("apc_mmap: mmap failed:" TSRMLS_CC); + } + + if(fd != -1) close(fd); @@ -8061,15 +8473,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + return segment; +} + -+void apc_unmap(apc_segment_t *segment) ++void apc_unmap(apc_segment_t *segment TSRMLS_DC) +{ + if (munmap(segment->shmaddr, segment->size) < 0) { -+ apc_wprint("apc_unmap: munmap failed:"); ++ apc_warning("apc_unmap: munmap failed:" TSRMLS_CC); + } + +#ifdef APC_MEMPROTECT + if (segment->roaddr && munmap(segment->roaddr, segment->size) < 0) { -+ apc_wprint("apc_unmap: munmap failed:"); ++ apc_warning("apc_unmap: munmap failed:" TSRMLS_CC); + } +#endif + @@ -8085,15 +8497,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.c php-5.3.1/ext/apc/apc_mmap.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.h php-5.3.1/ext/apc/apc_mmap.h ---- php-5.3.1.orig/ext/apc/apc_mmap.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_mmap.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_mmap.h @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2009 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -8103,7 +8514,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.h php-5.3.1/ext/apc/apc_mmap.h + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ -+ | Authors: Gopal V ++ | Authors: Gopal V | + +----------------------------------------------------------------------+ + + This software was contributed to PHP by Community Connect Inc. in 2002 @@ -8116,7 +8527,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.h php-5.3.1/ext/apc/apc_mmap.h + + */ + -+/* $Id: apc_mmap.h 273456 2009-01-13 14:43:58Z gopalv $ */ ++/* $Id: apc_mmap.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_MMAP_H +#define APC_MMAP_H @@ -8129,8 +8540,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.h php-5.3.1/ext/apc/apc_mmap.h +/* Wrapper functions for shared memory mapped files */ + +#if APC_MMAP -+apc_segment_t apc_mmap(char *file_mask, size_t size); -+void apc_unmap(apc_segment_t* segment); ++apc_segment_t apc_mmap(char *file_mask, size_t size TSRMLS_DC); ++void apc_unmap(apc_segment_t* segment TSRMLS_DC); +#endif + +#endif @@ -8143,16 +8554,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_mmap.h php-5.3.1/ext/apc/apc_mmap.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc.php php-5.3.1/ext/apc/apc.php ---- php-5.3.1.orig/ext/apc/apc.php 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc.php 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc.php @@ -0,0 +1,1362 @@ +Clear $cache_mode Cache ++
  • Clear $cache_mode Cache
  • +EOB; +} +echo <<", + "",ucwords(preg_replace("/_/"," ",$k)),"", -+ "",(preg_match("/time/",$k) && $value!='None') ? date(DATE_FORMAT,$value) : $value,"", ++ "",(preg_match("/time/",$k) && $value!='None') ? date(DATE_FORMAT,$value) : htmlspecialchars($value, ENT_QUOTES, 'UTF-8'),"", + ""; + $m=1-$m; + } + if($fieldkey=='info') { + echo "Stored Value
    ";
     +					$output = var_export(apc_fetch($entry[$fieldkey]),true);
    -+					echo htmlspecialchars($output);
    ++					echo htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
     +					echo "
    \n"; + } + break; @@ -9486,8 +9896,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.php php-5.3.1/ext/apc/apc.php + } else if (!$i--) { + break; + } -+ echo "".htmlspecialchars($v)."
    "; -+ echo nl2br(htmlspecialchars(current($match[2])))."
    "; ++ echo "".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."
    "; ++ echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."
    "; + next($match[2]); + } + echo ''; @@ -9509,15 +9919,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc.php php-5.3.1/ext/apc/apc.php + + + -diff -Naur php-5.3.1.orig/ext/apc/apc_php.h php-5.3.1/ext/apc/apc_php.h ---- php-5.3.1.orig/ext/apc/apc_php.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_php.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,74 @@ +--- /dev/null ++++ b/ext/apc/apc_php.h +@@ -0,0 +1,77 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -9544,7 +9953,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_php.h php-5.3.1/ext/apc/apc_php.h + + */ + -+/* $Id: apc_php.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_php.h 300979 2010-07-04 10:15:05Z kalle $ */ + +#ifndef APC_PHP_H +#define APC_PHP_H @@ -9562,6 +9971,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_php.h php-5.3.1/ext/apc/apc_php.h +#include "zend_hash.h" +#include "zend_extensions.h" + ++#if ZEND_MODULE_API_NO >= 20100409 ++#define ZEND_ENGINE_2_4 ++#endif +#if ZEND_MODULE_API_NO > 20060613 +#define ZEND_ENGINE_2_3 +#endif @@ -9587,15 +9999,115 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_php.h php-5.3.1/ext/apc/apc_php.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c ---- php-5.3.1.orig/ext/apc/apc_pool.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_pool.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,484 @@ +--- /dev/null ++++ b/ext/apc/apc_php_pcre.h +@@ -0,0 +1,98 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC/PHP Version 5 | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 1997-2010 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.txt | ++ | If you did not receive a copy of the PHP license and are unable to | ++ | obtain it through the world-wide-web, please send a note to | ++ | license@php.net so we can mail you a copy immediately. | ++ +----------------------------------------------------------------------+ ++ | Author: Andrei Zmievski | ++ +----------------------------------------------------------------------+ ++ */ ++ ++/* $Id: apc_php_pcre.h 300979 2010-07-04 10:15:05Z kalle $ */ ++ ++#ifndef PHP_PCRE_H ++#define PHP_PCRE_H ++ ++#if HAVE_PCRE || HAVE_BUNDLED_PCRE ++ ++#if HAVE_BUNDLED_PCRE ++#include "ext/pcre/pcrelib/pcre.h" ++#else ++#include "pcre.h" ++#endif ++ ++#if HAVE_LOCALE_H ++#include ++#endif ++ ++PHP_FUNCTION(preg_match); ++PHP_FUNCTION(preg_match_all); ++PHP_FUNCTION(preg_replace); ++PHP_FUNCTION(preg_replace_callback); ++PHP_FUNCTION(preg_split); ++PHP_FUNCTION(preg_quote); ++PHP_FUNCTION(preg_grep); ++ ++PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC); ++PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *options TSRMLS_DC); ++PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *coptions TSRMLS_DC); ++ ++extern zend_module_entry pcre_module_entry; ++#define pcre_module_ptr &pcre_module_entry ++ ++typedef struct { ++ pcre *re; ++ pcre_extra *extra; ++ int preg_options; ++#if HAVE_SETLOCALE ++ char *locale; ++ unsigned const char *tables; ++#endif ++ int compile_options; ++ int refcount; ++} pcre_cache_entry; ++ ++PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC); ++ ++PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, ++ zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC); ++ ++PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, ++ int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC); ++ ++PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, ++ long limit_val, long flags TSRMLS_DC); ++ ++PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, ++ long flags TSRMLS_DC); ++ ++ZEND_BEGIN_MODULE_GLOBALS(pcre) ++ HashTable pcre_cache; ++ long backtrack_limit; ++ long recursion_limit; ++ int error_code; ++ZEND_END_MODULE_GLOBALS(pcre) ++ ++#ifdef ZTS ++# define PCRE_G(v) TSRMG(pcre_globals_id, zend_pcre_globals *, v) ++#else ++# define PCRE_G(v) (pcre_globals.v) ++#endif ++ ++#else ++ ++#define pcre_module_ptr NULL ++ ++#endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */ ++ ++#define phpext_pcre_ptr pcre_module_ptr ++ ++#endif /* PHP_PCRE_H */ +--- /dev/null ++++ b/ext/apc/apc_pool.c +@@ -0,0 +1,488 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -9618,7 +10130,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + + */ + -+/* $Id: apc_pool.c 281353 2009-05-28 23:45:08Z kalle $ */ ++/* $Id: apc_pool.c 301964 2010-08-07 03:34:18Z rasmus $ */ + + +#include "apc_pool.h" @@ -9630,8 +10142,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + + +/* {{{ forward references */ -+static apc_pool* apc_unpool_create(apc_pool_type type, apc_malloc_t, apc_free_t, apc_protect_t, apc_unprotect_t); -+static apc_pool* apc_realpool_create(apc_pool_type type, apc_malloc_t, apc_free_t, apc_protect_t, apc_unprotect_t); ++static apc_pool* apc_unpool_create(apc_pool_type type, apc_malloc_t, apc_free_t, apc_protect_t, apc_unprotect_t TSRMLS_DC); ++static apc_pool* apc_realpool_create(apc_pool_type type, apc_malloc_t, apc_free_t, apc_protect_t, apc_unprotect_t TSRMLS_DC); +/* }}} */ + +/* {{{ apc_pool_create */ @@ -9639,26 +10151,27 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + apc_malloc_t allocate, + apc_free_t deallocate, + apc_protect_t protect, -+ apc_unprotect_t unprotect) ++ apc_unprotect_t unprotect ++ TSRMLS_DC) +{ + if(pool_type == APC_UNPOOL) { + return apc_unpool_create(pool_type, allocate, deallocate, -+ protect, unprotect ); ++ protect, unprotect TSRMLS_CC); + } + + return apc_realpool_create(pool_type, allocate, deallocate, -+ protect, unprotect ); ++ protect, unprotect TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_pool_destroy */ -+void apc_pool_destroy(apc_pool *pool) ++void apc_pool_destroy(apc_pool *pool TSRMLS_DC) +{ + apc_free_t deallocate = pool->deallocate; + apc_pcleanup_t cleanup = pool->cleanup; + -+ cleanup(pool); -+ deallocate(pool); ++ cleanup(pool TSRMLS_CC); ++ deallocate(pool TSRMLS_CC); +} +/* }}} */ + @@ -9671,7 +10184,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + /* apc_unpool is a lie! */ +}; + -+static void* apc_unpool_alloc(apc_pool* pool, size_t size) ++static void* apc_unpool_alloc(apc_pool* pool, size_t size TSRMLS_DC) +{ + apc_unpool *upool = (apc_unpool*)pool; + @@ -9680,27 +10193,28 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + upool->parent.size += size; + upool->parent.used += size; + -+ return allocate(size); ++ return allocate(size TSRMLS_CC); +} + -+static void apc_unpool_free(apc_pool* pool, void *ptr) ++static void apc_unpool_free(apc_pool* pool, void *ptr TSRMLS_DC) +{ + apc_unpool *upool = (apc_unpool*) pool; + + apc_free_t deallocate = upool->parent.deallocate; + -+ deallocate(ptr); ++ deallocate(ptr TSRMLS_CC); +} + -+static void apc_unpool_cleanup(apc_pool* pool) ++static void apc_unpool_cleanup(apc_pool* pool TSRMLS_DC) +{ +} + +static apc_pool* apc_unpool_create(apc_pool_type type, + apc_malloc_t allocate, apc_free_t deallocate, -+ apc_protect_t protect, apc_unprotect_t unprotect) ++ apc_protect_t protect, apc_unprotect_t unprotect ++ TSRMLS_DC) +{ -+ apc_unpool* upool = allocate(sizeof(apc_unpool)); ++ apc_unpool* upool = allocate(sizeof(apc_unpool) TSRMLS_CC); + + if (!upool) { + return NULL; @@ -9797,13 +10311,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c +} while(0) + +/* {{{ create_pool_block */ -+static pool_block* create_pool_block(apc_realpool *rpool, size_t size) ++static pool_block* create_pool_block(apc_realpool *rpool, size_t size TSRMLS_DC) +{ + apc_malloc_t allocate = rpool->parent.allocate; + + size_t realsize = sizeof(pool_block) + ALIGNWORD(size); + -+ pool_block* entry = allocate(realsize); ++ pool_block* entry = allocate(realsize TSRMLS_CC); + + if (!entry) { + return NULL; @@ -9818,7 +10332,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c +/* }}} */ + +/* {{{ apc_realpool_alloc */ -+static void* apc_realpool_alloc(apc_pool *pool, size_t size) ++static void* apc_realpool_alloc(apc_pool *pool, size_t size TSRMLS_DC) +{ + apc_realpool *rpool = (apc_realpool*)pool; + unsigned char *p = NULL; @@ -9827,9 +10341,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + unsigned char *redzone = NULL; + size_t redsize = 0; + size_t *sizeinfo= NULL; -+ -+ pool_block *entry; -+ ++ pool_block *entry = NULL; ++ + if(APC_POOL_HAS_REDZONES(pool)) { + redsize = REDZONE_SIZE(size); /* redsize might be re-using word size padding */ + realsize = size + redsize; /* recalculating realsize */ @@ -9850,7 +10363,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + + poolsize = ALIGNSIZE(realsize, rpool->dsize); + -+ entry = create_pool_block(rpool, poolsize); ++ entry = create_pool_block(rpool, poolsize TSRMLS_CC); + + if(!entry) { + return NULL; @@ -9951,18 +10464,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c +} +/* }}} */ + -+/* {{{ apc_pool_free */ ++/* {{{ apc_realpool_free */ +/* + * free does not do anything other than + * check for redzone values when free'ing + * data areas. + */ -+static void apc_realpool_free(apc_pool *pool, void *p) ++static void apc_realpool_free(apc_pool *pool, void *p TSRMLS_DC) +{ +} +/* }}} */ + -+static void apc_realpool_cleanup(apc_pool *pool) ++static void apc_realpool_cleanup(apc_pool *pool TSRMLS_DC) +{ + pool_block *entry; + pool_block *tmp; @@ -9975,14 +10488,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + + while(entry->next != NULL) { + tmp = entry->next; -+ deallocate(entry); ++ deallocate(entry TSRMLS_CC); + entry = tmp; + } +} + +/* {{{ apc_realpool_create */ +static apc_pool* apc_realpool_create(apc_pool_type type, apc_malloc_t allocate, apc_free_t deallocate, -+ apc_protect_t protect, apc_unprotect_t unprotect) ++ apc_protect_t protect, apc_unprotect_t unprotect ++ TSRMLS_DC) +{ + + size_t dsize = 0; @@ -10005,7 +10519,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + return NULL; + } + -+ rpool = (apc_realpool*)allocate(sizeof(apc_realpool) + ALIGNWORD(dsize)); ++ rpool = (apc_realpool*)allocate((sizeof(apc_realpool) + ALIGNWORD(dsize)) TSRMLS_CC); + + if(!rpool) { + return NULL; @@ -10043,19 +10557,21 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + /* put all ye sanity checks here */ + assert(sizeof(decaff) > REDZONE_SIZE(ALIGNWORD(sizeof(char)))); + assert(sizeof(pool_block) == ALIGNWORD(sizeof(pool_block))); ++#if APC_POOL_DEBUG + assert((APC_POOL_SIZE_MASK & (APC_POOL_SIZEINFO | APC_POOL_REDZONES)) == 0); ++#endif +} +/* }}} */ + +/* {{{ apc_pstrdup */ -+void* apc_pstrdup(const char* s, apc_pool* pool) ++void* apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC) +{ -+ return s != NULL ? apc_pmemcpy(s, strlen(s)+1, pool) : NULL; ++ return s != NULL ? apc_pmemcpy(s, (strlen(s) + 1), pool TSRMLS_CC) : NULL; +} +/* }}} */ + +/* {{{ apc_pmemcpy */ -+void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool) ++void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool TSRMLS_DC) +{ + void* q; + @@ -10075,15 +10591,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.c php-5.3.1/ext/apc/apc_pool.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_pool.h php-5.3.1/ext/apc/apc_pool.h ---- php-5.3.1.orig/ext/apc/apc_pool.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_pool.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,102 @@ +--- /dev/null ++++ b/ext/apc/apc_pool.h +@@ -0,0 +1,114 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10106,7 +10621,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.h php-5.3.1/ext/apc/apc_pool.h + + */ + -+/* $Id: apc_pool.h 275212 2009-02-05 08:36:26Z gopalv $ */ ++/* $Id: apc_pool.h 301682 2010-07-29 11:09:00Z gopalv $ */ + +#ifndef APC_POOL_H +#define APC_POOL_H @@ -10114,26 +10629,37 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.h php-5.3.1/ext/apc/apc_pool.h +#include "apc.h" +#include "apc_sma.h" + ++/* #define APC_POOL_DEBUG 1 */ ++ +typedef enum { + APC_UNPOOL = 0x0, + APC_SMALL_POOL = 0x1, + APC_MEDIUM_POOL = 0x2, + APC_LARGE_POOL = 0x3, + APC_POOL_SIZE_MASK = 0x7, /* waste a bit */ ++#if APC_POOL_DEBUG + APC_POOL_REDZONES = 0x08, + APC_POOL_SIZEINFO = 0x10, + APC_POOL_OPT_MASK = 0x18 ++#endif +} apc_pool_type; + ++#if APC_POOL_DEBUG +#define APC_POOL_HAS_SIZEINFO(pool) ((pool->type & APC_POOL_SIZEINFO)!=0) +#define APC_POOL_HAS_REDZONES(pool) ((pool->type & APC_POOL_REDZONES)!=0) ++#else ++/* let gcc optimize away the optional features */ ++#define APC_POOL_HAS_SIZEINFO(pool) (0) ++#define APC_POOL_HAS_REDZONES(pool) (0) ++#endif ++ + +typedef struct _apc_pool apc_pool; + -+typedef void (*apc_pcleanup_t)(apc_pool *pool); ++typedef void (*apc_pcleanup_t)(apc_pool *pool TSRMLS_DC); + -+typedef void* (*apc_palloc_t)(apc_pool *pool, size_t size); -+typedef void (*apc_pfree_t) (apc_pool *pool, void* p); ++typedef void* (*apc_palloc_t)(apc_pool *pool, size_t size TSRMLS_DC); ++typedef void (*apc_pfree_t) (apc_pool *pool, void* p TSRMLS_DC); + +typedef void* (*apc_protect_t) (void *p); +typedef void* (*apc_unprotect_t)(void *p); @@ -10158,13 +10684,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.h php-5.3.1/ext/apc/apc_pool.h + /* apc_realpool and apc_unpool add more here */ +}; + -+#define apc_pool_alloc(pool, size) ((pool)->palloc((pool), (size))) -+#define apc_pool_free (pool, ptr) ((pool)->pfree((pool), (ptr))) ++#define apc_pool_alloc(pool, size) ((void *) pool->palloc(pool, size TSRMLS_CC)) ++#define apc_pool_free(pool, ptr) ((void) pool->pfree (pool, ptr TSRMLS_CC)) + -+#define apc_pool_protect (pool, ptr) (pool->protect ? \ ++#define apc_pool_protect(pool, ptr) (pool->protect ? \ + (pool)->protect((ptr)) : (ptr)) + -+#define apc_pool_unprotect (pool, ptr) (pool->unprotect ? \ ++#define apc_pool_unprotect(pool, ptr) (pool->unprotect ? \ + (pool)->unprotect((ptr)) : (ptr)) + +extern void apc_pool_init(); @@ -10173,23 +10699,23 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pool.h php-5.3.1/ext/apc/apc_pool.h + apc_malloc_t allocate, + apc_free_t deallocate, + apc_protect_t protect, -+ apc_unprotect_t unprotect); ++ apc_unprotect_t unprotect ++ TSRMLS_DC); + -+extern void apc_pool_destroy(apc_pool* pool); ++extern void apc_pool_destroy(apc_pool* pool TSRMLS_DC); + -+extern void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool); -+extern void* apc_pstrdup(const char* s, apc_pool* pool); ++extern void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool TSRMLS_DC); ++extern void* apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC); + +#endif -diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthreadmutex.c ---- php-5.3.1.orig/ext/apc/apc_pthreadmutex.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_pthreadmutex.c 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_pthreadmutex.c @@ -0,0 +1,111 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10204,13 +10730,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthre + + */ + -+/* $Id: apc_pthreadmutex.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_pthreadmutex.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc_pthreadmutex.h" + +#ifdef APC_PTHREADMUTEX_LOCKS + -+pthread_mutex_t *apc_pthreadmutex_create(pthread_mutex_t *lock) ++pthread_mutex_t *apc_pthreadmutex_create(pthread_mutex_t *lock TSRMLS_DC) +{ + int result; + pthread_mutexattr_t* attr; @@ -10218,32 +10744,32 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthre + + result = pthread_mutexattr_init(attr); + if(result == ENOMEM) { -+ apc_eprint("pthread mutex error: Insufficient memory exists to create the mutex attribute object."); ++ apc_error("pthread mutex error: Insufficient memory exists to create the mutex attribute object." TSRMLS_CC); + } else if(result == EINVAL) { -+ apc_eprint("pthread mutex error: attr does not point to writeable memory."); ++ apc_error("pthread mutex error: attr does not point to writeable memory." TSRMLS_CC); + } else if(result == EFAULT) { -+ apc_eprint("pthread mutex error: attr is an invalid pointer."); ++ apc_error("pthread mutex error: attr is an invalid pointer." TSRMLS_CC); + } + +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + result = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ADAPTIVE_NP); + if (result == EINVAL) { -+ apc_eprint("pthread_mutexattr_settype: unable to set adaptive mutexes"); ++ apc_error("pthread_mutexattr_settype: unable to set adaptive mutexes" TSRMLS_CC); + } +#endif + + /* pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ERRORCHECK); */ + result = pthread_mutexattr_setpshared(attr, PTHREAD_PROCESS_SHARED); + if(result == EINVAL) { -+ apc_eprint("pthread mutex error: attr is not an initialized mutex attribute object, or pshared is not a valid process-shared state setting."); ++ apc_error("pthread mutex error: attr is not an initialized mutex attribute object, or pshared is not a valid process-shared state setting." TSRMLS_CC); + } else if(result == EFAULT) { -+ apc_eprint("pthread mutex error: attr is an invalid pointer."); ++ apc_error("pthread mutex error: attr is an invalid pointer." TSRMLS_CC); + } else if(result == ENOTSUP) { -+ apc_eprint("pthread mutex error: pshared was set to PTHREAD_PROCESS_SHARED."); ++ apc_error("pthread mutex error: pshared was set to PTHREAD_PROCESS_SHARED." TSRMLS_CC); + } + + if(pthread_mutex_init(lock, attr)) { -+ apc_eprint("unable to initialize pthread lock"); ++ apc_error("unable to initialize pthread lock" TSRMLS_CC); + } + return lock; +} @@ -10253,25 +10779,25 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthre + return; /* we don't actually destroy the mutex, as it would destroy it for all processes */ +} + -+void apc_pthreadmutex_lock(pthread_mutex_t *lock) ++void apc_pthreadmutex_lock(pthread_mutex_t *lock TSRMLS_DC) +{ + int result; + result = pthread_mutex_lock(lock); + if(result == EINVAL) { -+ apc_eprint("unable to obtain pthread lock (EINVAL)"); ++ apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); + } else if(result == EDEADLK) { -+ apc_eprint("unable to obtain pthread lock (EDEADLK)"); ++ apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); + } +} + -+void apc_pthreadmutex_unlock(pthread_mutex_t *lock) ++void apc_pthreadmutex_unlock(pthread_mutex_t *lock TSRMLS_DC) +{ + if(pthread_mutex_unlock(lock)) { -+ apc_eprint("unable to unlock pthread lock"); ++ apc_error("unable to unlock pthread lock" TSRMLS_CC); + } +} + -+zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock) ++zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock TSRMLS_DC) +{ + int rval; + rval = pthread_mutex_trylock(lock); @@ -10280,7 +10806,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthre + } else if(rval == 0) { /* Obtained lock */ + return 1; + } else { /* Other error */ -+ apc_eprint("unable to obtain pthread trylock"); ++ apc_error("unable to obtain pthread trylock" TSRMLS_CC); + return 0; + } +} @@ -10296,15 +10822,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.c php-5.3.1/ext/apc/apc_pthre + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.h php-5.3.1/ext/apc/apc_pthreadmutex.h ---- php-5.3.1.orig/ext/apc/apc_pthreadmutex.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_pthreadmutex.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_pthreadmutex.h @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10319,7 +10844,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.h php-5.3.1/ext/apc/apc_pthre + + */ + -+/* $Id: apc_pthreadmutex.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_pthreadmutex.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_PTHREADMUTEX_H +#define APC_PTHREADMUTEX_H @@ -10330,11 +10855,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.h php-5.3.1/ext/apc/apc_pthre + +#include + -+pthread_mutex_t *apc_pthreadmutex_create(); ++pthread_mutex_t *apc_pthreadmutex_create(pthread_mutex_t *lock TSRMLS_DC); +void apc_pthreadmutex_destroy(pthread_mutex_t *lock); -+void apc_pthreadmutex_lock(pthread_mutex_t *lock); -+void apc_pthreadmutex_unlock(pthread_mutex_t *lock); -+zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock); ++void apc_pthreadmutex_lock(pthread_mutex_t *lock TSRMLS_DC); ++void apc_pthreadmutex_unlock(pthread_mutex_t *lock TSRMLS_DC); ++zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock TSRMLS_DC); + +#endif + @@ -10348,15 +10873,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_pthreadmutex.h php-5.3.1/ext/apc/apc_pthre + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c ---- php-5.3.1.orig/ext/apc/apc_rfc1867.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_rfc1867.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,214 @@ +--- /dev/null ++++ b/ext/apc/apc_rfc1867.c +@@ -0,0 +1,232 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10379,7 +10903,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + + */ + -+/* $Id: apc_rfc1867.c 284580 2009-07-22 06:05:31Z kalle $*/ ++/* $Id: apc_rfc1867.c 305798 2010-11-28 13:43:20Z gopalv $*/ + +#include "apc.h" +#include "apc_globals.h" @@ -10443,8 +10967,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + RFC1867_DATA(key_length) = 0; + RFC1867_DATA(start_time) = my_time(); + RFC1867_DATA(bytes_processed) = 0; ++ RFC1867_DATA(prev_bytes_processed) = 0; + RFC1867_DATA(rate) = 0; + RFC1867_DATA(update_freq) = (int) APCG(rfc1867_freq); ++ RFC1867_DATA(started) = 0; + + if(RFC1867_DATA(update_freq) < 0) { // frequency is a percentage, not bytes + RFC1867_DATA(update_freq) = (int) (RFC1867_DATA(content_length) * APCG(rfc1867_freq) / 100); @@ -10457,7 +10983,20 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + int prefix_len = strlen(APCG(rfc1867_prefix)); + multipart_event_formdata *data = (multipart_event_formdata *) event_data; + if(data->name && !strncasecmp(data->name, APCG(rfc1867_name), strlen(APCG(rfc1867_name))) -+ && data->value && data->length && data->length < sizeof(RFC1867_DATA(tracking_key)) - prefix_len) { ++ && data->value && data->length) { ++ ++ if(data->length >= sizeof(RFC1867_DATA(tracking_key)) - prefix_len) { ++ apc_warning("Key too long for '%s'. Maximum size is '%d' characters." TSRMLS_CC, ++ APCG(rfc1867_name), ++ sizeof(RFC1867_DATA(tracking_key)) - prefix_len); ++ break; ++ } ++ ++ if(RFC1867_DATA(started)) { ++ apc_warning("Upload progress key '%s' should be before the file upload entry in the form." TSRMLS_CC, ++ APCG(rfc1867_name)); ++ break; ++ } + + strlcat(RFC1867_DATA(tracking_key), APCG(rfc1867_prefix), 63); + strlcat(RFC1867_DATA(tracking_key), *data->value, 63); @@ -10468,23 +11007,26 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + break; + + case MULTIPART_EVENT_FILE_START: -+ if(*RFC1867_DATA(tracking_key)) { -+ multipart_event_file_start *data = (multipart_event_file_start *) event_data; ++ { ++ RFC1867_DATA(started) = 1; ++ if(*RFC1867_DATA(tracking_key)) { ++ multipart_event_file_start *data = (multipart_event_file_start *) event_data; + -+ RFC1867_DATA(bytes_processed) = data->post_bytes_processed; -+ strncpy(RFC1867_DATA(filename),*data->filename,127); -+ RFC1867_DATA(temp_filename) = NULL; -+ strncpy(RFC1867_DATA(name),data->name,63); -+ ALLOC_INIT_ZVAL(track); -+ array_init(track); -+ add_assoc_long(track, "total", RFC1867_DATA(content_length)); -+ add_assoc_long(track, "current", RFC1867_DATA(bytes_processed)); -+ add_assoc_string(track, "filename", RFC1867_DATA(filename), 1); -+ add_assoc_string(track, "name", RFC1867_DATA(name), 1); -+ add_assoc_long(track, "done", 0); -+ add_assoc_double(track, "start_time", RFC1867_DATA(start_time)); -+ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length), track, 3600, 0 TSRMLS_CC); -+ zval_ptr_dtor(&track); ++ RFC1867_DATA(bytes_processed) = data->post_bytes_processed; ++ strlcpy(RFC1867_DATA(filename),*data->filename,128); ++ RFC1867_DATA(temp_filename) = NULL; ++ strlcpy(RFC1867_DATA(name),data->name,64); ++ ALLOC_INIT_ZVAL(track); ++ array_init(track); ++ add_assoc_long(track, "total", RFC1867_DATA(content_length)); ++ add_assoc_long(track, "current", RFC1867_DATA(bytes_processed)); ++ add_assoc_string(track, "filename", RFC1867_DATA(filename), 1); ++ add_assoc_string(track, "name", RFC1867_DATA(name), 1); ++ add_assoc_long(track, "done", 0); ++ add_assoc_double(track, "start_time", RFC1867_DATA(start_time)); ++ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC); ++ zval_ptr_dtor(&track); ++ } + } + break; + @@ -10502,7 +11044,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + add_assoc_string(track, "name", RFC1867_DATA(name), 1); + add_assoc_long(track, "done", 0); + add_assoc_double(track, "start_time", RFC1867_DATA(start_time)); -+ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length), track, 3600, 0 TSRMLS_CC); ++ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC); + zval_ptr_dtor(&track); + } + RFC1867_DATA(prev_bytes_processed) = RFC1867_DATA(bytes_processed); @@ -10526,7 +11068,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + add_assoc_long(track, "cancel_upload", RFC1867_DATA(cancel_upload)); + add_assoc_long(track, "done", 0); + add_assoc_double(track, "start_time", RFC1867_DATA(start_time)); -+ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length), track, 3600, 0 TSRMLS_CC); ++ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC); + zval_ptr_dtor(&track); + } + break; @@ -10548,7 +11090,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + add_assoc_long(track, "cancel_upload", RFC1867_DATA(cancel_upload)); + add_assoc_long(track, "done", 1); + add_assoc_double(track, "start_time", RFC1867_DATA(start_time)); -+ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length), track, APCG(rfc1867_ttl), 0 TSRMLS_CC); ++ _apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC); + zval_ptr_dtor(&track); + } + break; @@ -10566,15 +11108,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_rfc1867.c php-5.3.1/ext/apc/apc_rfc1867.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c ---- php-5.3.1.orig/ext/apc/apc_sem.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_sem.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,201 @@ +--- /dev/null ++++ b/ext/apc/apc_sem.c +@@ -0,0 +1,192 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10597,7 +11138,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + + */ + -+/* $Id: apc_sem.c 268620 2008-11-09 02:30:49Z shire $ */ ++/* $Id: apc_sem.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc.h" + @@ -10641,38 +11182,29 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c +# define UNDO 0 +#endif + -+int apc_sem_create(const char* pathname, int proj, int initval) ++int apc_sem_create(int proj, int initval TSRMLS_DC) +{ + int semid; -+ int perms; ++ int perms = 0777; + union semun arg; -+ key_t key; -+ -+ perms = 0777; -+ -+ key = IPC_PRIVATE; -+ if (pathname != NULL) { -+ if ((key = ftok(pathname, proj)) < 0) { -+ apc_eprint("apc_sem_create: ftok(%s,%d) failed:", pathname, proj); -+ } -+ } ++ key_t key = IPC_PRIVATE; + + if ((semid = semget(key, 1, IPC_CREAT | IPC_EXCL | perms)) >= 0) { + /* sempahore created for the first time, initialize now */ + arg.val = initval; + if (semctl(semid, 0, SETVAL, arg) < 0) { -+ apc_eprint("apc_sem_create: semctl(%d,...) failed:", semid); ++ apc_error("apc_sem_create: semctl(%d,...) failed:" TSRMLS_CC, semid); + } + } + else if (errno == EEXIST) { + /* sempahore already exists, don't initialize */ + if ((semid = semget(key, 1, perms)) < 0) { -+ apc_eprint("apc_sem_create: semget(%u,...) failed:", key); ++ apc_error("apc_sem_create: semget(%u,...) failed:" TSRMLS_CC, key); + } + /* insert here */ + } + else { -+ apc_eprint("apc_sem_create: semget(%u,...) failed:", key); ++ apc_error("apc_sem_create: semget(%u,...) failed:" TSRMLS_CC, key); + } + + return semid; @@ -10685,7 +11217,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + semctl(semid, 0, IPC_RMID, arg); +} + -+void apc_sem_lock(int semid) ++void apc_sem_lock(int semid TSRMLS_DC) +{ + struct sembuf op; + @@ -10695,12 +11227,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + + if (semop(semid, &op, 1) < 0) { + if (errno != EINTR) { -+ apc_eprint("apc_sem_lock: semop(%d) failed:", semid); ++ apc_error("apc_sem_lock: semop(%d) failed:" TSRMLS_CC, semid); + } + } +} + -+int apc_sem_nonblocking_lock(int semid) ++int apc_sem_nonblocking_lock(int semid TSRMLS_DC) +{ + struct sembuf op; + @@ -10712,14 +11244,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + if (errno == EAGAIN) { + return 0; /* Lock is already held */ + } else if (errno != EINTR) { -+ apc_eprint("apc_sem_lock: semop(%d) failed:", semid); ++ apc_error("apc_sem_lock: semop(%d) failed:" TSRMLS_CC, semid); + } + } + + return 1; /* Lock obtained */ +} + -+void apc_sem_unlock(int semid) ++void apc_sem_unlock(int semid TSRMLS_DC) +{ + struct sembuf op; + @@ -10729,12 +11261,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + + if (semop(semid, &op, 1) < 0) { + if (errno != EINTR) { -+ apc_eprint("apc_sem_unlock: semop(%d) failed:", semid); ++ apc_error("apc_sem_unlock: semop(%d) failed:" TSRMLS_CC, semid); + } + } +} + -+void apc_sem_wait_for_zero(int semid) ++void apc_sem_wait_for_zero(int semid TSRMLS_DC) +{ + struct sembuf op; + @@ -10744,19 +11276,19 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + + if (semop(semid, &op, 1) < 0) { + if (errno != EINTR) { -+ apc_eprint("apc_sem_waitforzero: semop(%d) failed:", semid); ++ apc_error("apc_sem_waitforzero: semop(%d) failed:" TSRMLS_CC, semid); + } + } +} + -+int apc_sem_get_value(int semid) ++int apc_sem_get_value(int semid TSRMLS_DC) +{ + union semun arg; + unsigned short val[1]; + + arg.array = val; + if (semctl(semid, 0, GETALL, arg) < 0) { -+ apc_eprint("apc_sem_getvalue: semctl(%d,...) failed:", semid); ++ apc_error("apc_sem_getvalue: semctl(%d,...) failed:" TSRMLS_CC, semid); + } + return val[0]; +} @@ -10771,15 +11303,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.c php-5.3.1/ext/apc/apc_sem.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_sem.h php-5.3.1/ext/apc/apc_sem.h ---- php-5.3.1.orig/ext/apc/apc_sem.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_sem.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_sem.h @@ -0,0 +1,52 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10802,20 +11333,20 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.h php-5.3.1/ext/apc/apc_sem.h + + */ + -+/* $Id: apc_sem.h 268620 2008-11-09 02:30:49Z shire $ */ ++/* $Id: apc_sem.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_SEM_H +#define APC_SEM_H + +/* Wrapper functions for SysV sempahores */ + -+extern int apc_sem_create(const char* pathname, int proj, int initval); ++extern int apc_sem_create(int proj, int initval TSRMLS_DC); +extern void apc_sem_destroy(int semid); -+extern void apc_sem_lock(int semid); -+extern int apc_sem_nonblocking_lock(int semid); -+extern void apc_sem_unlock(int semid); -+extern void apc_sem_wait_for_zero(int semid); -+extern int apc_sem_get_value(int semid); ++extern void apc_sem_lock(int semid TSRMLS_DC); ++extern int apc_sem_nonblocking_lock(int semid TSRMLS_DC); ++extern void apc_sem_unlock(int semid TSRMLS_DC); ++extern void apc_sem_wait_for_zero(int semid TSRMLS_DC); ++extern int apc_sem_get_value(int semid TSRMLS_DC); + +#endif + @@ -10827,15 +11358,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sem.h php-5.3.1/ext/apc/apc_sem.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c ---- php-5.3.1.orig/ext/apc/apc_shm.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_shm.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,124 @@ +--- /dev/null ++++ b/ext/apc/apc_shm.c +@@ -0,0 +1,114 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10859,7 +11389,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c + + */ + -+/* $Id: apc_shm.c 273457 2009-01-13 15:16:42Z gopalv $ */ ++/* $Id: apc_shm.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc_shm.h" +#include "apc.h" @@ -10880,25 +11410,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c +# define SHM_A 0222 /* write permission */ +#endif + -+int apc_shm_create(const char* pathname, int proj, size_t size) ++int apc_shm_create(int proj, size_t size TSRMLS_DC) +{ -+ int shmid; /* shared memory id */ -+ int oflag; /* permissions on shm */ -+ key_t key; /* shm key returned by ftok */ -+ -+ key = IPC_PRIVATE; -+#ifndef PHP_WIN32 -+ /* no ftok yet for win32 */ -+ if (pathname != NULL) { -+ if ((key = ftok(pathname, proj)) < 0) { -+ apc_eprint("apc_shm_create: ftok failed:"); -+ } -+ } -+#endif ++ int shmid; /* shared memory id */ ++ int oflag; /* permissions on shm */ ++ key_t key = IPC_PRIVATE; /* shm key */ + + oflag = IPC_CREAT | SHM_R | SHM_A; + if ((shmid = shmget(key, size, oflag)) < 0) { -+ apc_eprint("apc_shm_create: shmget(%d, %d, %d) failed: %s. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment.", key, size, oflag, strerror(errno)); ++ apc_error("apc_shm_create: shmget(%d, %d, %d) failed: %s. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment." TSRMLS_CC, key, size, oflag, strerror(errno)); + } + + return shmid; @@ -10910,12 +11430,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c + shmctl(shmid, IPC_RMID, 0); +} + -+apc_segment_t apc_shm_attach(int shmid) ++apc_segment_t apc_shm_attach(int shmid TSRMLS_DC) +{ + apc_segment_t segment; /* shm segment */ + + if ((long)(segment.shmaddr = shmat(shmid, 0, 0)) == -1) { -+ apc_eprint("apc_shm_attach: shmat failed:"); ++ apc_error("apc_shm_attach: shmat failed:" TSRMLS_CC); + } + +#ifdef APC_MEMPROTECT @@ -10934,15 +11454,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c + return segment; +} + -+void apc_shm_detach(apc_segment_t* segment) ++void apc_shm_detach(apc_segment_t* segment TSRMLS_DC) +{ + if (shmdt(segment->shmaddr) < 0) { -+ apc_eprint("apc_shm_detach: shmdt failed:"); ++ apc_error("apc_shm_detach: shmdt failed:" TSRMLS_CC); + } + +#ifdef APC_MEMPROTECT + if (segment->roaddr && shmdt(segment->roaddr) < 0) { -+ apc_eprint("apc_shm_detach: shmdt failed:"); ++ apc_error("apc_shm_detach: shmdt failed:" TSRMLS_CC); + } +#endif +} @@ -10955,15 +11475,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.c php-5.3.1/ext/apc/apc_shm.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_shm.h php-5.3.1/ext/apc/apc_shm.h ---- php-5.3.1.orig/ext/apc/apc_shm.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_shm.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_shm.h @@ -0,0 +1,56 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -10986,7 +11505,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.h php-5.3.1/ext/apc/apc_shm.h + + */ + -+/* $Id: apc_shm.h 273456 2009-01-13 14:43:58Z gopalv $ */ ++/* $Id: apc_shm.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_SHM_H +#define APC_SHM_H @@ -11000,10 +11519,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.h php-5.3.1/ext/apc/apc_shm.h + +/* Wrapper functions for unix shared memory */ + -+extern int apc_shm_create(const char* name, int proj, size_t size); ++extern int apc_shm_create(int proj, size_t size TSRMLS_DC); +extern void apc_shm_destroy(int shmid); -+extern apc_segment_t apc_shm_attach(int shmid); -+extern void apc_shm_detach(apc_segment_t* segment); ++extern apc_segment_t apc_shm_attach(int shmid TSRMLS_DC); ++extern void apc_shm_detach(apc_segment_t* segment TSRMLS_DC); + +#endif + @@ -11015,15 +11534,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_shm.h php-5.3.1/ext/apc/apc_shm.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c ---- php-5.3.1.orig/ext/apc/apc_signal.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_signal.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,195 @@ +--- /dev/null ++++ b/ext/apc/apc_signal.c +@@ -0,0 +1,197 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11045,7 +11563,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + All other licensing and usage conditions are those of the PHP Group. + */ + -+ /* $Id: apc_signal.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++ /* $Id: apc_signal.c 302175 2010-08-13 06:20:28Z kalle $ */ + + /* Allows apc to install signal handlers and maintain signalling + to already registered handlers. Registers all signals that @@ -11065,7 +11583,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + +static apc_signal_info_t apc_signal_info = {0}; + -+static int apc_register_signal(int signo, void (*handler)(int, siginfo_t*, void*)); ++static int apc_register_signal(int signo, void (*handler)(int, siginfo_t*, void*) TSRMLS_DC); +static void apc_rehandle_signal(int signo, siginfo_t *siginfo, void *context); +static void apc_core_unmap(int signo, siginfo_t *siginfo, void *context); + @@ -11074,7 +11592,9 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + */ +static void apc_core_unmap(int signo, siginfo_t *siginfo, void *context) +{ -+ apc_sma_cleanup(); ++ TSRMLS_FETCH(); ++ ++ apc_sma_cleanup(TSRMLS_C); + apc_rehandle_signal(signo, siginfo, context); + +#if !defined(WIN32) && !defined(NETWARE) @@ -11109,7 +11629,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + * Set a handler for a previously installed signal and save so we can + * callback when handled + */ -+static int apc_register_signal(int signo, void (*handler)(int, siginfo_t*, void*)) ++static int apc_register_signal(int signo, void (*handler)(int, siginfo_t*, void*) TSRMLS_DC) +{ + struct sigaction sa = {{0}}; + apc_signal_entry_t p_sig = {0}; @@ -11124,8 +11644,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + p_sig.siginfo = ((sa.sa_flags & SA_SIGINFO) == SA_SIGINFO); + p_sig.handler = (void *)sa.sa_handler; + -+ apc_signal_info.prev = (apc_signal_entry_t **)apc_erealloc(apc_signal_info.prev, (apc_signal_info.installed+1)*sizeof(apc_signal_entry_t *)); -+ apc_signal_info.prev[apc_signal_info.installed] = (apc_signal_entry_t *)apc_emalloc(sizeof(apc_signal_entry_t)); ++ apc_signal_info.prev = (apc_signal_entry_t **)apc_erealloc(apc_signal_info.prev, (apc_signal_info.installed+1)*sizeof(apc_signal_entry_t *) TSRMLS_CC); ++ apc_signal_info.prev[apc_signal_info.installed] = (apc_signal_entry_t *)apc_emalloc(sizeof(apc_signal_entry_t) TSRMLS_CC); + *apc_signal_info.prev[apc_signal_info.installed++] = p_sig; + } else { + /* inherit flags and mask if already set */ @@ -11141,7 +11661,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + sa.sa_handler = (void*)handler; + + if (sigaction(signo, &sa, NULL) < 0) { -+ apc_wprint("Error installing apc signal handler for %d", signo); ++ apc_warning("Error installing apc signal handler for %d" TSRMLS_CC, signo); + } + + return SUCCESS; @@ -11155,51 +11675,51 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c +{ + if (APCG(coredump_unmap) && apc_signal_info.installed == 0) { + /* ISO C standard signals that coredump */ -+ apc_register_signal(SIGSEGV, apc_core_unmap); -+ apc_register_signal(SIGABRT, apc_core_unmap); -+ apc_register_signal(SIGFPE, apc_core_unmap); -+ apc_register_signal(SIGILL, apc_core_unmap); ++ apc_register_signal(SIGSEGV, apc_core_unmap TSRMLS_CC); ++ apc_register_signal(SIGABRT, apc_core_unmap TSRMLS_CC); ++ apc_register_signal(SIGFPE, apc_core_unmap TSRMLS_CC); ++ apc_register_signal(SIGILL, apc_core_unmap TSRMLS_CC); + /* extended signals that coredump */ +#ifdef SIGBUS -+ apc_register_signal(SIGBUS, apc_core_unmap); ++ apc_register_signal(SIGBUS, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGABORT -+ apc_register_signal(SIGABORT, apc_core_unmap); ++ apc_register_signal(SIGABORT, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGEMT -+ apc_register_signal(SIGEMT, apc_core_unmap); ++ apc_register_signal(SIGEMT, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGIOT -+ apc_register_signal(SIGIOT, apc_core_unmap); ++ apc_register_signal(SIGIOT, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGQUIT -+ apc_register_signal(SIGQUIT, apc_core_unmap); ++ apc_register_signal(SIGQUIT, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGSYS -+ apc_register_signal(SIGSYS, apc_core_unmap); ++ apc_register_signal(SIGSYS, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGTRAP -+ apc_register_signal(SIGTRAP, apc_core_unmap); ++ apc_register_signal(SIGTRAP, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGXCPU -+ apc_register_signal(SIGXCPU, apc_core_unmap); ++ apc_register_signal(SIGXCPU, apc_core_unmap TSRMLS_CC); +#endif +#ifdef SIGXFSZ -+ apc_register_signal(SIGXFSZ, apc_core_unmap); ++ apc_register_signal(SIGXFSZ, apc_core_unmap TSRMLS_CC); +#endif + } +} /* }}} */ + +/* {{{ apc_set_signals + * cleanup signals for shutdown */ -+void apc_shutdown_signals() ++void apc_shutdown_signals(TSRMLS_D) +{ + int i=0; + if (apc_signal_info.installed > 0) { + for (i=0; (i < apc_signal_info.installed); i++) { -+ apc_efree(apc_signal_info.prev[i]); ++ apc_efree(apc_signal_info.prev[i] TSRMLS_CC); + } -+ apc_efree(apc_signal_info.prev); ++ apc_efree(apc_signal_info.prev TSRMLS_CC); + apc_signal_info.installed = 0; /* just in case */ + } +} @@ -11214,15 +11734,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.c php-5.3.1/ext/apc/apc_signal.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_signal.h php-5.3.1/ext/apc/apc_signal.h ---- php-5.3.1.orig/ext/apc/apc_signal.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_signal.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_signal.h @@ -0,0 +1,51 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11237,7 +11756,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.h php-5.3.1/ext/apc/apc_signal.h + + */ + -+/* $Id: apc_signal.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_signal.h 300986 2010-07-04 14:41:33Z felipe $ */ + +#ifndef APC_SIGNAL_H +#define APC_SIGNAL_H @@ -11257,7 +11776,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.h php-5.3.1/ext/apc/apc_signal.h +} apc_signal_info_t; + +void apc_set_signals(TSRMLS_D); -+void apc_shutdown_signals(); ++void apc_shutdown_signals(TSRMLS_D); + +#endif + @@ -11269,15 +11788,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_signal.h php-5.3.1/ext/apc/apc_signal.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c ---- php-5.3.1.orig/ext/apc/apc_sma.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_sma.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,738 @@ +--- /dev/null ++++ b/ext/apc/apc_sma.c +@@ -0,0 +1,765 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -11301,7 +11819,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + + */ + -+/* $Id: apc_sma.c 284580 2009-07-22 06:05:31Z kalle $ */ ++/* $Id: apc_sma.c 305260 2010-11-10 19:23:02Z gopalv $ */ + +#include "apc_sma.h" +#include "apc.h" @@ -11399,26 +11917,26 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +/* {{{ sma_debug_state(apc_sma_segment_t *segment, int canary_check, int verbose) + * useful for debuging state of memory blocks and free list, and sanity checking + */ -+static void sma_debug_state(void* shmaddr, int canary_check, int verbose) { ++static void sma_debug_state(void* shmaddr, int canary_check, int verbose TSRMLS_DC) { + sma_header_t *header = (sma_header_t*)shmaddr; + block_t *cur = BLOCKAT(ALIGNWORD(sizeof(sma_header_t))); + block_t *prv = NULL; + size_t avail; + + /* Verify free list */ -+ if (verbose) apc_wprint("Free List: "); ++ if (verbose) apc_warning("Free List: " TSRMLS_CC); + while(1) { -+ if (verbose) apc_wprint(" 0x%x[%d] (s%d)", cur, OFFSET(cur), cur->size); ++ if (verbose) apc_warning(" 0x%x[%d] (s%d)" TSRMLS_CC, cur, OFFSET(cur), cur->size); + if (canary_check) CHECK_CANARY(cur); + if (!cur->fnext) break; + cur = BLOCKAT(cur->fnext); + avail += cur->size; + if (prv == cur) { -+ apc_wprint("Circular list detected!"); ++ apc_warning("Circular list detected!" TSRMLS_CC); + assert(0); + } + if (prv && cur->fprev != OFFSET(prv)) { -+ apc_wprint("Previous pointer does not point to previous!"); ++ apc_warning("Previous pointer does not point to previous!" TSRMLS_CC); + assert(0); + } + prv = cur; @@ -11426,13 +11944,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + assert(avail == header->avail); + + /* Verify each block */ -+ if (verbose) apc_wprint("Block List: "); ++ if (verbose) apc_warning("Block List: " TSRMLS_CC); + cur = BLOCKAT(ALIGNWORD(sizeof(sma_header_t))); + while(1) { + if(!cur->fnext) { -+ if (verbose) apc_wprint(" 0x%x[%d] (s%d) (u)", cur, OFFSET(cur), cur->size); ++ if (verbose) apc_warning(" 0x%x[%d] (s%d) (u)" TSRMLS_CC, cur, OFFSET(cur), cur->size); + } else { -+ if (verbose) apc_wprint(" 0x%x[%d] (s%d) (f)", cur, OFFSET(cur), cur->size); ++ if (verbose) apc_warning(" 0x%x[%d] (s%d) (f)" TSRMLS_CC, cur, OFFSET(cur), cur->size); + } + if (canary_check) CHECK_CANARY(cur); + if (!cur->size && !cur->fnext) break; @@ -11442,7 +11960,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + cur = NEXT_SBLOCK(cur); + } + if (prv == cur) { -+ apc_wprint("Circular list detected!"); ++ apc_warning("Circular list detected!" TSRMLS_CC); + assert(0); + } + prv = cur; @@ -11608,7 +12126,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + +/* {{{ apc_sma_init */ + -+void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask) ++void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask TSRMLS_DC) +{ + uint i; + @@ -11635,18 +12153,18 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + + sma_segsize = segsize > 0 ? segsize : DEFAULT_SEGSIZE; + -+ sma_segments = (apc_segment_t*) apc_emalloc(sma_numseg*sizeof(apc_segment_t)); ++ sma_segments = (apc_segment_t*) apc_emalloc((sma_numseg * sizeof(apc_segment_t)) TSRMLS_CC); + + for (i = 0; i < sma_numseg; i++) { + sma_header_t* header; -+ block_t* block; ++ block_t *first, *empty, *last; + void* shmaddr; + +#if APC_MMAP -+ sma_segments[i] = apc_mmap(mmap_file_mask, sma_segsize); ++ sma_segments[i] = apc_mmap(mmap_file_mask, sma_segsize TSRMLS_CC); + if(sma_numseg != 1) memcpy(&mmap_file_mask[strlen(mmap_file_mask)-6], "XXXXXX", 6); +#else -+ sma_segments[i] = apc_shm_attach(apc_shm_create(NULL, i, sma_segsize)); ++ sma_segments[i] = apc_shm_attach(apc_shm_create(i, sma_segsize TSRMLS_CC) TSRMLS_CC); +#endif + + sma_segments[i].size = sma_segsize; @@ -11663,39 +12181,39 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + for(j=0; j<30; j++) header->adist[j] = 0; + } +#endif -+ block = BLOCKAT(ALIGNWORD(sizeof(sma_header_t))); -+ block->size = 0; -+ block->fnext = ALIGNWORD(sizeof(sma_header_t)) + ALIGNWORD(sizeof(block_t)); -+ block->fprev = 0; -+ block->prev_size = 0; -+ SET_CANARY(block); ++ first = BLOCKAT(ALIGNWORD(sizeof(sma_header_t))); ++ first->size = 0; ++ first->fnext = ALIGNWORD(sizeof(sma_header_t)) + ALIGNWORD(sizeof(block_t)); ++ first->fprev = 0; ++ first->prev_size = 0; ++ SET_CANARY(first); +#ifdef __APC_SMA_DEBUG__ + block->id = -1; +#endif -+ block = BLOCKAT(block->fnext); -+ block->size = header->avail - ALIGNWORD(sizeof(block_t)); -+ block->fnext = OFFSET(block) + block->size; -+ block->fprev = ALIGNWORD(sizeof(sma_header_t)); -+ block->prev_size = 0; -+ SET_CANARY(block); ++ empty = BLOCKAT(first->fnext); ++ empty->size = header->avail - ALIGNWORD(sizeof(block_t)); ++ empty->fnext = OFFSET(empty) + empty->size; ++ empty->fprev = ALIGNWORD(sizeof(sma_header_t)); ++ empty->prev_size = 0; ++ SET_CANARY(empty); +#ifdef __APC_SMA_DEBUG__ -+ block->id = -1; ++ empty->id = -1; +#endif -+ block = BLOCKAT(block->fnext); -+ block->size = 0; -+ block->fnext = 0; -+ block->fprev = ALIGNWORD(sizeof(sma_header_t)) + ALIGNWORD(sizeof(block_t)); -+ block->prev_size = header->avail - ALIGNWORD(sizeof(block_t)); -+ SET_CANARY(block); ++ last = BLOCKAT(empty->fnext); ++ last->size = 0; ++ last->fnext = 0; ++ last->fprev = OFFSET(empty); ++ last->prev_size = empty->size; ++ SET_CANARY(last); +#ifdef __APC_SMA_DEBUG__ -+ block->id = -1; ++ last->id = -1; +#endif + } +} +/* }}} */ + +/* {{{ apc_sma_cleanup */ -+void apc_sma_cleanup() ++void apc_sma_cleanup(TSRMLS_D) +{ + uint i; + @@ -11704,23 +12222,24 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + for (i = 0; i < sma_numseg; i++) { + apc_lck_destroy(SMA_LCK(i)); +#if APC_MMAP -+ apc_unmap(&sma_segments[i]); ++ apc_unmap(&sma_segments[i] TSRMLS_CC); +#else -+ apc_shm_detach(&sma_segments[i]); ++ apc_shm_detach(&sma_segments[i] TSRMLS_CC); +#endif + } + sma_initialized = 0; -+ apc_efree(sma_segments); ++ apc_efree(sma_segments TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_sma_malloc_ex */ -+void* apc_sma_malloc_ex(size_t n, size_t fragment, size_t* allocated) ++void* apc_sma_malloc_ex(size_t n, size_t fragment, size_t* allocated TSRMLS_DC) +{ + size_t off; + uint i; ++ int nuked = 0; + -+ TSRMLS_FETCH(); ++restart: + assert(sma_initialized); + LOCK(SMA_LCK(sma_lastseg)); + @@ -11729,7 +12248,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + if(off == -1 && APCG(current_cache)) { + /* retry failed allocation after we expunge */ + UNLOCK(SMA_LCK(sma_lastseg)); -+ APCG(current_cache)->expunge_cb(APCG(current_cache), n); ++ APCG(current_cache)->expunge_cb(APCG(current_cache), (n+fragment) TSRMLS_CC); + LOCK(SMA_LCK(sma_lastseg)); + off = sma_allocate(SMA_HDR(sma_lastseg), n, fragment, allocated); + } @@ -11754,7 +12273,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + if(off == -1 && APCG(current_cache)) { + /* retry failed allocation after we expunge */ + UNLOCK(SMA_LCK(i)); -+ APCG(current_cache)->expunge_cb(APCG(current_cache), n); ++ APCG(current_cache)->expunge_cb(APCG(current_cache), (n+fragment) TSRMLS_CC); + LOCK(SMA_LCK(i)); + off = sma_allocate(SMA_HDR(i), n, fragment, allocated); + } @@ -11770,30 +12289,40 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + UNLOCK(SMA_LCK(i)); + } + ++ /* I've tried being nice, but now you're just asking for it */ ++ if(!nuked) { ++ apc_cache->expunge_cb(apc_cache, (n+fragment) TSRMLS_CC); ++ apc_user_cache->expunge_cb(apc_cache, (n+fragment) TSRMLS_CC); ++ nuked = 1; ++ goto restart; ++ } ++ ++ /* now, I've truly and well given up */ ++ + return NULL; +} +/* }}} */ + +/* {{{ apc_sma_malloc */ -+void* apc_sma_malloc(size_t n) ++void* apc_sma_malloc(size_t n TSRMLS_DC) +{ + size_t allocated; -+ void *p = apc_sma_malloc_ex(n, MINBLOCKSIZE, &allocated); ++ void *p = apc_sma_malloc_ex(n, MINBLOCKSIZE, &allocated TSRMLS_CC); + + return p; +} +/* }}} */ + +/* {{{ apc_sma_realloc */ -+void* apc_sma_realloc(void *p, size_t n) ++void* apc_sma_realloc(void *p, size_t n TSRMLS_DC) +{ -+ apc_sma_free(p); -+ return apc_sma_malloc(n); ++ apc_sma_free(p TSRMLS_CC); ++ return apc_sma_malloc(n TSRMLS_CC); +} +/* }}} */ + +/* {{{ apc_sma_strdup */ -+char* apc_sma_strdup(const char* s) ++char* apc_sma_strdup(const char* s TSRMLS_DC) +{ + void* q; + int len; @@ -11801,7 +12330,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + if(!s) return NULL; + + len = strlen(s)+1; -+ q = apc_sma_malloc(len); ++ q = apc_sma_malloc(len TSRMLS_CC); + if(!q) return NULL; + memcpy(q, s, len); + return q; @@ -11809,7 +12338,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +/* }}} */ + +/* {{{ apc_sma_free */ -+void apc_sma_free(void* p) ++void apc_sma_free(void* p TSRMLS_DC) +{ + uint i; + size_t offset; @@ -11835,7 +12364,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + } + } + -+ apc_eprint("apc_sma_free: could not locate address %p", p); ++ apc_error("apc_sma_free: could not locate address %p" TSRMLS_CC, p); +} +/* }}} */ + @@ -11843,7 +12372,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +/* {{{ */ +void* apc_sma_protect(void *p) +{ -+ int i; ++ unsigned int i = 0; + size_t offset; + + if (p == NULL) { @@ -11872,7 +12401,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +/* {{{ */ +void* apc_sma_unprotect(void *p) +{ -+ int i; ++ unsigned int i = 0; + size_t offset; + + if (p == NULL) { @@ -11905,7 +12434,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +#endif + +/* {{{ apc_sma_info */ -+apc_sma_info_t* apc_sma_info(zend_bool limited) ++apc_sma_info_t* apc_sma_info(zend_bool limited TSRMLS_DC) +{ + apc_sma_info_t* info; + apc_sma_link_t** link; @@ -11917,11 +12446,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + return NULL; + } + -+ info = (apc_sma_info_t*) apc_emalloc(sizeof(apc_sma_info_t)); ++ info = (apc_sma_info_t*) apc_emalloc(sizeof(apc_sma_info_t) TSRMLS_CC); + info->num_seg = sma_numseg; + info->seg_size = sma_segsize - (ALIGNWORD(sizeof(sma_header_t)) + ALIGNWORD(sizeof(block_t)) + ALIGNWORD(sizeof(block_t))); + -+ info->list = apc_emalloc(info->num_seg * sizeof(apc_sma_link_t*)); ++ info->list = apc_emalloc(info->num_seg * sizeof(apc_sma_link_t*) TSRMLS_CC); + for (i = 0; i < sma_numseg; i++) { + info->list[i] = NULL; + } @@ -11943,7 +12472,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + CHECK_CANARY(cur); +#endif + -+ *link = apc_emalloc(sizeof(apc_sma_link_t)); ++ *link = apc_emalloc(sizeof(apc_sma_link_t) TSRMLS_CC); + (*link)->size = cur->size; + (*link)->offset = prv->fnext; + (*link)->next = NULL; @@ -11965,7 +12494,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +/* }}} */ + +/* {{{ apc_sma_free_info */ -+void apc_sma_free_info(apc_sma_info_t* info) ++void apc_sma_free_info(apc_sma_info_t* info TSRMLS_DC) +{ + int i; + @@ -11974,11 +12503,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + while (p) { + apc_sma_link_t* q = p; + p = p->next; -+ apc_efree(q); ++ apc_efree(q TSRMLS_CC); + } + } -+ apc_efree(info->list); -+ apc_efree(info); ++ apc_efree(info->list TSRMLS_CC); ++ apc_efree(info TSRMLS_CC); +} +/* }}} */ + @@ -11996,6 +12525,22 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c +} +/* }}} */ + ++/* {{{ apc_sma_get_avail_size */ ++zend_bool apc_sma_get_avail_size(size_t size) ++{ ++ uint i; ++ ++ for (i = 0; i < sma_numseg; i++) { ++ sma_header_t* header = SMA_HDR(i); ++ if (header->avail > size) { ++ return 1; ++ } ++ } ++ return 0; ++} ++/* }}} */ ++ ++ +#if ALLOC_DISTRIBUTION +size_t *apc_sma_get_alloc_distribution(void) { + sma_header_t* header = (sma_header_t*) segment->sma_shmaddr; @@ -12011,15 +12556,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.c php-5.3.1/ext/apc/apc_sma.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_sma.h php-5.3.1/ext/apc/apc_sma.h ---- php-5.3.1.orig/ext/apc/apc_sma.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_sma.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,102 @@ +--- /dev/null ++++ b/ext/apc/apc_sma.h +@@ -0,0 +1,103 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12042,7 +12586,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.h php-5.3.1/ext/apc/apc_sma.h + + */ + -+/* $Id: apc_sma.h 277617 2009-03-23 02:16:24Z shire $ */ ++/* $Id: apc_sma.h 303274 2010-09-11 14:31:32Z iliaa $ */ + +#ifndef APC_SMA_H +#define APC_SMA_H @@ -12063,13 +12607,13 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.h php-5.3.1/ext/apc/apc_sma.h +#endif +}; + -+extern void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask); -+extern void apc_sma_cleanup(); -+extern void* apc_sma_malloc(size_t size); -+extern void* apc_sma_malloc_ex(size_t size, size_t fragment, size_t* allocated); -+extern void* apc_sma_realloc(void* p, size_t size); -+extern char* apc_sma_strdup(const char *s); -+extern void apc_sma_free(void* p); ++extern void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask TSRMLS_DC); ++extern void apc_sma_cleanup(TSRMLS_D); ++extern void* apc_sma_malloc(size_t size TSRMLS_DC); ++extern void* apc_sma_malloc_ex(size_t size, size_t fragment, size_t* allocated TSRMLS_DC); ++extern void* apc_sma_realloc(void* p, size_t size TSRMLS_DC); ++extern char* apc_sma_strdup(const char *s TSRMLS_DC); ++extern void apc_sma_free(void* p TSRMLS_DC); +#if ALLOC_DISTRIBUTION +extern size_t *apc_sma_get_alloc_distribution(); +#endif @@ -12095,10 +12639,11 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.h php-5.3.1/ext/apc/apc_sma.h +}; +/* }}} */ + -+extern apc_sma_info_t* apc_sma_info(zend_bool limited); -+extern void apc_sma_free_info(apc_sma_info_t* info); ++extern apc_sma_info_t* apc_sma_info(zend_bool limited TSRMLS_DC); ++extern void apc_sma_free_info(apc_sma_info_t* info TSRMLS_DC); + +extern size_t apc_sma_get_avail_mem(); ++extern zend_bool apc_sma_get_avail_size(size_t size); +extern void apc_sma_check_integrity(); + +/* {{{ ALIGNWORD: pad up x, aligned to the system's word boundary */ @@ -12117,15 +12662,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_sma.h php-5.3.1/ext/apc/apc_sma.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_spin.c php-5.3.1/ext/apc/apc_spin.c ---- php-5.3.1.orig/ext/apc/apc_spin.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_spin.c 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_spin.c @@ -0,0 +1,66 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2007-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12140,7 +12684,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.c php-5.3.1/ext/apc/apc_spin.c + + */ + -+/* $Id: apc_spin.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_spin.c 302175 2010-08-13 06:20:28Z kalle $ */ + +#include "apc_spin.h" + @@ -12157,7 +12701,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.c php-5.3.1/ext/apc/apc_spin.c + return; +} + -+void apc_slock_lock(slock_t *lock) ++void apc_slock_lock(slock_t *lock TSRMLS_DC) +{ + S_LOCK(lock); +} @@ -12187,15 +12731,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.c php-5.3.1/ext/apc/apc_spin.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_spin.h php-5.3.1/ext/apc/apc_spin.h ---- php-5.3.1.orig/ext/apc/apc_spin.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_spin.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,49 @@ +--- /dev/null ++++ b/ext/apc/apc_spin.h +@@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2007-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12210,7 +12753,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.h php-5.3.1/ext/apc/apc_spin.h + + */ + -+/* $Id: apc_spin.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_spin.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_SPIN_H +#define APC_SPIN_H @@ -12223,9 +12766,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.h php-5.3.1/ext/apc/apc_spin.h + +slock_t *apc_slock_create(slock_t *lock); +void apc_slock_destroy(slock_t *lock); -+void apc_slock_lock(slock_t *lock); ++void apc_slock_lock(slock_t *lock TSRMLS_DC); +zend_bool apc_slock_nonblocking_lock(slock_t *lock); -+void apc_slock_lock(slock_t *lock); +void apc_slock_unlock(slock_t *lock); + +#endif @@ -12240,15 +12782,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_spin.h php-5.3.1/ext/apc/apc_spin.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_stack.c php-5.3.1/ext/apc/apc_stack.c ---- php-5.3.1.orig/ext/apc/apc_stack.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_stack.c 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_stack.c @@ -0,0 +1,106 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12271,10 +12812,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.c php-5.3.1/ext/apc/apc_stack.c + + */ + -+/* $Id: apc_stack.c 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_stack.c 302175 2010-08-13 06:20:28Z kalle $ */ + -+#include "apc_stack.h" +#include "apc.h" ++#include "apc_stack.h" + +struct apc_stack_t { + void** data; @@ -12282,22 +12823,22 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.c php-5.3.1/ext/apc/apc_stack.c + int size; +}; + -+apc_stack_t* apc_stack_create(int size_hint) ++apc_stack_t* apc_stack_create(int size_hint TSRMLS_DC) +{ -+ apc_stack_t* stack = (apc_stack_t*) apc_emalloc(sizeof(apc_stack_t)); ++ apc_stack_t* stack = (apc_stack_t*) apc_emalloc(sizeof(apc_stack_t) TSRMLS_CC); + + stack->capacity = (size_hint > 0) ? size_hint : 10; + stack->size = 0; -+ stack->data = (void**) apc_emalloc(sizeof(void*) * stack->capacity); ++ stack->data = (void**) apc_emalloc(sizeof(void*) * stack->capacity TSRMLS_CC); + + return stack; +} + -+void apc_stack_destroy(apc_stack_t* stack) ++void apc_stack_destroy(apc_stack_t* stack TSRMLS_DC) +{ + if (stack != NULL) { -+ apc_efree(stack->data); -+ apc_efree(stack); ++ apc_efree(stack->data TSRMLS_CC); ++ apc_efree(stack TSRMLS_CC); + } +} + @@ -12307,12 +12848,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.c php-5.3.1/ext/apc/apc_stack.c + stack->size = 0; +} + -+void apc_stack_push(apc_stack_t* stack, void* item) ++void apc_stack_push(apc_stack_t* stack, void* item TSRMLS_DC) +{ + assert(stack != NULL); + if (stack->size == stack->capacity) { + stack->capacity *= 2; -+ stack->data = apc_erealloc(stack->data, sizeof(void*)*stack->capacity); ++ stack->data = apc_erealloc(stack->data, sizeof(void*)*stack->capacity TSRMLS_CC); + } + stack->data[stack->size++] = item; +} @@ -12350,15 +12891,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.c php-5.3.1/ext/apc/apc_stack.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_stack.h php-5.3.1/ext/apc/apc_stack.h ---- php-5.3.1.orig/ext/apc/apc_stack.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_stack.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/apc_stack.h @@ -0,0 +1,58 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12382,7 +12922,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.h php-5.3.1/ext/apc/apc_stack.h + + */ + -+/* $Id: apc_stack.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: apc_stack.h 302175 2010-08-13 06:20:28Z kalle $ */ + +#ifndef APC_STACK_H +#define APC_STACK_H @@ -12392,10 +12932,10 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.h php-5.3.1/ext/apc/apc_stack.h +#define T apc_stack_t* +typedef struct apc_stack_t apc_stack_t; /* opaque stack type */ + -+extern T apc_stack_create(int size_hint); -+extern void apc_stack_destroy(T stack); ++extern T apc_stack_create(int size_hint TSRMLS_DC); ++extern void apc_stack_destroy(T stack TSRMLS_DC); +extern void apc_stack_clear(T stack); -+extern void apc_stack_push(T stack, void* item); ++extern void apc_stack_push(T stack, void* item TSRMLS_DC); +extern void* apc_stack_pop(T stack); +extern void* apc_stack_top(T stack); +extern void* apc_stack_get(T stack, int n); @@ -12412,15 +12952,316 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_stack.h php-5.3.1/ext/apc/apc_stack.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c ---- php-5.3.1.orig/ext/apc/apc_zend.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_zend.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,213 @@ +--- /dev/null ++++ b/ext/apc/apc_string.c +@@ -0,0 +1,247 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2010 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.txt | ++ | If you did not receive a copy of the PHP license and are unable to | ++ | obtain it through the world-wide-web, please send a note to | ++ | license@php.net so we can mail you a copy immediately. | ++ +----------------------------------------------------------------------+ ++ | Authors: Dmitry Stogov | ++ +----------------------------------------------------------------------+ ++ ++ This software was contributed to PHP by Community Connect Inc. in 2002 ++ and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. ++ Future revisions and derivatives of this source code must acknowledge ++ Community Connect Inc. as the original contributor of this module by ++ leaving this note intact in the source code. ++ ++ All other licensing and usage conditions are those of the PHP Group. ++ ++ */ ++ ++/* $Id: $ */ ++ ++#include "apc.h" ++#include "apc_globals.h" ++#include "apc_php.h" ++#include "apc_lock.h" ++ ++#ifdef ZEND_ENGINE_2_4 ++ ++typedef struct _apc_interned_strings_data_t { ++ char *interned_strings_start; ++ char *interned_strings_end; ++ char *interned_strings_top; ++ apc_lck_t lock; ++ HashTable interned_strings; ++} apc_interned_strings_data_t; ++ ++apc_interned_strings_data_t *apc_interned_strings_data = NULL; ++ ++#define APCSG(v) (apc_interned_strings_data->v) ++ ++static char *old_interned_strings_start; ++static char *old_interned_strings_end; ++static char *(*old_new_interned_string)(char *str, int len, int free_src TSRMLS_DC); ++static void (*old_interned_strings_snapshot)(TSRMLS_D); ++static void (*old_interned_strings_restore)(TSRMLS_D); ++ ++static char *apc_dummy_new_interned_string_for_php(char *str, int len, int free_src TSRMLS_DC) ++{ ++ return str; ++} ++ ++static void apc_dummy_interned_strings_snapshot_for_php(TSRMLS_D) ++{ ++} ++ ++static void apc_dummy_interned_strings_restore_for_php(TSRMLS_D) ++{ ++} ++ ++char *apc_new_interned_string(char *arKey, int nKeyLength TSRMLS_DC) ++{ ++ ulong h; ++ uint nIndex; ++ Bucket *p; ++ ++ if (arKey >= APCSG(interned_strings_start) && arKey < APCSG(interned_strings_end)) { ++ return arKey; ++ } ++ ++ h = zend_inline_hash_func(arKey, nKeyLength); ++ nIndex = h & APCSG(interned_strings).nTableMask; ++ ++ p = APCSG(interned_strings).arBuckets[nIndex]; ++ while (p != NULL) { ++ if ((p->h == h) && (p->nKeyLength == nKeyLength)) { ++ if (!memcmp(p->arKey, arKey, nKeyLength)) { ++ return p->arKey; ++ } ++ } ++ p = p->pNext; ++ } ++ ++ if (APCSG(interned_strings_top) + ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength) >= ++ APCSG(interned_strings_end)) { ++ /* no memory */ ++ return NULL; ++ } ++ ++ p = (Bucket *) APCSG(interned_strings_top); ++ APCSG(interned_strings_top) += ZEND_MM_ALIGNED_SIZE(sizeof(Bucket) + nKeyLength); ++ ++ p->arKey = (char*)(p+1); ++ memcpy(p->arKey, arKey, nKeyLength); ++ p->nKeyLength = nKeyLength; ++ p->h = h; ++ p->pData = &p->pDataPtr; ++ p->pDataPtr = p; ++ ++ p->pNext = APCSG(interned_strings).arBuckets[nIndex]; ++ p->pLast = NULL; ++ if (p->pNext) { ++ p->pNext->pLast = p; ++ } ++ APCSG(interned_strings).arBuckets[nIndex] = p; ++ ++ p->pListLast = APCSG(interned_strings).pListTail; ++ APCSG(interned_strings).pListTail = p; ++ p->pListNext = NULL; ++ if (p->pListLast != NULL) { ++ p->pListLast->pListNext = p; ++ } ++ if (!APCSG(interned_strings).pListHead) { ++ APCSG(interned_strings).pListHead = p; ++ } ++ ++ APCSG(interned_strings).nNumOfElements++; ++ ++ return p->arKey; ++} ++ ++static void apc_copy_internal_strings(TSRMLS_D) ++{ ++ Bucket *p, *q; ++ ++ p = CG(function_table)->pListHead; ++ while (p) { ++ if (p->nKeyLength) { ++ p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); ++ } ++ p = p->pListNext; ++ } ++ ++ p = CG(class_table)->pListHead; ++ while (p) { ++ zend_class_entry *ce = (zend_class_entry*)(p->pDataPtr); ++ ++ if (p->nKeyLength) { ++ p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); ++ } ++ ++ q = ce->properties_info.pListHead; ++ while (q) { ++ zend_property_info *info = (zend_property_info*)(q->pData); ++ ++ if (q->nKeyLength) { ++ q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); ++ } ++ ++ if (info->name) { ++ info->name = apc_new_interned_string(info->name, info->name_length+1 TSRMLS_CC); ++ } ++ ++ q = q->pListNext; ++ } ++ ++ q = ce->function_table.pListHead; ++ while (q) { ++ if (q->nKeyLength) { ++ q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); ++ } ++ q = q->pListNext; ++ } ++ ++ q = ce->constants_table.pListHead; ++ while (q) { ++ if (q->nKeyLength) { ++ q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC); ++ } ++ q = q->pListNext; ++ } ++ ++ p = p->pListNext; ++ } ++ ++ p = EG(zend_constants)->pListHead; ++ while (p) { ++ if (p->nKeyLength) { ++ p->arKey = apc_new_interned_string(p->arKey, p->nKeyLength TSRMLS_CC); ++ } ++ p = p->pListNext; ++ } ++} ++ ++void apc_interned_strings_init(TSRMLS_D) ++{ ++ int count = APCG(shm_strings_buffer) / (sizeof(Bucket) + sizeof(Bucket*) * 2); ++ ++ apc_interned_strings_data = (apc_interned_strings_data_t*) apc_sma_malloc(APCG(shm_strings_buffer) TSRMLS_CC); ++ ++ CREATE_LOCK(APCSG(lock)); ++ ++ zend_hash_init(&APCSG(interned_strings), count, NULL, NULL, 1); ++ APCSG(interned_strings).nTableMask = APCSG(interned_strings).nTableSize - 1; ++ APCSG(interned_strings).arBuckets = (Bucket**)((char*)apc_interned_strings_data + sizeof(apc_interned_strings_data_t)); ++ ++ APCSG(interned_strings_start) = (char*)APCSG(interned_strings).arBuckets + APCSG(interned_strings).nTableSize * sizeof(Bucket *); ++ APCSG(interned_strings_end) = (char*)apc_interned_strings_data + APCG(shm_strings_buffer); ++ APCSG(interned_strings_top) = APCSG(interned_strings_start); ++ ++ old_interned_strings_start = CG(interned_strings_start); ++ old_interned_strings_end = CG(interned_strings_end); ++ old_new_interned_string = zend_new_interned_string; ++ old_interned_strings_snapshot = zend_interned_strings_snapshot; ++ old_interned_strings_restore = zend_interned_strings_restore; ++ ++ CG(interned_strings_start) = APCSG(interned_strings_start); ++ CG(interned_strings_end) = APCSG(interned_strings_end); ++ zend_new_interned_string = apc_dummy_new_interned_string_for_php; ++ zend_interned_strings_snapshot = apc_dummy_interned_strings_snapshot_for_php; ++ zend_interned_strings_restore = apc_dummy_interned_strings_restore_for_php; ++ ++ apc_copy_internal_strings(TSRMLS_C); ++} ++ ++void apc_interned_strings_shutdown(TSRMLS_D) ++{ ++ zend_hash_clean(CG(function_table)); ++ zend_hash_clean(CG(class_table)); ++ zend_hash_clean(EG(zend_constants)); ++ ++ CG(interned_strings_start) = old_interned_strings_start; ++ CG(interned_strings_end) = old_interned_strings_end; ++ zend_new_interned_string = old_new_interned_string; ++ zend_interned_strings_snapshot = old_interned_strings_snapshot; ++ zend_interned_strings_restore = old_interned_strings_restore; ++ ++ DESTROY_LOCK(APCSG(lock)); ++} ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +--- /dev/null ++++ b/ext/apc/apc_string.h +@@ -0,0 +1,49 @@ ++/* ++ +----------------------------------------------------------------------+ ++ | APC | ++ +----------------------------------------------------------------------+ ++ | Copyright (c) 2006-2010 The PHP Group | ++ +----------------------------------------------------------------------+ ++ | This source file is subject to version 3.01 of the PHP license, | ++ | that is bundled with this package in the file LICENSE, and is | ++ | available through the world-wide-web at the following url: | ++ | http://www.php.net/license/3_01.txt | ++ | If you did not receive a copy of the PHP license and are unable to | ++ | obtain it through the world-wide-web, please send a note to | ++ | license@php.net so we can mail you a copy immediately. | ++ +----------------------------------------------------------------------+ ++ | Authors: Dmitry Stogov | ++ +----------------------------------------------------------------------+ ++ ++ This software was contributed to PHP by Community Connect Inc. in 2002 ++ and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. ++ Future revisions and derivatives of this source code must acknowledge ++ Community Connect Inc. as the original contributor of this module by ++ leaving this note intact in the source code. ++ ++ All other licensing and usage conditions are those of the PHP Group. ++ ++ */ ++ ++/* $Id: $ */ ++ ++#ifndef APC_STRING ++#define APC_STRING ++ ++#include "apc.h" ++ ++void apc_interned_strings_init(TSRMLS_D); ++void apc_interned_strings_shutdown(TSRMLS_D); ++ ++char *apc_new_interned_string(char *arKey, int nKeyLength TSRMLS_DC); ++ ++#endif ++ ++/* ++ * Local variables: ++ * tab-width: 4 ++ * c-basic-offset: 4 ++ * End: ++ * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker ++ * vim<600: expandtab sw=4 ts=4 sts=4 ++ */ +--- /dev/null ++++ b/ext/apc/apc_zend.c +@@ -0,0 +1,271 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12443,7 +13284,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + + */ + -+/* $Id: apc_zend.c 276053 2009-02-18 08:59:00Z gopalv $ */ ++/* $Id: apc_zend.c 303426 2010-09-16 16:39:08Z iliaa $ */ + +#include "apc_zend.h" +#include "apc_globals.h" @@ -12451,12 +13292,12 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c +/* true global */ +int apc_reserved_offset; + -+void* apc_php_malloc(size_t n) ++void* apc_php_malloc(size_t n TSRMLS_DC) +{ + return emalloc(n); +} + -+void apc_php_free(void* p) ++void apc_php_free(void* p TSRMLS_DC) +{ + efree(p); +} @@ -12468,6 +13309,38 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + +#define APC_EX_T(offset) (*(temp_variable *)((char*)execute_data->Ts + offset)) + ++#ifdef ZEND_ENGINE_2_4 ++static zval *apc_get_zval_ptr(zend_uchar op_type, znode_op *node, zval **freeval, zend_execute_data *execute_data TSRMLS_DC) ++{ ++ *freeval = NULL; ++ ++ switch (op_type) { ++ case IS_CONST: ++ return node->zv; ++ case IS_VAR: ++ return APC_EX_T(node->var).var.ptr; ++ case IS_TMP_VAR: ++ return (*freeval = &APC_EX_T(node->var).tmp_var); ++ case IS_CV: ++ { ++ zval ***ret = &execute_data->CVs[node->var]; ++ ++ if (!*ret) { ++ zend_compiled_variable *cv = &EG(active_op_array)->vars[node->var]; ++ ++ if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void**)ret)==FAILURE) { ++ apc_notice("Undefined variable: %s" TSRMLS_CC, cv->name); ++ return &EG(uninitialized_zval); ++ } ++ } ++ return **ret; ++ } ++ case IS_UNUSED: ++ default: ++ return NULL; ++ } ++} ++#else +static zval *apc_get_zval_ptr(znode *node, zval **freeval, zend_execute_data *execute_data TSRMLS_DC) +{ + *freeval = NULL; @@ -12488,7 +13361,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + zend_compiled_variable *cv = &EG(active_op_array)->vars[node->u.var]; + + if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void**)ret)==FAILURE) { -+ apc_nprint("Undefined variable: %s", cv->name); ++ apc_notice("Undefined variable: %s" TSRMLS_CC, cv->name); + return &EG(uninitialized_zval); + } + } @@ -12500,6 +13373,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + return NULL; + } +} ++#endif + +static int ZEND_FASTCALL apc_op_ZEND_INCLUDE_OR_EVAL(ZEND_OPCODE_HANDLER_ARGS) +{ @@ -12509,15 +13383,26 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + char realpath[MAXPATHLEN]; + php_stream_wrapper *wrapper; + char *path_for_open; ++ char *full_path = NULL; + int ret = 0; + apc_opflags_t* flags = NULL; + ++#ifdef ZEND_ENGINE_2_4 ++ if (opline->extended_value != ZEND_INCLUDE_ONCE && ++ opline->extended_value != ZEND_REQUIRE_ONCE) { ++ return apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); ++ } ++ ++ inc_filename = apc_get_zval_ptr(opline->op1_type, &opline->op1, &freeop1, execute_data TSRMLS_CC); ++#else + if (Z_LVAL(opline->op2.u.constant) != ZEND_INCLUDE_ONCE && + Z_LVAL(opline->op2.u.constant) != ZEND_REQUIRE_ONCE) { + return apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } + + inc_filename = apc_get_zval_ptr(&opline->op1, &freeop1, execute_data TSRMLS_CC); ++#endif ++ + if (Z_TYPE_P(inc_filename) != IS_STRING) { + tmp_inc_filename = *inc_filename; + zval_copy_ctor(&tmp_inc_filename); @@ -12527,9 +13412,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + + wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(inc_filename), &path_for_open, 0 TSRMLS_CC); + -+ if (wrapper != &php_plain_files_wrapper || -+ !(IS_ABSOLUTE_PATH(path_for_open, strlen(path_for_open)) || -+ expand_filepath(path_for_open, realpath TSRMLS_CC))) { ++ if (wrapper != &php_plain_files_wrapper || !(IS_ABSOLUTE_PATH(path_for_open, strlen(path_for_open)) || (full_path = expand_filepath(path_for_open, realpath TSRMLS_CC)))) { + /* Fallback to original handler */ + if (inc_filename == &tmp_inc_filename) { + zval_dtor(&tmp_inc_filename); @@ -12537,11 +13420,21 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + return apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } + ++ if (!full_path) { ++ full_path = path_for_open; ++ } + if (zend_hash_exists(&EG(included_files), realpath, strlen(realpath) + 1)) { ++#ifdef ZEND_ENGINE_2_4 ++ if (!(opline->result_type & EXT_TYPE_UNUSED)) { ++ ALLOC_INIT_ZVAL(APC_EX_T(opline->result.var).var.ptr); ++ ZVAL_TRUE(APC_EX_T(opline->result.var).var.ptr); ++ } ++#else + if (!(opline->result.u.EA.type & EXT_TYPE_UNUSED)) { + ALLOC_INIT_ZVAL(APC_EX_T(opline->result.u.var).var.ptr); + ZVAL_TRUE(APC_EX_T(opline->result.u.var).var.ptr); + } ++#endif + if (inc_filename == &tmp_inc_filename) { + zval_dtor(&tmp_inc_filename); + } @@ -12565,9 +13458,15 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + /* Since the op array is a local copy, we can cheat our way through the file inclusion by temporarily + * changing the op to a plain require/include, calling its handler and finally restoring the opcode. + */ ++#ifdef ZEND_ENGINE_2_4 ++ opline->extended_value = (opline->extended_value == ZEND_INCLUDE_ONCE) ? ZEND_INCLUDE : ZEND_REQUIRE; ++ ret = apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); ++ opline->extended_value = (opline->extended_value == ZEND_INCLUDE) ? ZEND_INCLUDE_ONCE : ZEND_REQUIRE_ONCE; ++#else + Z_LVAL(opline->op2.u.constant) = (Z_LVAL(opline->op2.u.constant) == ZEND_INCLUDE_ONCE) ? ZEND_INCLUDE : ZEND_REQUIRE; + ret = apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + Z_LVAL(opline->op2.u.constant) = (Z_LVAL(opline->op2.u.constant) == ZEND_INCLUDE) ? ZEND_INCLUDE_ONCE : ZEND_REQUIRE_ONCE; ++#endif + } else { + ret = apc_original_opcode_handlers[APC_OPCODE_HANDLER_DECODE(opline)](ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } @@ -12629,15 +13528,14 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.c php-5.3.1/ext/apc/apc_zend.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h ---- php-5.3.1.orig/ext/apc/apc_zend.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/apc_zend.h 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,169 @@ +--- /dev/null ++++ b/ext/apc/apc_zend.h +@@ -0,0 +1,191 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -12660,7 +13558,7 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h + + */ + -+/* $Id: apc_zend.h 286799 2009-08-04 11:27:29Z gopalv $ */ ++/* $Id: apc_zend.h 303464 2010-09-17 12:19:29Z gopalv $ */ + +#ifndef APC_ZEND_H +#define APC_ZEND_H @@ -12711,8 +13609,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h +#endif + + -+extern void* apc_php_malloc(size_t n); -+extern void apc_php_free(void* p); ++extern void* apc_php_malloc(size_t n TSRMLS_DC); ++extern void apc_php_free(void* p TSRMLS_DC); + +extern void apc_zend_init(TSRMLS_D); +extern void apc_zend_shutdown(TSRMLS_D); @@ -12763,13 +13661,19 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h + _UNUSED_CODE, /* 15 */ + _CV_CODE /* 16 = IS_CV */ + }; ++#ifdef ZEND_ENGINE_2_4 ++ return (opline->opcode * 25) + (apc_vm_decode[opline->op1_type] * 5) + apc_vm_decode[opline->op2_type]; ++#else + return (opline->opcode * 25) + (apc_vm_decode[opline->op1.op_type] * 5) + apc_vm_decode[opline->op2.op_type]; ++#endif +} + +# define APC_ZEND_OPLINE zend_op *opline = execute_data->opline; +# define APC_OPCODE_HANDLER_DECODE(opline) _apc_opcode_handler_decode(opline) +# if PHP_MAJOR_VERSION >= 6 +# define APC_OPCODE_HANDLER_COUNT ((25 * 152) + 1) ++# elif defined(ZEND_ENGINE_2_4) ++# define APC_OPCODE_HANDLER_COUNT ((25 * 157) + 1) /* 3 new opcodes in 5.4? - separate, bind_trais, add_trait */ +# elif PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 +# define APC_OPCODE_HANDLER_COUNT ((25 * 154) + 1) /* 3 new opcodes in 5.3 - unused, lambda, jmp_set */ +# else @@ -12788,9 +13692,25 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h +#define ZEND_FASTCALL +#endif + ++/* Added in ZE2.3.0 */ ++#ifndef zend_parse_parameters_none ++# define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") ++#endif ++ + +#endif /* APC_OPCODE_OVERRIDE */ + ++#ifdef ZEND_ENGINE_2_4 ++# define ZEND_CE_FILENAME(ce) (ce)->info.user.filename ++# define ZEND_CE_DOC_COMMENT(ce) (ce)->info.user.doc_comment ++# define ZEND_CE_DOC_COMMENT_LEN(ce) (ce)->info.user.doc_comment_len ++# define ZEND_CE_BUILTIN_FUNCTIONS(ce) (ce)->info.internal.builtin_functions ++#else ++# define ZEND_CE_FILENAME(ce) (ce)->filename ++# define ZEND_CE_DOC_COMMENT(ce) (ce)->doc_comment ++# define ZEND_CE_DOC_COMMENT_LEN(ce) (ce)->doc_comment_len ++# define ZEND_CE_BUILTIN_FUNCTIONS(ce) (ce)->builtin_functions ++#endif + +#endif /* APC_ZEND_H */ + @@ -12802,9 +13722,8 @@ diff -Naur php-5.3.1.orig/ext/apc/apc_zend.h php-5.3.1/ext/apc/apc_zend.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/CHANGELOG php-5.3.1/ext/apc/CHANGELOG ---- php-5.3.1.orig/ext/apc/CHANGELOG 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/CHANGELOG 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/CHANGELOG @@ -0,0 +1,249 @@ + +3.1.2 : 2008-12-12 @@ -13055,17 +13974,25 @@ diff -Naur php-5.3.1.orig/ext/apc/CHANGELOG php-5.3.1/ext/apc/CHANGELOG + +1.0.1: +- added optional file modification time check [djc 2001-01-12] -diff -Naur php-5.3.1.orig/ext/apc/config.m4 php-5.3.1/ext/apc/config.m4 ---- php-5.3.1.orig/ext/apc/config.m4 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/config.m4 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,232 @@ +--- /dev/null ++++ b/ext/apc/config.m4 +@@ -0,0 +1,246 @@ +dnl -+dnl $Id: config.m4 286829 2009-08-05 10:31:28Z gopalv $ ++dnl $Id: config.m4 304101 2010-10-05 14:37:36Z kalle $ +dnl + +PHP_ARG_ENABLE(apc, whether to enable APC support, +[ --enable-apc Enable APC support]) + ++AC_ARG_ENABLE(apc-debug, ++[ --enable-apc-debug Enable APC debugging], ++[ ++ PHP_APC_DEBUG=yes ++], ++[ ++ PHP_APC_DEBUG=no ++]) ++ +AC_MSG_CHECKING(whether we should enable cache request file info) +AC_ARG_ENABLE(apc-filehits, +[ --enable-apc-filehits Enable per request file info about files used from the APC cache (ie: apc_cache_info('filehits')) ], @@ -13179,8 +14106,8 @@ diff -Naur php-5.3.1.orig/ext/apc/config.m4 php-5.3.1/ext/apc/config.m4 +]) + +AC_MSG_CHECKING(whether we should enable memory protection) -+AC_ARG_ENABLE(memory-protection, -+[ --enable-memory-protection ++AC_ARG_ENABLE(apc-memprotect, ++[ --enable-apc-memprotect + Enable mmap/shm memory protection], +[ + PHP_APC_MEMPROTECT=$enableval @@ -13194,6 +14121,10 @@ diff -Naur php-5.3.1.orig/ext/apc/config.m4 php-5.3.1/ext/apc/config.m4 + test "$PHP_APC_MMAP" != "no" && AC_DEFINE(APC_MMAP, 1, [ ]) + test "$PHP_APC_FILEHITS" != "no" && AC_DEFINE(APC_FILEHITS, 1, [ ]) + ++ if test "$PHP_APC_DEBUG" != "no"; then ++ AC_DEFINE(__DEBUG_APC__, 1, [ ]) ++ fi ++ + if test "$PHP_APC_SEM" != "no"; then + AC_DEFINE(APC_SEM_LOCKS, 1, [ ]) + elif test "$PHP_APC_SPINLOCKS" != "no"; then @@ -13282,7 +14213,8 @@ diff -Naur php-5.3.1.orig/ext/apc/config.m4 php-5.3.1/ext/apc/config.m4 + apc_signal.c \ + apc_pool.c \ + apc_iterator.c \ -+ apc_bin.c " ++ apc_bin.c \ ++ apc_string.c " + + PHP_CHECK_LIBRARY(rt, shm_open, [PHP_ADD_LIBRARY(rt,,APC_SHARED_LIBADD)]) + PHP_NEW_EXTENSION(apc, $apc_sources, $ext_shared,, \\$(APC_CFLAGS)) @@ -13291,41 +14223,61 @@ diff -Naur php-5.3.1.orig/ext/apc/config.m4 php-5.3.1/ext/apc/config.m4 + AC_DEFINE(HAVE_APC, 1, [ ]) +fi + -diff -Naur php-5.3.1.orig/ext/apc/config.w32 php-5.3.1/ext/apc/config.w32 ---- php-5.3.1.orig/ext/apc/config.w32 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/config.w32 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,27 @@ -+// $Id: config.w32 284592 2009-07-22 10:53:50Z kalle $ +--- /dev/null ++++ b/ext/apc/config.w32 +@@ -0,0 +1,48 @@ ++// $Id: config.w32 305410 2010-11-16 16:47:18Z pajoye $ +// vim:ft=javascript + -+ARG_ENABLE("apc", "Alternative PHP Cache", "no"); -+ -+if (PHP_APC != "no") { -+ apc_sources="apc.c php_apc.c \ -+ apc_cache.c \ -+ apc_compile.c \ -+ apc_debug.c \ -+ apc_fcntl_win32.c \ -+ apc_iterator.c \ -+ apc_main.c \ -+ apc_shm.c \ -+ apc_sma.c \ -+ apc_stack.c \ -+ apc_rfc1867.c \ -+ apc_zend.c \ -+ apc_pool.c \ -+ apc_bin.c \ -+ apc_spin.c \ -+ pgsql_s_lock.c"; -+ -+ EXTENSION('apc', apc_sources); ++ ++ARG_ENABLE('apc', 'Whether to enable APC support', 'no'); ++ARG_ENABLE('apc-debug', 'Whether to enable APC debugging', 'no'); ++ARG_ENABLE('apc-filehits', 'Whether to enable cache request file info', 'no'); ++ARG_ENABLE('apc-spinlocks', 'Whether to use spin locks (experimental)', 'no'); ++ARG_ENABLE('apc-memprotect', 'Whether to enable memory protection (experimental)', 'no'); ++ ++if(PHP_APC != 'no') ++{ ++ var apc_sources = 'apc.c php_apc.c apc_cache.c apc_compile.c apc_debug.c ' + ++ 'apc_fcntl_win32.c apc_iterator.c apc_main.c apc_shm.c ' + ++ 'apc_sma.c apc_stack.c apc_rfc1867.c apc_zend.c apc_pool.c ' + ++ 'apc_bin.c apc_string.c'; ++ ++ if(PHP_APC_DEBUG != 'no') ++ { ++ ADD_FLAG('CFLAGS_APC', '/D __DEBUG_APC__=1'); ++ } ++ ++ if(PHP_APC_FILEHITS != 'no') ++ { ++ AC_DEFINE('APC_FILEHITS', 1); ++ } ++ ++ if(PHP_APC_MEMPROTECT != 'no') ++ { ++ AC_DEFINE('APC_MEMPROTECT', 1); ++ } ++ ++ if(PHP_APC_SPINLOCKS != 'no') ++ { ++ AC_DEFINE('APC_SPIN_LOCKS', 1); ++ ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); ++ ++ apc_sources += ' apc_spin.c pgsql_s_lock.c'; ++ } ++ else ++ { ++ AC_DEFINE('APC_FCNTL_LOCKS', 1); ++ } ++ + AC_DEFINE('HAVE_APC', 1); -+ ADD_FLAG('CFLAGS_APC', "/DAPC_SPIN_LOCKS=1 /DWIN32_ONLY_COMPILER=1"); ++ ++ EXTENSION('apc', apc_sources); +} -diff -Naur php-5.3.1.orig/ext/apc/INSTALL php-5.3.1/ext/apc/INSTALL ---- php-5.3.1.orig/ext/apc/INSTALL 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/INSTALL 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,421 @@ +\ No newline at end of file +--- /dev/null ++++ b/ext/apc/INSTALL +@@ -0,0 +1,400 @@ +Installation Instructions for APC +--------------------------------- + @@ -13338,47 +14290,26 @@ diff -Naur php-5.3.1.orig/ext/apc/INSTALL php-5.3.1/ext/apc/INSTALL +---------------- +Building from CVS can be done like this: + -+ cvs -d :pserver:cvsread@cvs.php.net:/repository login -+ Password: phpfi -+ cvs -d :pserver:cvsread@cvs.php.net:/repository co pecl/apc -+ cd pecl/apc ++ svn co http://svn.php.net/repository/pecl/apc/trunk apc ++ cd apc + phpize -+ ./configure --enable-apc-mmap --with-apxs --with-php-config=/usr/local/php/bin/php-config ++ ./configure --with-php-config=/usr/local/php/bin/php-config + make ++ export TEST_PHP_ARGS='-n' ++ make test + make install + +Suggested Configuration (in your php.ini file) +---------------------------------------------- + extension=apc.so + apc.enabled=1 -+ apc.shm_segments=1 + apc.shm_size=128 + apc.ttl=7200 + apc.user_ttl=7200 -+ apc.num_files_hint=1024 -+ apc.mmap_file_mask=/tmp/apc.XXXXXX + apc.enable_cli=1 + +These are fully described at the bottom of this file. + -+PHP 4 Optimization -+------------------ -+If you are trying to get every little bit of speed out of PHP4+APC, you need -+to tell APC where to find your httpd.h file and also add -DAPC_PHP4_STAT to -+your CPPFLAGS. (if you don't have httpd.h, install the apache_dev package -+for your OS) and do: -+ export CPPFLAGS="-I/usr/include/apache-1.3 -DAPC_PHP4_STAT" (for bash on Debian) -+ setenv CPPFLAGS "-I/usr/include/apache-1.3 -DAPC_PHP4_STAT" (for tsch on Debian) -+and then re-run your configure script. -+ -+This optimization saves a stat syscall on the main script file. In PHP5 this -+optimization is automatic and doesn't need any special build flags. -+ -+The second thing you are going to want to do to save another syscall is to -+compile using the --with-apxs configure switch. This should work for both -+Apache1 and Apache2. Point it directly at your apxs2 script for Apache2. -+eg. --with-apxs=/usr/local/bin/apxs2 -+ ++---------------------+ +| QUICK INSTALL (DSO) | ++---------------------+ @@ -13389,7 +14320,7 @@ diff -Naur php-5.3.1.orig/ext/apc/INSTALL php-5.3.1/ext/apc/INSTALL +$ gunzip -c apc_x.y.tar.gz | tar xf - +$ cd apc_x.y +$ /usr/local/php/bin/phpize -+$ ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/local/php/bin/php-config ++$ ./configure --with-php-config=/usr/local/php/bin/php-config +$ make +$ make install + @@ -13747,13 +14678,12 @@ diff -Naur php-5.3.1.orig/ext/apc/INSTALL php-5.3.1/ext/apc/INSTALL + Optimize include_once and require_once calls and avoid the + expensive system calls used. + (Default: 0) -diff -Naur php-5.3.1.orig/ext/apc/LICENSE php-5.3.1/ext/apc/LICENSE ---- php-5.3.1.orig/ext/apc/LICENSE 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/LICENSE 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/LICENSE @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- + The PHP License, version 3.01 -+Copyright (c) 1999 - 2006 The PHP Group. All rights reserved. ++Copyright (c) 1999 - 2010 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without @@ -13819,9 +14749,8 @@ diff -Naur php-5.3.1.orig/ext/apc/LICENSE php-5.3.1/ext/apc/LICENSE + +PHP includes the Zend Engine, freely available at +. -diff -Naur php-5.3.1.orig/ext/apc/NOTICE php-5.3.1/ext/apc/NOTICE ---- php-5.3.1.orig/ext/apc/NOTICE 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/NOTICE 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/NOTICE @@ -0,0 +1,43 @@ +This is the NOTICE file that holds acknowledgements and stuff. + @@ -13866,12 +14795,11 @@ diff -Naur php-5.3.1.orig/ext/apc/NOTICE php-5.3.1/ext/apc/NOTICE + Angel Li diffs for ANSI comment compliance + Christian Rishøj help debugging phplib problems + Sascha Schumann memory error bug fix -diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml ---- php-5.3.1.orig/ext/apc/package.xml 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/package.xml 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,736 @@ +--- /dev/null ++++ b/ext/apc/package.xml +@@ -0,0 +1,827 @@ + -+ ++ + APC + pecl.php.net + Alternative PHP Cache @@ -13904,7 +14832,7 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml + Edin Kadribasic + edink + edink@emini.dk -+ yes ++ no + + + Ilia Alshanetsky @@ -13916,13 +14844,13 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml + Marcus Börger + helly + helly@php.net -+ yes ++ no + + + Sara Golemon + pollita + pollita@php.net -+ yes ++ no + + + Brian Shire @@ -13930,23 +14858,38 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml + shire@php.net + yes + -+ 2009-08-14 -+ ++ ++ Kalle Sommer Nielsen ++ kalle ++ kalle@php.net ++ yes ++ ++ ++ Pierre Joye ++ pajoye ++ pierre@php.net ++ yes ++ ++ 2010-11-30 ++ + -+ 3.1.3p1 ++ 3.1.6 + 3.1.0 + + -+ beta -+ beta ++ stable ++ stable + + PHP License + -+- fix pecl build / package.xml (Gopal) ++- make slam_defense a little more optimistic, allow a thread/process to write to cache in a loop ++- ensure realpaths hit the realpath_cache, in no-stat mode ++- prevent memory starvation, nuke all caches when expunging just one doesn't work ++- fix uploadprogress keylength issues (NUL is part of keylen, pecl bug #20016) + + + -+ ++ + + + @@ -13955,14 +14898,14 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml + + + -+ ++ + + + + + + -+ ++ + + + @@ -13971,65 +14914,67 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml + + + -+ ++ + + + + -+ -+ ++ ++ + -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + @@ -14604,17 +15549,90 @@ diff -Naur php-5.3.1.orig/ext/apc/package.xml php-5.3.1/ext/apc/package.xml +- Win32 build-fixes (Kalle) + + ++ ++ ++ 3.1.3p1 ++ 3.1.0 ++ ++ ++ beta ++ beta ++ ++ PHP License ++ 2009-08-14 ++ ++- fix pecl build / package.xml (Gopal) ++ ++ ++ ++ ++ 3.1.4 ++ 3.1.0 ++ ++ ++ beta ++ beta ++ ++ PHP License ++ 2010-08-05 ++ ++- Windows builds may now have filehits and memory protection if enabled (Kalle) ++- Renamed the memory protection configure option to --enable-apc-memprotect (Kalle, Shire) ++- ZTS fixes and optimizations (Kalle, Felipe) ++- Win32 stat support (Pierre, Kalle) ++- Added support for interned strings, run-time caches and Zend Engine 2.4 (Dmitry) ++- Added apc_exists() (Rasmus) ++- Fixed potential XSS in apc.php, CVE-2010-3294 (Pierre, Matt Chapman) ++- Fixed pecl bug #17597 (keys with embedded NUL) (Gopal) ++- Fixed pecl bug #17650 (Fix goto jump offsets) (Gopal) ++- Fixed pecl bug #17527 (Standardized error reporting) (Gopal, Paul Dragoonis) ++- Fixed pecl bug #17089 (Scrub the constant table of all inherited members before caching) (Gopal) ++- Fixed pecl bug #16860 (files can be included more than once even when include/require_once are used) (Pierre) ++- Fixed pecl bug #16717 (apc_fetch dies after 1 hour, regardless of ttl settings) (Kalle) ++- Fixed pecl bug #17597 (apc user cache keys with embedded NULs) (Gopal) ++- Fixed pecl bug #13583 (apc upload progress fixes) (Gopal) ++ ++ ++ ++ ++ 3.1.5 ++ 3.1.0 ++ ++ ++ beta ++ stable ++ ++ PHP License ++ 2010-11-01 ++ ++- Reduce usage of CG(open_files) (mkoppanen at php dot net) ++- Add support for php-trunk, new op code, new internals string format, etc. (Dmitry) ++- apc_debug are not compiler-valid NOPs for non-debug builds ++ ++- Fixed relative paths resolution when ./foo/a.php or ../foo/a.php (or similar path) ++ are used. 'foo/a.php' path behaviors remain unchanged ++- Fixed a possible memory corruption, when partial path cannot be resolved ++ by expand_filepath() ++- Fixed notices in apc.php (Tomasz Krawczyk) ++ ++- Fixed Bug #17978: standardize user keys to include NULs in identifier_len. Z_STRLEN_P() doesn't, so add to it. ++- Fixed bug #16966, apc produces tons of warnings "Unable to allocate memory for pool". ++ ++- Added --enable-apc-debug configuration argument to enable debugging (Kalle) ++- Added support for internal debugging on Windows (Kalle) ++- ZTS optimizations (Kalle) ++ ++ + + -diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock.c ---- php-5.3.1.orig/ext/apc/pgsql_s_lock.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/pgsql_s_lock.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,485 @@ +--- /dev/null ++++ b/ext/apc/pgsql_s_lock.c +@@ -0,0 +1,391 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2007-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -14631,7 +15649,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. + + */ + -+/* $Id: pgsql_s_lock.c 284592 2009-07-22 10:53:50Z kalle $ */ ++/* $Id: pgsql_s_lock.c 302175 2010-08-13 06:20:28Z kalle $ */ + +/*------------------------------------------------------------------------- + * @@ -14741,7 +15759,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. + * s_lock_stuck() - complain about a stuck spinlock + */ +static void -+s_lock_stuck(volatile slock_t *lock, const char *file, int line) ++s_lock_stuck(volatile slock_t *lock, const char *file, int line TSRMLS_DC) +{ +#if defined(S_LOCK_TEST) + fprintf(stderr, @@ -14753,7 +15771,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. + elog(PANIC, "stuck spinlock (%p) detected at %s:%d", + lock, file, line); + */ -+ apc_eprint("Stuck spinlock (%p) detected", lock); ++ apc_error("Stuck spinlock (%p) detected" TSRMLS_CC, lock); +#endif +} + @@ -14762,7 +15780,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. + * s_lock(lock) - platform-independent portion of waiting for a spinlock. + */ +void -+s_lock(volatile slock_t *lock, const char *file, int line) ++s_lock(volatile slock_t *lock, const char *file, int line TSRMLS_DC) +{ + /* + * We loop tightly for awhile, then delay using pg_usleep() and try again. @@ -14821,7 +15839,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. + if (++spins >= spins_per_delay) + { + if (++delays > NUM_DELAYS) -+ s_lock_stuck(lock, file, line); ++ s_lock_stuck(lock, file, line TSRMLS_CC); + + if (cur_delay == 0) /* first time to delay? */ + cur_delay = MIN_DELAY_MSEC; @@ -15000,110 +16018,15 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.c php-5.3.1/ext/apc/pgsql_s_lock. +#endif /* not __GNUC__ */ +#endif /* HAVE_SPINLOCKS */ + -+ -+ -+/*****************************************************************************/ -+#if defined(S_LOCK_TEST) -+ -+/* -+ * test program for verifying a port's spinlock support. -+ */ -+ -+struct test_lock_struct -+{ -+ char pad1; -+ slock_t lock; -+ char pad2; -+}; -+ -+volatile struct test_lock_struct test_lock; -+ -+int -+main() -+{ -+ srandom((unsigned int) time(NULL)); -+ -+ test_lock.pad1 = test_lock.pad2 = 0x44; -+ -+ S_INIT_LOCK(&test_lock.lock); -+ -+ if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) -+ { -+ printf("S_LOCK_TEST: failed, declared datatype is wrong size\n"); -+ return 1; -+ } -+ -+ if (!S_LOCK_FREE(&test_lock.lock)) -+ { -+ printf("S_LOCK_TEST: failed, lock not initialized\n"); -+ return 1; -+ } -+ -+ S_LOCK(&test_lock.lock); -+ -+ if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) -+ { -+ printf("S_LOCK_TEST: failed, declared datatype is wrong size\n"); -+ return 1; -+ } -+ -+ if (S_LOCK_FREE(&test_lock.lock)) -+ { -+ printf("S_LOCK_TEST: failed, lock not locked\n"); -+ return 1; -+ } -+ -+ S_UNLOCK(&test_lock.lock); -+ -+ if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) -+ { -+ printf("S_LOCK_TEST: failed, declared datatype is wrong size\n"); -+ return 1; -+ } -+ -+ if (!S_LOCK_FREE(&test_lock.lock)) -+ { -+ printf("S_LOCK_TEST: failed, lock not unlocked\n"); -+ return 1; -+ } -+ -+ S_LOCK(&test_lock.lock); -+ -+ if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44) -+ { -+ printf("S_LOCK_TEST: failed, declared datatype is wrong size\n"); -+ return 1; -+ } -+ -+ if (S_LOCK_FREE(&test_lock.lock)) -+ { -+ printf("S_LOCK_TEST: failed, lock not re-locked\n"); -+ return 1; -+ } -+ -+ printf("S_LOCK_TEST: this will print %d stars and then\n", NUM_DELAYS); -+ printf(" exit with a 'stuck spinlock' message\n"); -+ printf(" if S_LOCK() and TAS() are working.\n"); -+ fflush(stdout); -+ -+ s_lock(&test_lock.lock, __FILE__, __LINE__); -+ -+ printf("S_LOCK_TEST: failed, lock not locked\n"); -+ return 1; -+} -+ -+#endif /* S_LOCK_TEST */ -+ +#endif /* APC_SPIN_LOCKS */ -diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.h php-5.3.1/ext/apc/pgsql_s_lock.h ---- php-5.3.1.orig/ext/apc/pgsql_s_lock.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/pgsql_s_lock.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/pgsql_s_lock.h @@ -0,0 +1,928 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2007-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -15120,7 +16043,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.h php-5.3.1/ext/apc/pgsql_s_lock. + + */ + -+/* $Id: pgsql_s_lock.h 268255 2008-11-04 05:42:11Z rasmus $ */ ++/* $Id: pgsql_s_lock.h 302175 2010-08-13 06:20:28Z kalle $ */ + +/*------------------------------------------------------------------------- + * @@ -15985,7 +16908,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.h php-5.3.1/ext/apc/pgsql_s_lock. +#define S_LOCK(lock) \ + do { \ + if (TAS(lock)) \ -+ s_lock((lock), __FILE__, __LINE__); \ ++ s_lock((lock), __FILE__, __LINE__ TSRMLS_CC); \ + } while (0) +#endif /* S_LOCK */ + @@ -16016,7 +16939,7 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.h php-5.3.1/ext/apc/pgsql_s_lock. +/* + * Platform-independent out-of-line support routines + */ -+extern void s_lock(volatile slock_t *lock, const char *file, int line); ++extern void s_lock(volatile slock_t *lock, const char *file, int line TSRMLS_DC); + +/* Support for dynamic adjustment of spins_per_delay */ +#define DEFAULT_SPINS_PER_DELAY 100 @@ -16027,15 +16950,14 @@ diff -Naur php-5.3.1.orig/ext/apc/pgsql_s_lock.h php-5.3.1/ext/apc/pgsql_s_lock. +#endif + +#endif /* S_LOCK_H */ -diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c ---- php-5.3.1.orig/ext/apc/php_apc.c 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/php_apc.c 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,1649 @@ +--- /dev/null ++++ b/ext/apc/php_apc.c +@@ -0,0 +1,1812 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -16059,7 +16981,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + */ + -+/* $Id: php_apc.c 286798 2009-08-04 11:27:12Z gopalv $ */ ++/* $Id: php_apc.c 303642 2010-09-21 15:42:01Z kalle $ */ + +#include "apc_zend.h" +#include "apc_cache.h" @@ -16104,6 +17026,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c +PHP_FUNCTION(apc_bin_load); +PHP_FUNCTION(apc_bin_dumpfile); +PHP_FUNCTION(apc_bin_loadfile); ++PHP_FUNCTION(apc_exists); +/* }}} */ + +/* {{{ ZEND_DECLARE_MODULE_GLOBALS(apc) */ @@ -16118,12 +17041,13 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + apc_globals->filters = NULL; + apc_globals->compiled_filters = NULL; + apc_globals->initialized = 0; -+ apc_globals->cache_stack = apc_stack_create(0); ++ apc_globals->cache_stack = apc_stack_create(0 TSRMLS_CC); + apc_globals->cache_by_default = 1; + apc_globals->fpstat = 1; + apc_globals->canonicalize = 1; + apc_globals->stat_ctime = 0; + apc_globals->write_lock = 1; ++ apc_globals->slam_defense = 1; + apc_globals->report_autofilter = 0; + apc_globals->include_once = 0; + apc_globals->apc_optimize_function = NULL; @@ -16146,27 +17070,62 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + if (apc_globals->filters != NULL) { + int i; + for (i=0; apc_globals->filters[i] != NULL; i++) { -+ apc_efree(apc_globals->filters[i]); ++ apc_efree(apc_globals->filters[i] TSRMLS_CC); + } -+ apc_efree(apc_globals->filters); ++ apc_efree(apc_globals->filters TSRMLS_CC); + } + + /* the stack should be empty */ + assert(apc_stack_size(apc_globals->cache_stack) == 0); + + /* apc cleanup */ -+ apc_stack_destroy(apc_globals->cache_stack); ++ apc_stack_destroy(apc_globals->cache_stack TSRMLS_CC); + + /* the rest of the globals are cleaned up in apc_module_shutdown() */ +} + ++static long apc_atol(const char *str, int str_len) ++{ ++#if PHP_MAJOR_VERSION >= 6 || PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3 ++ return zend_atol(str, str_len); ++#else ++ /* Re-implement zend_atol() for 5.2.x */ ++ long retval; ++ ++ if (!str_len) { ++ str_len = strlen(str); ++ } ++ ++ retval = strtol(str, NULL, 0); ++ ++ if (str_len > 0) { ++ switch (str[str_len - 1]) { ++ case 'g': ++ case 'G': ++ retval *= 1024; ++ /* break intentionally missing */ ++ case 'm': ++ case 'M': ++ retval *= 1024; ++ /* break intentionally missing */ ++ case 'k': ++ case 'K': ++ retval *= 1024; ++ break; ++ } ++ } ++ ++ return retval; ++#endif ++} ++ +/* }}} */ + +/* {{{ PHP_INI */ + +static PHP_INI_MH(OnUpdate_filters) /* {{{ */ +{ -+ APCG(filters) = apc_tokenize(new_value, ','); ++ APCG(filters) = apc_tokenize(new_value, ',' TSRMLS_CC); + return SUCCESS; +} +/* }}} */ @@ -16174,29 +17133,49 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c +static PHP_INI_MH(OnUpdateShmSegments) /* {{{ */ +{ +#if APC_MMAP -+ if(atoi(new_value)!=1) { ++ if(zend_atoi(new_value, new_value_length)!=1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "apc.shm_segments setting ignored in MMAP mode"); + } + APCG(shm_segments) = 1; +#else -+ APCG(shm_segments) = atoi(new_value); ++ APCG(shm_segments) = zend_atoi(new_value, new_value_length); +#endif + return SUCCESS; +} +/* }}} */ + ++static PHP_INI_MH(OnUpdateShmSize) /* {{{ */ ++{ ++ long s = apc_atol(new_value, new_value_length); ++ ++ if(s <= 0) { ++ return FAILURE; ++ } ++ ++ if(s < 1048576L) { ++ /* if it's less than 1Mb, they are probably using the old syntax */ ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files"); ++ s = s * 1048576L; ++ } ++ ++ APCG(shm_size) = s; ++ ++ return SUCCESS; ++} ++/* }}} */ ++ +#ifdef MULTIPART_EVENT_FORMDATA +static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ +{ + int tmp; + tmp = zend_atoi(new_value, new_value_length); + if(tmp < 0) { -+ apc_eprint("rfc1867_freq must be greater than or equal to zero."); ++ apc_error("rfc1867_freq must be greater than or equal to zero." TSRMLS_CC); + return FAILURE; + } + if(new_value[new_value_length-1] == '%') { + if(tmp > 100) { -+ apc_eprint("rfc1867_freq cannot be over 100%%"); ++ apc_error("rfc1867_freq cannot be over 100%%" TSRMLS_CC); + return FAILURE; + } + APCG(rfc1867_freq) = tmp / 100.0; @@ -16208,37 +17187,39 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c +/* }}} */ +#endif + -+#define OnUpdateInt OnUpdateLong -+ +PHP_INI_BEGIN() +STD_PHP_INI_BOOLEAN("apc.enabled", "1", PHP_INI_SYSTEM, OnUpdateBool, enabled, zend_apc_globals, apc_globals) +STD_PHP_INI_ENTRY("apc.shm_segments", "1", PHP_INI_SYSTEM, OnUpdateShmSegments, shm_segments, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.shm_size", "30", PHP_INI_SYSTEM, OnUpdateInt, shm_size, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.shm_size", "32M", PHP_INI_SYSTEM, OnUpdateShmSize, shm_size, zend_apc_globals, apc_globals) ++#ifdef ZEND_ENGINE_2_4 ++STD_PHP_INI_ENTRY("apc.shm_strings_buffer", "4M", PHP_INI_SYSTEM, OnUpdateLong, shm_strings_buffer, zend_apc_globals, apc_globals) ++#endif +STD_PHP_INI_BOOLEAN("apc.include_once_override", "0", PHP_INI_SYSTEM, OnUpdateBool, include_once, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.num_files_hint", "1000", PHP_INI_SYSTEM, OnUpdateInt, num_files_hint, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.user_entries_hint", "4096", PHP_INI_SYSTEM, OnUpdateInt, user_entries_hint, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.gc_ttl", "3600", PHP_INI_SYSTEM, OnUpdateInt, gc_ttl, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.ttl", "0", PHP_INI_SYSTEM, OnUpdateInt, ttl, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.user_ttl", "0", PHP_INI_SYSTEM, OnUpdateInt, user_ttl, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.num_files_hint", "1000", PHP_INI_SYSTEM, OnUpdateLong, num_files_hint, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.user_entries_hint", "4096", PHP_INI_SYSTEM, OnUpdateLong, user_entries_hint, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.gc_ttl", "3600", PHP_INI_SYSTEM, OnUpdateLong, gc_ttl, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.ttl", "0", PHP_INI_SYSTEM, OnUpdateLong, ttl, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.user_ttl", "0", PHP_INI_SYSTEM, OnUpdateLong, user_ttl, zend_apc_globals, apc_globals) +#if APC_MMAP +STD_PHP_INI_ENTRY("apc.mmap_file_mask", NULL, PHP_INI_SYSTEM, OnUpdateString, mmap_file_mask, zend_apc_globals, apc_globals) +#endif +PHP_INI_ENTRY("apc.filters", NULL, PHP_INI_SYSTEM, OnUpdate_filters) +STD_PHP_INI_BOOLEAN("apc.cache_by_default", "1", PHP_INI_ALL, OnUpdateBool, cache_by_default, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.file_update_protection", "2", PHP_INI_SYSTEM, OnUpdateInt,file_update_protection, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.file_update_protection", "2", PHP_INI_SYSTEM, OnUpdateLong,file_update_protection, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.enable_cli", "0", PHP_INI_SYSTEM, OnUpdateBool, enable_cli, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.max_file_size", "1M", PHP_INI_SYSTEM, OnUpdateInt, max_file_size, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.max_file_size", "1M", PHP_INI_SYSTEM, OnUpdateLong, max_file_size, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.stat", "1", PHP_INI_SYSTEM, OnUpdateBool, fpstat, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.canonicalize", "1", PHP_INI_SYSTEM, OnUpdateBool, canonicalize, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.stat_ctime", "0", PHP_INI_SYSTEM, OnUpdateBool, stat_ctime, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.write_lock", "1", PHP_INI_SYSTEM, OnUpdateBool, write_lock, zend_apc_globals, apc_globals) ++STD_PHP_INI_BOOLEAN("apc.slam_defense", "1", PHP_INI_SYSTEM, OnUpdateBool, slam_defense, zend_apc_globals, apc_globals) +STD_PHP_INI_BOOLEAN("apc.report_autofilter", "0", PHP_INI_SYSTEM, OnUpdateBool, report_autofilter,zend_apc_globals, apc_globals) +#ifdef MULTIPART_EVENT_FORMDATA +STD_PHP_INI_BOOLEAN("apc.rfc1867", "0", PHP_INI_SYSTEM, OnUpdateBool, rfc1867, zend_apc_globals, apc_globals) +STD_PHP_INI_ENTRY("apc.rfc1867_prefix", "upload_", PHP_INI_SYSTEM, OnUpdateStringUnempty, rfc1867_prefix, zend_apc_globals, apc_globals) +STD_PHP_INI_ENTRY("apc.rfc1867_name", "APC_UPLOAD_PROGRESS", PHP_INI_SYSTEM, OnUpdateStringUnempty, rfc1867_name, zend_apc_globals, apc_globals) +STD_PHP_INI_ENTRY("apc.rfc1867_freq", "0", PHP_INI_SYSTEM, OnUpdateRfc1867Freq, rfc1867_freq, zend_apc_globals, apc_globals) -+STD_PHP_INI_ENTRY("apc.rfc1867_ttl", "3600", PHP_INI_SYSTEM, OnUpdateInt, rfc1867_ttl, zend_apc_globals, apc_globals) ++STD_PHP_INI_ENTRY("apc.rfc1867_ttl", "3600", PHP_INI_SYSTEM, OnUpdateLong, rfc1867_ttl, zend_apc_globals, apc_globals) +#endif +STD_PHP_INI_BOOLEAN("apc.coredump_unmap", "0", PHP_INI_SYSTEM, OnUpdateBool, coredump_unmap, zend_apc_globals, apc_globals) +STD_PHP_INI_ENTRY("apc.preload_path", (char*)NULL, PHP_INI_SYSTEM, OnUpdateString, preload_path, zend_apc_globals, apc_globals) @@ -16256,6 +17237,11 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + php_info_print_table_start(); + php_info_print_table_header(2, "APC Support", APCG(enabled) ? "enabled" : "disabled"); + php_info_print_table_row(2, "Version", PHP_APC_VERSION); ++#ifdef __DEBUG_APC__ ++ php_info_print_table_row(2, "APC Debugging", "Enabled"); ++#else ++ php_info_print_table_row(2, "APC Debugging", "Disabled"); ++#endif +#if APC_MMAP + php_info_print_table_row(2, "MMAP Support", "Enabled"); + php_info_print_table_row(2, "MMAP File Mask", APCG(mmap_file_mask)); @@ -16263,7 +17249,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + php_info_print_table_row(2, "MMAP Support", "Disabled"); +#endif + php_info_print_table_row(2, "Locking type", APC_LOCK_TYPE); -+ php_info_print_table_row(2, "Revision", "$Revision: 286798 $"); ++ php_info_print_table_row(2, "Revision", "$Revision: 303642 $"); + php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); + php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); @@ -16321,7 +17307,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + php_apc_shutdown_globals(&apc_globals); +#endif +#if HAVE_SIGACTION -+ apc_shutdown_signals(); ++ apc_shutdown_signals(TSRMLS_C); +#endif + } +#ifdef ZTS @@ -16373,7 +17359,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if(ZEND_NUM_ARGS()) { + if(!strcasecmp(cache_type,"user")) { -+ info = apc_cache_info(apc_user_cache, limited); ++ info = apc_cache_info(apc_user_cache, limited TSRMLS_CC); + } else if(!strcasecmp(cache_type,"filehits")) { +#ifdef APC_FILEHITS + RETVAL_ZVAL(APCG(filehits), 1, 0); @@ -16382,9 +17368,11 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + RETURN_FALSE; +#endif + } else { -+ info = apc_cache_info(apc_cache, limited); ++ info = apc_cache_info(apc_cache, limited TSRMLS_CC); + } -+ } else info = apc_cache_info(apc_cache, limited); ++ } else { ++ info = apc_cache_info(apc_cache, limited TSRMLS_CC); ++ } + + if(!info) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No APC info available. Perhaps APC is not enabled? Check apc.enabled in your ini file"); @@ -16423,7 +17411,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + add_assoc_stringl(return_value, "locking_type", "file", sizeof("file")-1, 1); +#endif + if(limited) { -+ apc_cache_free_info(info); ++ apc_cache_free_info(info TSRMLS_CC); + return; + } + @@ -16438,8 +17426,21 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if(p->type == APC_CACHE_ENTRY_FILE) { + add_assoc_string(link, "filename", p->data.file.filename, 1); ++#ifdef PHP_WIN32 ++ { ++ char buf[20]; ++ sprintf(buf, "%I64d", p->data.file.device); ++ add_assoc_string(link, "device", buf, 1); ++ ++ sprintf(buf, "%I64d", p->data.file.inode); ++ add_assoc_string(link, "inode", buf, 1); ++ } ++#else + add_assoc_long(link, "device", p->data.file.device); + add_assoc_long(link, "inode", p->data.file.inode); ++#endif ++ ++ + add_assoc_string(link, "type", "file", 1); + if(APCG(file_md5)) { + make_digest(md5str, p->data.file.md5); @@ -16476,8 +17477,20 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if(p->type == APC_CACHE_ENTRY_FILE) { + add_assoc_string(link, "filename", p->data.file.filename, 1); ++#ifdef PHP_WIN32 ++ { ++ char buf[20]; ++ sprintf(buf, "%I64d", p->data.file.device); ++ add_assoc_string(link, "device", buf, 1); ++ ++ sprintf(buf, "%I64d", p->data.file.inode); ++ add_assoc_string(link, "inode", buf, 1); ++ } ++#else + add_assoc_long(link, "device", p->data.file.device); + add_assoc_long(link, "inode", p->data.file.inode); ++#endif ++ + add_assoc_string(link, "type", "file", 1); + if(APCG(file_md5)) { + make_digest(md5str, p->data.file.md5); @@ -16501,7 +17514,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + } + add_assoc_zval(return_value, "deleted_list", list); + -+ apc_cache_free_info(info); ++ apc_cache_free_info(info TSRMLS_CC); +} +/* }}} */ + @@ -16517,11 +17530,11 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if(ct_len) { + if(!strcasecmp(cache_type, "user")) { -+ apc_cache_clear(apc_user_cache); ++ apc_cache_clear(apc_user_cache TSRMLS_CC); + RETURN_TRUE; + } + } -+ apc_cache_clear(apc_cache); ++ apc_cache_clear(apc_cache TSRMLS_CC); + RETURN_TRUE; +} +/* }}} */ @@ -16538,7 +17551,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + return; + } + -+ info = apc_sma_info(limited); ++ info = apc_sma_info(limited TSRMLS_CC); + + if(!info) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No APC SMA info available. Perhaps APC is disabled via apc.enabled?"); @@ -16551,7 +17564,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + add_assoc_double(return_value, "avail_mem", (double)apc_sma_get_avail_mem()); + + if(limited) { -+ apc_sma_free_info(info); ++ apc_sma_free_info(info TSRMLS_CC); + return; + } + @@ -16590,16 +17603,16 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + add_next_index_zval(block_lists, list); + } + add_assoc_zval(return_value, "block_lists", block_lists); -+ apc_sma_free_info(info); ++ apc_sma_free_info(info TSRMLS_CC); +} +/* }}} */ + +/* {{{ */ +int _apc_update(char *strkey, int strkey_len, apc_cache_updater_t updater, void* data TSRMLS_DC) +{ -+ if(!APCG(enabled)) { -+ return 0; -+ } ++ if(!APCG(enabled)) { ++ return 0; ++ } + + HANDLE_BLOCK_INTERRUPTIONS(); + APCG(current_cache) = apc_user_cache; @@ -16632,9 +17645,9 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + APCG(current_cache) = apc_user_cache; + -+ ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect); ++ ctxt.pool = apc_pool_create(APC_SMALL_POOL, apc_sma_malloc, apc_sma_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC); + if (!ctxt.pool) { -+ apc_wprint("Unable to allocate memory for pool."); ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); + return 0; + } + ctxt.copy = APC_COPY_IN_USER; @@ -16649,17 +17662,17 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + goto freepool; + } + -+ if (apc_cache_is_last_key(apc_user_cache, &key, t)) { ++ if (apc_cache_is_last_key(apc_user_cache, &key, 0, t TSRMLS_CC)) { + goto freepool; + } + -+ if (!(entry = apc_cache_make_user_entry(strkey, strkey_len, val, &ctxt, ttl))) { ++ if (!(entry = apc_cache_make_user_entry(strkey, strkey_len, val, &ctxt, ttl TSRMLS_CC))) { + goto freepool; + } + + if (!apc_cache_user_insert(apc_user_cache, key, entry, &ctxt, t, exclusive TSRMLS_CC)) { +freepool: -+ apc_pool_destroy(ctxt.pool); ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); + ret = 0; + } + @@ -16700,8 +17713,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { + zend_hash_get_current_key_ex(hash, &hkey, &hkey_len, &hkey_idx, 0, &hpos); + if (hkey) { -+ /* hkey_len - 1 for consistency, because it includes '\0', while Z_STRLEN_P() doesn't */ -+ if(!_apc_store(hkey, hkey_len - 1, *hentry, (unsigned int)ttl, exclusive TSRMLS_CC)) { ++ if(!_apc_store(hkey, hkey_len, *hentry, (unsigned int)ttl, exclusive TSRMLS_CC)) { + add_assoc_long_ex(return_value, hkey, hkey_len, -1); /* -1: insertion error */ + } + hkey = NULL; @@ -16713,10 +17725,10 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + return; + } else if (Z_TYPE_P(key) == IS_STRING) { + if (!val) RETURN_FALSE; -+ if(_apc_store(Z_STRVAL_P(key), Z_STRLEN_P(key), val, (unsigned int)ttl, exclusive TSRMLS_CC)) ++ if(_apc_store(Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, val, (unsigned int)ttl, exclusive TSRMLS_CC)) + RETURN_TRUE; + } else { -+ apc_wprint("apc_store expects key parameter to be a string or an array of key/value pairs."); ++ apc_warning("apc_store expects key parameter to be a string or an array of key/value pairs." TSRMLS_CC); + } + + RETURN_FALSE; @@ -16860,28 +17872,103 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + int strkey_len; + apc_cache_entry_t* entry; + time_t t; -+ apc_context_t ctxt = {0,}; ++ apc_context_t ctxt = {0,}; ++ ++ if(!APCG(enabled)) RETURN_FALSE; ++ ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &key, &success) == FAILURE) { ++ return; ++ } ++ ++ t = apc_time(); ++ ++ if (success) { ++ ZVAL_BOOL(success, 0); ++ } ++ ++ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL TSRMLS_CC); ++ if (!ctxt.pool) { ++ apc_warning("Unable to allocate memory for pool." TSRMLS_CC); ++ RETURN_FALSE; ++ } ++ ctxt.copy = APC_COPY_OUT_USER; ++ ctxt.force_update = 0; ++ ++ if(Z_TYPE_P(key) != IS_STRING && Z_TYPE_P(key) != IS_ARRAY) { ++ convert_to_string(key); ++ } ++ ++ if(Z_TYPE_P(key) == IS_STRING) { ++ strkey = Z_STRVAL_P(key); ++ strkey_len = Z_STRLEN_P(key); ++ if(!strkey_len) RETURN_FALSE; ++ entry = apc_cache_user_find(apc_user_cache, strkey, (strkey_len + 1), t TSRMLS_CC); ++ if(entry) { ++ /* deep-copy returned shm zval to emalloc'ed return_value */ ++ apc_cache_fetch_zval(return_value, entry->data.user.val, &ctxt TSRMLS_CC); ++ apc_cache_release(apc_user_cache, entry TSRMLS_CC); ++ } else { ++ goto freepool; ++ } ++ } else if(Z_TYPE_P(key) == IS_ARRAY) { ++ hash = Z_ARRVAL_P(key); ++ MAKE_STD_ZVAL(result); ++ array_init(result); ++ zend_hash_internal_pointer_reset_ex(hash, &hpos); ++ while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { ++ if(Z_TYPE_PP(hentry) != IS_STRING) { ++ apc_warning("apc_fetch() expects a string or array of strings." TSRMLS_CC); ++ goto freepool; ++ } ++ entry = apc_cache_user_find(apc_user_cache, Z_STRVAL_PP(hentry), (Z_STRLEN_PP(hentry) + 1), t TSRMLS_CC); ++ if(entry) { ++ /* deep-copy returned shm zval to emalloc'ed return_value */ ++ MAKE_STD_ZVAL(result_entry); ++ apc_cache_fetch_zval(result_entry, entry->data.user.val, &ctxt TSRMLS_CC); ++ apc_cache_release(apc_user_cache, entry TSRMLS_CC); ++ zend_hash_add(Z_ARRVAL_P(result), Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) +1, &result_entry, sizeof(zval*), NULL); ++ } /* don't set values we didn't find */ ++ zend_hash_move_forward_ex(hash, &hpos); ++ } ++ RETVAL_ZVAL(result, 0, 1); ++ } else { ++ apc_warning("apc_fetch() expects a string or array of strings." TSRMLS_CC); ++freepool: ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); ++ RETURN_FALSE; ++ } ++ ++ if (success) { ++ ZVAL_BOOL(success, 1); ++ } ++ ++ apc_pool_destroy(ctxt.pool TSRMLS_CC); ++ return; ++} ++/* }}} */ ++ ++/* {{{ proto mixed apc_exists(mixed key) ++ */ ++PHP_FUNCTION(apc_exists) { ++ zval *key; ++ HashTable *hash; ++ HashPosition hpos; ++ zval **hentry; ++ char *strkey; ++ int strkey_len; ++ apc_cache_entry_t* entry; ++ zval *result; ++ zval *result_entry; ++ time_t t; + + if(!APCG(enabled)) RETURN_FALSE; + -+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &key, &success) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &key) == FAILURE) { + return; + } + + t = apc_time(); + -+ if (success) { -+ ZVAL_BOOL(success, 0); -+ } -+ -+ ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, NULL, NULL); -+ if (!ctxt.pool) { -+ apc_wprint("Unable to allocate memory for pool."); -+ RETURN_FALSE; -+ } -+ ctxt.copy = APC_COPY_OUT_USER; -+ ctxt.force_update = 0; -+ + if(Z_TYPE_P(key) != IS_STRING && Z_TYPE_P(key) != IS_ARRAY) { + convert_to_string(key); + } @@ -16890,13 +17977,9 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + strkey = Z_STRVAL_P(key); + strkey_len = Z_STRLEN_P(key); + if(!strkey_len) RETURN_FALSE; -+ entry = apc_cache_user_find(apc_user_cache, strkey, strkey_len + 1, t); ++ entry = apc_cache_user_exists(apc_user_cache, strkey, strkey_len + 1, t TSRMLS_CC); + if(entry) { -+ /* deep-copy returned shm zval to emalloc'ed return_value */ -+ apc_cache_fetch_zval(return_value, entry->data.user.val, &ctxt); -+ apc_cache_release(apc_user_cache, entry); -+ } else { -+ goto freepool; ++ RETURN_TRUE; + } + } else if(Z_TYPE_P(key) == IS_ARRAY) { + hash = Z_ARRVAL_P(key); @@ -16905,33 +17988,24 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + zend_hash_internal_pointer_reset_ex(hash, &hpos); + while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { + if(Z_TYPE_PP(hentry) != IS_STRING) { -+ apc_wprint("apc_fetch() expects a string or array of strings."); -+ goto freepool; ++ apc_warning("apc_exists() expects a string or array of strings." TSRMLS_CC); ++ RETURN_FALSE; + } -+ entry = apc_cache_user_find(apc_user_cache, Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) + 1, t); ++ ++ entry = apc_cache_user_exists(apc_user_cache, Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) + 1, t TSRMLS_CC); + if(entry) { -+ /* deep-copy returned shm zval to emalloc'ed return_value */ + MAKE_STD_ZVAL(result_entry); -+ apc_cache_fetch_zval(result_entry, entry->data.user.val, &ctxt); -+ apc_cache_release(apc_user_cache, entry); ++ ZVAL_BOOL(result_entry, 1); + zend_hash_add(Z_ARRVAL_P(result), Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) +1, &result_entry, sizeof(zval*), NULL); + } /* don't set values we didn't find */ + zend_hash_move_forward_ex(hash, &hpos); + } -+ RETVAL_ZVAL(result, 0, 1); ++ RETURN_ZVAL(result, 0, 1); + } else { -+ apc_wprint("apc_fetch() expects a string or array of strings."); -+freepool: -+ apc_pool_destroy(ctxt.pool); -+ RETURN_FALSE; -+ } -+ -+ if (success) { -+ ZVAL_BOOL(success, 1); ++ apc_warning("apc_exists() expects a string or array of strings." TSRMLS_CC); + } + -+ apc_pool_destroy(ctxt.pool); -+ return; ++ RETURN_FALSE; +} +/* }}} */ + @@ -16949,7 +18023,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if (Z_TYPE_P(keys) == IS_STRING) { + if (!Z_STRLEN_P(keys)) RETURN_FALSE; -+ if(apc_cache_user_delete(apc_user_cache, Z_STRVAL_P(keys), Z_STRLEN_P(keys) + 1)) { ++ if(apc_cache_user_delete(apc_user_cache, Z_STRVAL_P(keys), (Z_STRLEN_P(keys) + 1) TSRMLS_CC)) { + RETURN_TRUE; + } else { + RETURN_FALSE; @@ -16962,10 +18036,10 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + zend_hash_internal_pointer_reset_ex(hash, &hpos); + while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { + if(Z_TYPE_PP(hentry) != IS_STRING) { -+ apc_wprint("apc_delete() expects a string, array of strings, or APCIterator instance."); ++ apc_warning("apc_delete() expects a string, array of strings, or APCIterator instance." TSRMLS_CC); + add_next_index_zval(return_value, *hentry); + Z_ADDREF_PP(hentry); -+ } else if(apc_cache_user_delete(apc_user_cache, Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) + 1) != 1) { ++ } else if(apc_cache_user_delete(apc_user_cache, Z_STRVAL_PP(hentry), (Z_STRLEN_PP(hentry) + 1) TSRMLS_CC) != 1) { + add_next_index_zval(return_value, *hentry); + Z_ADDREF_PP(hentry); + } @@ -16979,7 +18053,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + RETURN_FALSE; + } + } else { -+ apc_wprint("apc_delete() expects a string, array of strings, or APCIterator instance."); ++ apc_warning("apc_delete() expects a string, array of strings, or APCIterator instance." TSRMLS_CC); + } +} +/* }}} */ @@ -17000,7 +18074,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if (Z_TYPE_P(keys) == IS_STRING) { + if (!Z_STRLEN_P(keys)) RETURN_FALSE; -+ if(apc_cache_delete(apc_cache, Z_STRVAL_P(keys), Z_STRLEN_P(keys) + 1) != 1) { ++ if(apc_cache_delete(apc_cache, Z_STRVAL_P(keys), Z_STRLEN_P(keys) + 1 TSRMLS_CC) != 1) { + RETURN_FALSE; + } else { + RETURN_TRUE; @@ -17013,10 +18087,10 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + zend_hash_internal_pointer_reset_ex(hash, &hpos); + while(zend_hash_get_current_data_ex(hash, (void**)&hentry, &hpos) == SUCCESS) { + if(Z_TYPE_PP(hentry) != IS_STRING) { -+ apc_wprint("apc_delete_file() expects a string, array of strings, or APCIterator instance."); ++ apc_warning("apc_delete_file() expects a string, array of strings, or APCIterator instance." TSRMLS_CC); + add_next_index_zval(return_value, *hentry); + Z_ADDREF_PP(hentry); -+ } else if(apc_cache_delete(apc_cache, Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) + 1) != 1) { ++ } else if(apc_cache_delete(apc_cache, Z_STRVAL_PP(hentry), Z_STRLEN_PP(hentry) + 1 TSRMLS_CC) != 1) { + add_next_index_zval(return_value, *hentry); + Z_ADDREF_PP(hentry); + } @@ -17030,7 +18104,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + RETURN_FALSE; + } + } else { -+ apc_wprint("apc_delete_file() expects a string, array of strings, or APCIterator instance."); ++ apc_warning("apc_delete_file() expects a string, array of strings, or APCIterator instance." TSRMLS_CC); + } +} +/* }}} */ @@ -17092,7 +18166,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + if(!strkey_len) RETURN_FALSE; + + _apc_define_constants(constants, case_sensitive TSRMLS_CC); -+ if(_apc_store(strkey, strkey_len, constants, 0, 0 TSRMLS_CC)) RETURN_TRUE; ++ if(_apc_store(strkey, strkey_len + 1, constants, 0, 0 TSRMLS_CC)) RETURN_TRUE; + RETURN_FALSE; +} /* }}} */ + @@ -17114,11 +18188,11 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + t = apc_time(); + -+ entry = apc_cache_user_find(apc_user_cache, strkey, strkey_len + 1, t); ++ entry = apc_cache_user_find(apc_user_cache, strkey, (strkey_len + 1), t TSRMLS_CC); + + if(entry) { + _apc_define_constants(entry->data.user.val, case_sensitive TSRMLS_CC); -+ apc_cache_release(apc_user_cache, entry); ++ apc_cache_release(apc_user_cache, entry TSRMLS_CC); + RETURN_TRUE; + } else { + RETURN_FALSE; @@ -17157,7 +18231,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + } + + if (Z_TYPE_P(file) != IS_ARRAY && Z_TYPE_P(file) != IS_STRING) { -+ apc_wprint("apc_compile_file argument must be a string or an array of strings"); ++ apc_warning("apc_compile_file argument must be a string or an array of strings" TSRMLS_CC); + RETURN_FALSE; + } + @@ -17198,7 +18272,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + EG(current_execute_data) = orig_current_execute_data; + EG(in_execution) = 1; + CG(unclean_shutdown) = 0; -+ apc_wprint("Error compiling %s in apc_compile_file.", file_handle.filename); ++ apc_warning("Error compiling %s in apc_compile_file." TSRMLS_CC, file_handle.filename); + op_array = NULL; + } zend_end_try(); + if(op_array != NULL) { @@ -17223,7 +18297,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(file), &hpos); + while(zend_hash_get_current_data_ex(Z_ARRVAL_P(file), (void**)&hentry, &hpos) == SUCCESS) { + if (Z_TYPE_PP(hentry) != IS_STRING) { -+ apc_wprint("apc_compile_file array values must be strings, aborting."); ++ apc_warning("apc_compile_file array values must be strings, aborting." TSRMLS_CC); + break; + } + file_handle.type = ZEND_HANDLE_FILENAME; @@ -17233,7 +18307,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + + if (!apc_cache_make_file_key(&(keys[i]), file_handle.filename, PG(include_path), t TSRMLS_CC)) { + add_assoc_long(return_value, Z_STRVAL_PP(hentry), -1); /* -1: compilation error */ -+ apc_wprint("Error compiling %s in apc_compile_file.", file_handle.filename); ++ apc_warning("Error compiling %s in apc_compile_file." TSRMLS_CC, file_handle.filename); + break; + } + @@ -17249,7 +18323,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + op_arrays[i] = NULL; + cache_entries[i] = NULL; + add_assoc_long(return_value, Z_STRVAL_PP(hentry), -2); /* -2: input or cache insertion error */ -+ apc_wprint("Error compiling %s in apc_compile_file.", file_handle.filename); ++ apc_warning("Error compiling %s in apc_compile_file." TSRMLS_CC, file_handle.filename); + } + } zend_catch { + EG(current_execute_data) = orig_current_execute_data; @@ -17258,7 +18332,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + op_arrays[i] = NULL; + cache_entries[i] = NULL; + add_assoc_long(return_value, Z_STRVAL_PP(hentry), -1); /* -1: compilation error */ -+ apc_wprint("Error compiling %s in apc_compile_file.", file_handle.filename); ++ apc_warning("Error compiling %s in apc_compile_file." TSRMLS_CC, file_handle.filename); + } zend_end_try(); + + zend_destroy_file_handle(&file_handle TSRMLS_CC); @@ -17278,7 +18352,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + ctxt.copy = APC_COPY_IN_OPCODE; + ctxt.force_update = 1; + if (count == i || !atomic) { -+ rval = apc_cache_insert_mult(apc_cache, keys, cache_entries, &ctxt, t, i); ++ rval = apc_cache_insert_mult(apc_cache, keys, cache_entries, &ctxt, t, i TSRMLS_CC); + atomic_fail = 0; + } else { + atomic_fail = 1; @@ -17290,7 +18364,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + if (rval && rval[c] != 1) { + add_assoc_long(return_value, Z_STRVAL_PP(hentry), -2); /* -2: input or cache insertion error */ + if (cache_entries[c]) { -+ apc_pool_destroy(cache_entries[c]->pool); ++ apc_pool_destroy(cache_entries[c]->pool TSRMLS_CC); + } + } + if (op_arrays[c]) { @@ -17298,7 +18372,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + efree(op_arrays[c]); + } + if (atomic_fail && cache_entries[c]) { -+ apc_pool_destroy(cache_entries[c]->pool); ++ apc_pool_destroy(cache_entries[c]->pool TSRMLS_CC); + } + if (keys[c].type == APC_CACHE_KEY_FPFILE) { + efree((void*)keys[c].data.fpfile.fullpath); @@ -17341,12 +18415,12 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + */ +PHP_FUNCTION(apc_bin_dump) { + -+ zval *z_files, *z_user_vars; ++ zval *z_files = NULL, *z_user_vars = NULL; + HashTable *h_files, *h_user_vars; + apc_bd_t *bd; + + if(!APCG(enabled)) { -+ apc_wprint("APC is not enabled, apc_bin_dump not available."); ++ apc_warning("APC is not enabled, apc_bin_dump not available." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17360,7 +18434,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + if(bd) { + RETVAL_STRINGL((char*)bd, bd->size-1, 0); + } else { -+ apc_eprint("Unkown error encounterd during apc_bin_dump."); ++ apc_error("Unknown error encountered during apc_bin_dump." TSRMLS_CC); + RETVAL_NULL(); + } + @@ -17372,9 +18446,9 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + */ +PHP_FUNCTION(apc_bin_dumpfile) { + -+ zval *z_files, *z_user_vars; ++ zval *z_files = NULL, *z_user_vars = NULL; + HashTable *h_files, *h_user_vars; -+ char *filename; ++ char *filename = NULL; + int filename_len; + long flags=0; + zval *zcontext = NULL; @@ -17384,7 +18458,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + apc_bd_t *bd; + + if(!APCG(enabled)) { -+ apc_wprint("APC is not enabled, apc_bin_dumpfile not available."); ++ apc_warning("APC is not enabled, apc_bin_dumpfile not available." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17394,7 +18468,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + } + + if(!filename_len) { -+ apc_eprint("apc_bin_dumpfile filename argument must be a valid filename."); ++ apc_error("apc_bin_dumpfile filename argument must be a valid filename." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17402,7 +18476,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + h_user_vars = z_user_vars ? Z_ARRVAL_P(z_user_vars) : NULL; + bd = apc_bin_dump(h_files, h_user_vars TSRMLS_CC); + if(!bd) { -+ apc_eprint("Unkown error uncountered during apc binary dump."); ++ apc_error("Unknown error encountered during apc_bin_dumpfile." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17414,14 +18488,14 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context); + if (stream == NULL) { + efree(bd); -+ apc_eprint("Unable to write to file in apc_bin_dumpfile."); ++ apc_error("Unable to write to file in apc_bin_dumpfile." TSRMLS_CC); + RETURN_FALSE; + } + + if (flags & LOCK_EX && php_stream_lock(stream, LOCK_EX)) { + php_stream_close(stream); + efree(bd); -+ apc_eprint("Unable to get a lock on file in apc_bin_dumpfile."); ++ apc_error("Unable to get a lock on file in apc_bin_dumpfile." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17434,7 +18508,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + efree(bd); + + if(numbytes < 0) { -+ apc_wprint("Only %d of %d bytes written, possibly out of free disk space", numbytes, bd->size); ++ apc_error("Only %d of %d bytes written, possibly out of free disk space" TSRMLS_CC, numbytes, bd->size); + RETURN_FALSE; + } + @@ -17451,7 +18525,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + long flags = 0; + + if(!APCG(enabled)) { -+ apc_wprint("APC is not enabled, apc_bin_load not available."); ++ apc_warning("APC is not enabled, apc_bin_load not available." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17460,7 +18534,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + } + + if(!data_len || data_len != ((apc_bd_t*)data)->size -1) { -+ apc_eprint("apc_bin_load string argument does not appear to be a valid APC binary dump due to size (%d vs expected %d).", data_len, ((apc_bd_t*)data)->size -1); ++ apc_error("apc_bin_load string argument does not appear to be a valid APC binary dump due to size (%d vs expected %d)." TSRMLS_CC, data_len, ((apc_bd_t*)data)->size -1); + RETURN_FALSE; + } + @@ -17484,7 +18558,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + int len; + + if(!APCG(enabled)) { -+ apc_wprint("APC is not enabled, apc_bin_loadfile not available."); ++ apc_warning("APC is not enabled, apc_bin_loadfile not available." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17493,7 +18567,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + } + + if(!filename_len) { -+ apc_eprint("apc_bin_loadfile filename argument must be a valid filename."); ++ apc_error("apc_bin_loadfile filename argument must be a valid filename." TSRMLS_CC); + RETURN_FALSE; + } + @@ -17501,19 +18575,19 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + stream = php_stream_open_wrapper_ex(filename, "rb", + ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context); + if (!stream) { -+ apc_eprint("Unable to read from file in apc_bin_loadfile."); ++ apc_error("Unable to read from file in apc_bin_loadfile." TSRMLS_CC); + RETURN_FALSE; + } + + len = php_stream_copy_to_mem(stream, &data, PHP_STREAM_COPY_ALL, 0); + if(len == 0) { -+ apc_wprint("File passed to apc_bin_loadfile was empty: %s.", filename); ++ apc_warning("File passed to apc_bin_loadfile was empty: %s." TSRMLS_CC, filename); + RETURN_FALSE; + } else if(len < 0) { -+ apc_wprint("Error reading file passed to apc_bin_loadfile: %s.", filename); ++ apc_warning("Error reading file passed to apc_bin_loadfile: %s." TSRMLS_CC, filename); + RETURN_FALSE; + } else if(len != ((apc_bd_t*)data)->size) { -+ apc_wprint("file passed to apc_bin_loadfile does not appear to be valid due to size (%d vs expected %d).", len, ((apc_bd_t*)data)->size -1); ++ apc_warning("file passed to apc_bin_loadfile does not appear to be valid due to size (%d vs expected %d)." TSRMLS_CC, len, ((apc_bd_t*)data)->size -1); + RETURN_FALSE; + } + php_stream_close(stream); @@ -17545,6 +18619,11 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c +ZEND_END_ARG_INFO() + +PHP_APC_ARGINFO ++ZEND_BEGIN_ARG_INFO_EX(arginfo_apc_sma_info, 0, 0, 0) ++ ZEND_ARG_INFO(0, limited) ++ZEND_END_ARG_INFO() ++ ++PHP_APC_ARGINFO +ZEND_BEGIN_ARG_INFO_EX(arginfo_apc_cache_info, 0, 0, 0) + ZEND_ARG_INFO(0, type) + ZEND_ARG_INFO(0, limited) @@ -17626,13 +18705,18 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() ++ ++PHP_APC_ARGINFO ++ZEND_BEGIN_ARG_INFO(arginfo_apc_exists, 0) ++ ZEND_ARG_INFO(0, keys) ++ZEND_END_ARG_INFO() +/* }}} */ + +/* {{{ apc_functions[] */ -+function_entry apc_functions[] = { ++zend_function_entry apc_functions[] = { + PHP_FE(apc_cache_info, arginfo_apc_cache_info) + PHP_FE(apc_clear_cache, arginfo_apc_clear_cache) -+ PHP_FE(apc_sma_info, arginfo_apc_clear_cache) ++ PHP_FE(apc_sma_info, arginfo_apc_sma_info) + PHP_FE(apc_store, arginfo_apc_store) + PHP_FE(apc_fetch, arginfo_apc_fetch) + PHP_FE(apc_delete, arginfo_apc_delete) @@ -17648,6 +18732,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + PHP_FE(apc_bin_load, arginfo_apc_bin_load) + PHP_FE(apc_bin_dumpfile, arginfo_apc_bin_dumpfile) + PHP_FE(apc_bin_loadfile, arginfo_apc_bin_loadfile) ++ PHP_FE(apc_exists, arginfo_apc_exists) + {NULL, NULL, NULL} +}; +/* }}} */ @@ -17680,15 +18765,14 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.c php-5.3.1/ext/apc/php_apc.c + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/php_apc.h php-5.3.1/ext/apc/php_apc.h ---- php-5.3.1.orig/ext/apc/php_apc.h 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/php_apc.h 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/php_apc.h @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | APC | + +----------------------------------------------------------------------+ -+ | Copyright (c) 2006-2008 The PHP Group | ++ | Copyright (c) 2006-2010 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | @@ -17713,7 +18797,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.h php-5.3.1/ext/apc/php_apc.h + + */ + -+/* $Id: php_apc.h 287286 2009-08-14 10:50:22Z gopalv $ */ ++/* $Id: php_apc.h 305846 2010-11-30 09:36:57Z gopalv $ */ + +#ifndef PHP_APC_H +#define PHP_APC_H @@ -17721,7 +18805,7 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.h php-5.3.1/ext/apc/php_apc.h +#include "apc_php.h" +#include "apc_globals.h" + -+#define PHP_APC_VERSION "3.1.3p1" ++#define PHP_APC_VERSION "3.1.6" + +extern zend_module_entry apc_module_entry; +#define apc_module_ptr &apc_module_entry @@ -17738,9 +18822,8 @@ diff -Naur php-5.3.1.orig/ext/apc/php_apc.h php-5.3.1/ext/apc/php_apc.h + * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker + * vim<600: expandtab sw=4 ts=4 sts=4 + */ -diff -Naur php-5.3.1.orig/ext/apc/TECHNOTES.txt php-5.3.1/ext/apc/TECHNOTES.txt ---- php-5.3.1.orig/ext/apc/TECHNOTES.txt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/TECHNOTES.txt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/TECHNOTES.txt @@ -0,0 +1,361 @@ +APC Quick-Start Braindump + @@ -17965,7 +19048,7 @@ diff -Naur php-5.3.1.orig/ext/apc/TECHNOTES.txt php-5.3.1/ext/apc/TECHNOTES.txt + symlinks and get rid of relative path components. By using the device+inode we + can uniquely identify a file with a single stat. + -+ So, on an insert we find the array position in the slots array by hasing the device+inode. ++ So, on an insert we find the array position in the slots array by hashing the device+inode. + If there are currently no other slots there, we just create the slot and stick it into + the array: + @@ -18103,10 +19186,9 @@ diff -Naur php-5.3.1.orig/ext/apc/TECHNOTES.txt php-5.3.1/ext/apc/TECHNOTES.txt +If you made it to the end of this, you should have a pretty good idea of where things are in +the code. I skimmed over a lot of things, so plan on spending some time reading through the code. + -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_001.phpt php-5.3.1/ext/apc/tests/apc_001.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_001.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_001.phpt 1970-01-01 10:14:21.000000000 +0100 -@@ -0,0 +1,27 @@ +--- /dev/null ++++ b/ext/apc/tests/apc_001.phpt +@@ -0,0 +1,32 @@ +--TEST-- +APC: apc_store/fetch with strings +--SKIPIF-- @@ -18126,6 +19208,10 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_001.phpt php-5.3.1/ext/apc/tests/apc +$bar = 'nice'; +var_dump($bar); + ++apc_store('foo\x00bar', $foo); ++$bar = apc_fetch('foo\x00bar'); ++var_dump($bar); ++ +?> +===DONE=== + @@ -18133,10 +19219,10 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_001.phpt php-5.3.1/ext/apc/tests/apc +string(11) "hello world" +string(11) "hello world" +string(4) "nice" ++string(11) "hello world" +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_002.phpt php-5.3.1/ext/apc/tests/apc_002.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_002.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_002.phpt 1970-01-01 10:14:21.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_002.phpt @@ -0,0 +1,34 @@ +--TEST-- +APC: apc_store/fetch with objects @@ -18172,9 +19258,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_002.phpt php-5.3.1/ext/apc/tests/apc + bool(true) +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_003b.phpt php-5.3.1/ext/apc/tests/apc_003b.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_003b.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_003b.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_003b.phpt @@ -0,0 +1,117 @@ +--TEST-- +APC: apc_store/fetch with objects (php 5.3) @@ -18293,9 +19378,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_003b.phpt php-5.3.1/ext/apc/tests/ap + bool(true) +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_003.phpt php-5.3.1/ext/apc/tests/apc_003.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_003.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_003.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_003.phpt @@ -0,0 +1,117 @@ +--TEST-- +APC: apc_store/fetch with objects (php pre-5.3) @@ -18414,9 +19498,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_003.phpt php-5.3.1/ext/apc/tests/apc + bool(true) +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_004.phpt php-5.3.1/ext/apc/tests/apc_004.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_004.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_004.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_004.phpt @@ -0,0 +1,38 @@ +--TEST-- +APC: apc_store/fetch with bools @@ -18456,9 +19539,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_004.phpt php-5.3.1/ext/apc/tests/apc +bool(false) +bool(false) +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_005.phpt php-5.3.1/ext/apc/tests/apc_005.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_005.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_005.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_005.phpt @@ -0,0 +1,50 @@ +--TEST-- +APC: apc_store/fetch with arrays of objects @@ -18510,9 +19592,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_005.phpt php-5.3.1/ext/apc/tests/apc + } +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_006.phpt php-5.3.1/ext/apc/tests/apc_006.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_006.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_006.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_006.phpt @@ -0,0 +1,72 @@ +--TEST-- +APC: apc_store/fetch reference test @@ -18586,9 +19667,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_006.phpt php-5.3.1/ext/apc/tests/apc + } +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_007.phpt php-5.3.1/ext/apc/tests/apc_007.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_007.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_007.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_007.phpt @@ -0,0 +1,46 @@ +--TEST-- +APC: apc_inc/apc_dec test @@ -18636,9 +19716,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_007.phpt php-5.3.1/ext/apc/tests/apc +$foobar -= 1 = 2 +pass by ref success 1 +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_008.phpt php-5.3.1/ext/apc/tests/apc_008.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_008.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_008.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_008.phpt @@ -0,0 +1,34 @@ +--TEST-- +APC: apc_cas test @@ -18674,10 +19753,9 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_008.phpt php-5.3.1/ext/apc/tests/apc +$perfection == 2 ? 1 : 2 = epic fail +$foobar = 1 +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_009.phpt php-5.3.1/ext/apc/tests/apc_009.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_009.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_009.phpt 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,94 @@ +--- /dev/null ++++ b/ext/apc/tests/apc_009.phpt +@@ -0,0 +1,97 @@ +--TEST-- +APC: apc_delete_file test +--SKIPIF-- @@ -18686,6 +19764,7 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_009.phpt php-5.3.1/ext/apc/tests/apc +apc.enabled=1 +apc.enable_cli=1 +apc.file_update_protection=0 ++apc.stat=On +report_memleaks=0 +--FILE-- + + int(-1) @@ -18772,9 +19853,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_009.phpt php-5.3.1/ext/apc/tests/apc +apc_009-2.php Not Found +nofile.php Not Found +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_010.phpt php-5.3.1/ext/apc/tests/apc_010.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_010.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_010.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_010.phpt @@ -0,0 +1,83 @@ +--TEST-- +APC: apc_store/fetch/add with array of key/value pairs. @@ -18859,9 +19939,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_010.phpt php-5.3.1/ext/apc/tests/apc + int(4) +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_001.phpt php-5.3.1/ext/apc/tests/apc53_001.phpt ---- php-5.3.1.orig/ext/apc/tests/apc53_001.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc53_001.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc53_001.phpt @@ -0,0 +1,33 @@ +--TEST-- +APC: classes with namespaces (php 5.3) @@ -18896,9 +19975,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_001.phpt php-5.3.1/ext/apc/tests/a + string(11) "hello world" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_002.phpt php-5.3.1/ext/apc/tests/apc53_002.phpt ---- php-5.3.1.orig/ext/apc/tests/apc53_002.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc53_002.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc53_002.phpt @@ -0,0 +1,47 @@ +--TEST-- +APC: global spaces (php 5.3) @@ -18947,9 +20025,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_002.phpt php-5.3.1/ext/apc/tests/a +} +string(8) "IT WORKS" +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_003.phpt php-5.3.1/ext/apc/tests/apc53_003.phpt ---- php-5.3.1.orig/ext/apc/tests/apc53_003.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc53_003.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc53_003.phpt @@ -0,0 +1,31 @@ +--TEST-- +APC: anonymous functions (php 5.3) @@ -18982,9 +20059,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_003.phpt php-5.3.1/ext/apc/tests/a +Hello World +Hello PHP +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_004.phpt php-5.3.1/ext/apc/tests/apc53_004.phpt ---- php-5.3.1.orig/ext/apc/tests/apc53_004.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc53_004.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc53_004.phpt @@ -0,0 +1,33 @@ +--TEST-- +APC: closures (php 5.3) @@ -19019,9 +20095,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_004.phpt php-5.3.1/ext/apc/tests/a +double of 9 is 18 +triple of 4 is 12 +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_005.phpt php-5.3.1/ext/apc/tests/apc53_005.phpt ---- php-5.3.1.orig/ext/apc/tests/apc53_005.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc53_005.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc53_005.phpt @@ -0,0 +1,35 @@ +--TEST-- +APC: goto (php 5.3) @@ -19058,10 +20133,9 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc53_005.phpt php-5.3.1/ext/apc/tests/a +8 +10 +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_bin_001.phpt php-5.3.1/ext/apc/tests/apc_bin_001.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_bin_001.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_bin_001.phpt 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,23 @@ +--- /dev/null ++++ b/ext/apc/tests/apc_bin_001.phpt +@@ -0,0 +1,24 @@ +--TEST-- +APC: bindump user cache +--SKIPIF-- @@ -19073,6 +20147,7 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_bin_001.phpt php-5.3.1/ext/apc/tests + -diff -Naur php-5.3.1.orig/ext/apc/tests/apc_bin_002.phpt php-5.3.1/ext/apc/tests/apc_bin_002.phpt ---- php-5.3.1.orig/ext/apc/tests/apc_bin_002.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/apc_bin_002.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/apc_bin_002.phpt @@ -0,0 +1,53 @@ +--TEST-- +APC: bindump file cache part 1 @@ -19197,9 +20269,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/apc_bin_002.phpt php-5.3.1/ext/apc/tests +inherited class constant: Success + +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_001.phpt php-5.3.1/ext/apc/tests/iterator_001.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_001.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_001.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_001.phpt @@ -0,0 +1,110 @@ +--TEST-- +APC: APCIterator general @@ -19311,9 +20382,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_001.phpt php-5.3.1/ext/apc/test + string(4) "key9" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_002.phpt php-5.3.1/ext/apc/tests/iterator_002.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_002.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_002.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_002.phpt @@ -0,0 +1,36 @@ +--TEST-- +APC: APCIterator regex @@ -19351,9 +20421,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_002.phpt php-5.3.1/ext/apc/test + string(5) "key40" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_003.phpt php-5.3.1/ext/apc/tests/iterator_003.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_003.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_003.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_003.phpt @@ -0,0 +1,110 @@ +--TEST-- +APC: APCIterator chunk size @@ -19465,9 +20534,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_003.phpt php-5.3.1/ext/apc/test + string(4) "key9" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_004.phpt php-5.3.1/ext/apc/tests/iterator_004.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_004.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_004.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_004.phpt @@ -0,0 +1,36 @@ +--TEST-- +APC: APCIterator regex & chunk size & list @@ -19505,9 +20573,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_004.phpt php-5.3.1/ext/apc/test + string(5) "key40" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_005.phpt php-5.3.1/ext/apc/tests/iterator_005.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_005.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_005.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_005.phpt @@ -0,0 +1,112 @@ +--TEST-- +APC: APCIterator delete @@ -19621,9 +20688,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_005.phpt php-5.3.1/ext/apc/test + string(4) "key9" +} +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/tests/iterator_006.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_006.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_006.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_006.phpt @@ -0,0 +1,1535 @@ +--TEST-- +APC: APCIterator formats @@ -19688,6 +20754,11 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +--EXPECTF-- +IT #0 +============================ ++string(5) "key10" ++array(1) { ++ ["type"]=> ++ string(4) "user" ++} +string(4) "key0" +array(1) { + ["type"]=> @@ -19738,15 +20809,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["type"]=> + string(4) "user" +} -+string(5) "key10" -+array(1) { -+ ["type"]=> -+ string(4) "user" -+} +============================ + +IT #1 +============================ ++string(5) "key10" ++array(1) { ++ ["key"]=> ++ string(5) "key10" ++} +string(4) "key0" +array(1) { + ["key"]=> @@ -19797,15 +20868,13 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["key"]=> + string(4) "key9" +} -+string(5) "key10" -+array(1) { -+ ["key"]=> -+ string(5) "key10" -+} +============================ + +IT #2 +============================ ++string(5) "key10" ++array(0) { ++} +string(4) "key0" +array(0) { +} @@ -19836,13 +20905,13 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key9" +array(0) { +} -+string(5) "key10" -+array(0) { -+} +============================ + +IT #3 +============================ ++string(5) "key10" ++array(0) { ++} +string(4) "key0" +array(0) { +} @@ -19873,13 +20942,13 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key9" +array(0) { +} -+string(5) "key10" -+array(0) { -+} +============================ + +IT #4 +============================ ++string(5) "key10" ++array(0) { ++} +string(4) "key0" +array(0) { +} @@ -19910,13 +20979,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key9" +array(0) { +} -+string(5) "key10" -+array(0) { -+} +============================ + +IT #5 +============================ ++string(5) "key10" ++array(1) { ++ ["value"]=> ++ string(7) "value10" ++} +string(4) "key0" +array(1) { + ["value"]=> @@ -19967,15 +21038,13 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["value"]=> + string(6) "value9" +} -+string(5) "key10" -+array(1) { -+ ["value"]=> -+ string(7) "value10" -+} +============================ + +IT #6 +============================ ++string(5) "key10" ++array(0) { ++} +string(4) "key0" +array(0) { +} @@ -20006,13 +21075,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key9" +array(0) { +} -+string(5) "key10" -+array(0) { -+} +============================ + +IT #7 +============================ ++string(5) "key10" ++array(1) { ++ ["num_hits"]=> ++ int(0) ++} +string(4) "key0" +array(1) { + ["num_hits"]=> @@ -20063,15 +21134,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["num_hits"]=> + int(0) +} -+string(5) "key10" -+array(1) { -+ ["num_hits"]=> -+ int(0) -+} +============================ + +IT #8 +============================ ++string(5) "key10" ++array(1) { ++ ["mtime"]=> ++ int(%d) ++} +string(4) "key0" +array(1) { + ["mtime"]=> @@ -20122,15 +21193,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["mtime"]=> + int(%d) +} -+string(5) "key10" -+array(1) { -+ ["mtime"]=> -+ int(%d) -+} +============================ + +IT #9 +============================ ++string(5) "key10" ++array(1) { ++ ["creation_time"]=> ++ int(%d) ++} +string(4) "key0" +array(1) { + ["creation_time"]=> @@ -20181,15 +21252,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["creation_time"]=> + int(%d) +} -+string(5) "key10" -+array(1) { -+ ["creation_time"]=> -+ int(%d) -+} +============================ + +IT #10 +============================ ++string(5) "key10" ++array(1) { ++ ["deletion_time"]=> ++ int(0) ++} +string(4) "key0" +array(1) { + ["deletion_time"]=> @@ -20240,15 +21311,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["deletion_time"]=> + int(0) +} -+string(5) "key10" -+array(1) { -+ ["deletion_time"]=> -+ int(0) -+} +============================ + +IT #11 +============================ ++string(5) "key10" ++array(1) { ++ ["access_time"]=> ++ int(%d) ++} +string(4) "key0" +array(1) { + ["access_time"]=> @@ -20299,15 +21370,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["access_time"]=> + int(%d) +} -+string(5) "key10" -+array(1) { -+ ["access_time"]=> -+ int(%d) -+} +============================ + +IT #12 +============================ ++string(5) "key10" ++array(1) { ++ ["ref_count"]=> ++ int(0) ++} +string(4) "key0" +array(1) { + ["ref_count"]=> @@ -20358,15 +21429,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["ref_count"]=> + int(0) +} -+string(5) "key10" -+array(1) { -+ ["ref_count"]=> -+ int(0) -+} +============================ + +IT #13 +============================ ++string(5) "key10" ++array(1) { ++ ["mem_size"]=> ++ int(%d) ++} +string(4) "key0" +array(1) { + ["mem_size"]=> @@ -20390,7 +21461,7 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key4" +array(1) { + ["mem_size"]=> -+ int(580) ++ int(%d) +} +string(4) "key5" +array(1) { @@ -20417,15 +21488,15 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["mem_size"]=> + int(%d) +} -+string(5) "key10" -+array(1) { -+ ["mem_size"]=> -+ int(%d) -+} +============================ + +IT #14 +============================ ++string(5) "key10" ++array(1) { ++ ["ttl"]=> ++ int(0) ++} +string(4) "key0" +array(1) { + ["ttl"]=> @@ -20476,15 +21547,13 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["ttl"]=> + int(0) +} -+string(5) "key10" -+array(1) { -+ ["ttl"]=> -+ int(0) -+} +============================ + +IT #15 +============================ ++string(5) "key10" ++array(0) { ++} +string(4) "key0" +array(0) { +} @@ -20515,13 +21584,35 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test +string(4) "key9" +array(0) { +} -+string(5) "key10" -+array(0) { -+} +============================ + +IT #16 +============================ ++string(5) "key10" ++array(11) { ++ ["type"]=> ++ string(4) "user" ++ ["key"]=> ++ string(5) "key10" ++ ["value"]=> ++ string(7) "value10" ++ ["num_hits"]=> ++ int(0) ++ ["mtime"]=> ++ int(%d) ++ ["creation_time"]=> ++ int(%d) ++ ["deletion_time"]=> ++ int(0) ++ ["access_time"]=> ++ int(%d) ++ ["ref_count"]=> ++ int(0) ++ ["mem_size"]=> ++ int(%d) ++ ["ttl"]=> ++ int(0) ++} +string(4) "key0" +array(11) { + ["type"]=> @@ -20772,8 +21863,12 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["ttl"]=> + int(0) +} ++============================ ++ ++IT #17 ++============================ +string(5) "key10" -+array(11) { ++array(10) { + ["type"]=> + string(4) "user" + ["key"]=> @@ -20794,13 +21889,7 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + int(0) + ["mem_size"]=> + int(%d) -+ ["ttl"]=> -+ int(0) +} -+============================ -+ -+IT #17 -+============================ +string(4) "key0" +array(10) { + ["type"]=> @@ -21031,33 +22120,19 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["mem_size"]=> + int(%d) +} ++============================ ++ ++IT #18 ++============================ +string(5) "key10" -+array(10) { -+ ["type"]=> -+ string(4) "user" ++array(3) { + ["key"]=> + string(5) "key10" -+ ["value"]=> -+ string(7) "value10" + ["num_hits"]=> + int(0) -+ ["mtime"]=> -+ int(%d) -+ ["creation_time"]=> -+ int(%d) -+ ["deletion_time"]=> -+ int(0) -+ ["access_time"]=> -+ int(%d) -+ ["ref_count"]=> -+ int(0) + ["mem_size"]=> + int(%d) +} -+============================ -+ -+IT #18 -+============================ +string(4) "key0" +array(3) { + ["key"]=> @@ -21148,21 +22223,11 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_006.phpt php-5.3.1/ext/apc/test + ["mem_size"]=> + int(%d) +} -+string(5) "key10" -+array(3) { -+ ["key"]=> -+ string(5) "key10" -+ ["num_hits"]=> -+ int(0) -+ ["mem_size"]=> -+ int(%d) -+} +============================ + +===DONE=== -diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_007.phpt php-5.3.1/ext/apc/tests/iterator_007.phpt ---- php-5.3.1.orig/ext/apc/tests/iterator_007.phpt 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/iterator_007.phpt 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/iterator_007.phpt @@ -0,0 +1,36 @@ +--TEST-- +APC: APCIterator Overwriting the ctor @@ -21200,9 +22265,8 @@ diff -Naur php-5.3.1.orig/ext/apc/tests/iterator_007.phpt php-5.3.1/ext/apc/test +bool(false) +bool(false) + -diff -Naur php-5.3.1.orig/ext/apc/tests/php_5_3_ns.inc php-5.3.1/ext/apc/tests/php_5_3_ns.inc ---- php-5.3.1.orig/ext/apc/tests/php_5_3_ns.inc 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/tests/php_5_3_ns.inc 1970-01-01 10:13:08.000000000 +0100 +--- /dev/null ++++ b/ext/apc/tests/php_5_3_ns.inc @@ -0,0 +1,18 @@ + -diff -Naur php-5.3.1.orig/ext/apc/TODO php-5.3.1/ext/apc/TODO ---- php-5.3.1.orig/ext/apc/TODO 1970-01-01 01:00:00.000000000 +0100 -+++ php-5.3.1/ext/apc/TODO 1970-01-01 10:13:08.000000000 +0100 -@@ -0,0 +1,30 @@ +--- /dev/null ++++ b/ext/apc/TODO +@@ -0,0 +1,32 @@ +Known Bugs + +1. Gallery2 doesn't work with PHP5+APC. There is something wrong @@ -21257,12 +22319,15 @@ diff -Naur php-5.3.1.orig/ext/apc/TODO php-5.3.1/ext/apc/TODO + in the apc_store() function in php_apc.c but I am wondering if it needs to do more + than that. + -+Enhancements ++Windows + -+1. Some faster platform-specific locking mechanisms wouldd be nice. futex support -+ for the 2.6 Linux kernels, and/or x86-specific spinlock support. ++1. The following configurations (build arguments) have not been implemented yet + -+2. The optimizer needs a lot of work. ++ (*) --enable-apc-mmap Memory mapping support ++ (*) --enable-apc-sem Semaphore locking support (FCNTL replacement) ++ (*) --enable-apc-phreadmutex Thread mutexes, while implemented we should probably rename the internals to thread + -+3. Assert() elimination in the optimizer when some debug flag somewhere isn't set. ++2. Non-blocking locks is not supported either + ++3. Update fileinfo to support stat info in a more portable way (see PECL #17903) +\ No newline at end of file