summaryrefslogtreecommitdiffstats
path: root/apcu-upstream.patch
diff options
context:
space:
mode:
Diffstat (limited to 'apcu-upstream.patch')
-rw-r--r--apcu-upstream.patch227
1 files changed, 0 insertions, 227 deletions
diff --git a/apcu-upstream.patch b/apcu-upstream.patch
deleted file mode 100644
index b21aeb6..0000000
--- a/apcu-upstream.patch
+++ /dev/null
@@ -1,227 +0,0 @@
-diff --git a/apc_globals.h b/apc_globals.h
-index 40509f0..a0de234 100644
---- a/apc_globals.h
-+++ b/apc_globals.h
-@@ -41,12 +41,12 @@
- ZEND_BEGIN_MODULE_GLOBALS(apcu)
- /* configuration parameters */
- zend_bool enabled; /* if true, apc is enabled (defaults to true) */
-- long shm_segments; /* number of shared memory segments to use */
-- long shm_size; /* size of each shared memory segment (in MB) */
-- long entries_hint; /* hint at the number of entries expected */
-- long gc_ttl; /* parameter to apc_cache_create */
-- long ttl; /* parameter to apc_cache_create */
-- long smart; /* smart value */
-+ zend_long shm_segments; /* number of shared memory segments to use */
-+ zend_long shm_size; /* size of each shared memory segment (in MB) */
-+ zend_long entries_hint; /* hint at the number of entries expected */
-+ zend_long gc_ttl; /* parameter to apc_cache_create */
-+ zend_long ttl; /* parameter to apc_cache_create */
-+ zend_long smart; /* smart value */
-
- #if APC_MMAP
- char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */
-diff --git a/php_apc.c b/php_apc.c
-index c35ede1..83fd758 100644
---- a/php_apc.c
-+++ b/php_apc.c
-@@ -118,11 +118,11 @@ static PHP_INI_MH(OnUpdateShmSize) /* {{{ */
- return FAILURE;
- }
-
-- if (s < 1048576L) {
-+ if (s < Z_L(1048576)) {
- /* if it's less than 1Mb, they are probably using the old syntax */
- php_error_docref(
- NULL, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files");
-- s = s * 1048576L;
-+ s = s * Z_L(1048576);
- }
-
- APCG(shm_size) = s;
-@@ -526,60 +526,46 @@ PHP_FUNCTION(apcu_add) {
- /* {{{ php_inc_updater */
-
- struct php_inc_updater_args {
-- zend_long step;
-- zend_long lval;
-+ zval step;
-+ zval rval;
- };
-
- static zend_bool php_inc_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) {
- struct php_inc_updater_args *args = (struct php_inc_updater_args*) data;
-
- if (Z_TYPE(entry->val) == IS_LONG) {
-- while (args->step--) {
-- fast_long_increment_function(&entry->val);
-- }
-- args->lval = Z_LVAL(entry->val);
-+ fast_long_add_function(&entry->val, &entry->val, &args->step);
-+ ZVAL_COPY_VALUE(&args->rval, &entry->val);
- return 1;
- }
-
- return 0;
- }
-
--static zend_bool php_dec_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) {
-- struct php_inc_updater_args *args = (struct php_inc_updater_args*) data;
--
-- if (Z_TYPE(entry->val) == IS_LONG) {
-- while (args->step--) {
-- fast_long_decrement_function(&entry->val);
-- }
-- args->lval = Z_LVAL(entry->val);
-- return 1;
-- }
--
-- return 0;
--}
--/* }}} */
--
- /* {{{ proto long apc_inc(string key [, long step [, bool& success]])
- */
- PHP_FUNCTION(apcu_inc) {
- zend_string *key;
-- struct php_inc_updater_args args = {1L, -1};
-+ struct php_inc_updater_args args;
-+ zend_long step = 1;
- zval *success = NULL;
-
-- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) {
-+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) {
- return;
- }
--
-+
- if (success) {
- ZVAL_DEREF(success);
- zval_ptr_dtor(success);
- }
-
-+ ZVAL_LONG(&args.step, step);
-+
- if (php_apc_update(key, php_inc_updater, &args)) {
- if (success) {
- ZVAL_TRUE(success);
- }
-- RETURN_LONG(args.lval);
-+ RETURN_ZVAL(&args.rval, 0, 0);
- }
-
- if (success) {
-@@ -594,24 +580,27 @@ PHP_FUNCTION(apcu_inc) {
- */
- PHP_FUNCTION(apcu_dec) {
- zend_string *key;
-- struct php_inc_updater_args args = {1L, -1};
-+ struct php_inc_updater_args args;
-+ zend_long step = 1;
- zval *success = NULL;
-
-- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) {
-+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) {
- return;
- }
--
-+
- if (success) {
- ZVAL_DEREF(success);
- zval_ptr_dtor(success);
- }
-
-- if (php_apc_update(key, php_dec_updater, &args)) {
-+ ZVAL_LONG(&args.step, 0 - step);
-+
-+ if (php_apc_update(key, php_inc_updater, &args)) {
- if (success) {
- ZVAL_TRUE(success);
- }
-
-- RETURN_LONG(args.lval);
-+ RETURN_ZVAL(&args.rval, 0, 0);
- }
-
- if (success) {
-@@ -662,9 +651,7 @@ PHP_FUNCTION(apcu_cas) {
- PHP_FUNCTION(apcu_fetch) {
- zval *key;
- zval *success = NULL;
-- apc_cache_entry_t* entry;
- time_t t;
-- apc_context_t ctxt = {0,};
-
- if (!APCG(enabled)) {
- RETURN_FALSE;
-diff --git a/tests/apc_012.phpt b/tests/apc_012.phpt
-index e7844ef..0d3b050 100644
---- a/tests/apc_012.phpt
-+++ b/tests/apc_012.phpt
-@@ -10,25 +10,28 @@ apc.enable_cli=1
- $key="testkey";
- $i=PHP_INT_MAX;
- apcu_store($key, $i);
--$j=apcu_fetch($key);
-+var_dump($j=apcu_fetch($key));
- var_dump($i==$j);
-
- apcu_inc($key, 1);
- $i++;
--$j=apcu_fetch($key);
-+var_dump($j=apcu_fetch($key));
- var_dump($i==$j);
-
- $i=PHP_INT_MIN;
- apcu_store($key, $i);
- apcu_dec($key, 1);
- $i--;
--$j=apcu_fetch($key);
-+var_dump($j=apcu_fetch($key));
- var_dump($i==$j);
- ?>
- ===DONE===
- <?php exit(0); ?>
----EXPECT--
-+--EXPECTF--
-+int(%d)
- bool(true)
-+float(%s)
- bool(true)
-+float(%s)
- bool(true)
- ===DONE===
-diff --git a/tests/apc_inc_perf.phpt b/tests/apc_inc_perf.phpt
-new file mode 100644
-index 0000000..8f082f1
---- /dev/null
-+++ b/tests/apc_inc_perf.phpt
-@@ -0,0 +1,28 @@
-+--TEST--
-+APC: apcu_inc/apcu_dec performance test (gh#164)
-+--SKIPIF--
-+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
-+--INI--
-+apc.enabled=1
-+apc.enable_cli=1
-+apc.file_update_protection=0
-+--FILE--
-+<?php
-+apcu_store('foobar', 1);
-+$t = microtime(true);
-+var_dump(apcu_inc('foobar', 0x76543210));
-+var_dump(apcu_dec('foobar', 0x76543210));
-+var_dump(apcu_dec('foobar', -999999999));
-+var_dump(apcu_inc('foobar', -999999999));
-+$t = microtime(true) - $t;
-+var_dump($t < 0.1 ? true : $t);
-+?>
-+===DONE===
-+<?php exit(0); ?>
-+--EXPECTF--
-+int(1985229329)
-+int(1)
-+int(1000000000)
-+int(1)
-+bool(true)
-+===DONE===