[php-pecl-apcu] restore APC serializers ABI (patch merged upstream)

Remi Collet remi at fedoraproject.org
Sat Jul 27 13:23:11 UTC 2013


commit 56aa9135ec0e1dbbdf7c6718f3e2fb0608422297
Author: Remi Collet <remi at fedoraproject.org>
Date:   Sat Jul 27 15:22:58 2013 +0200

    restore APC serializers ABI (patch merged upstream)

 .gitignore         |    1 +
 apcu-git.patch     |  289 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 php-pecl-apcu.spec |   17 +++-
 3 files changed, 303 insertions(+), 4 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 1ce46d1..e3c73f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
+*spec~
 /apcu-4.0.1.tgz
diff --git a/apcu-git.patch b/apcu-git.patch
new file mode 100644
index 0000000..b595a48
--- /dev/null
+++ b/apcu-git.patch
@@ -0,0 +1,289 @@
+From 286f70d4a921c0cd21f59f8db8efd2fa45e8d559 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora at famillecollet.com>
+Date: Mon, 8 Jul 2013 14:23:05 +0200
+Subject: [PATCH 1/4] restore APC hook for register serializer, fix #24
+
+---
+ apc.c            |  4 +--
+ apc.h            | 19 +++----------
+ apc_serializer.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ config.m4        |  2 +-
+ config.w32       |  2 +-
+ php_apc.c        |  7 ++++-
+ 6 files changed, 98 insertions(+), 20 deletions(-)
+ create mode 100644 apc_serializer.h
+
+diff --git a/apc.c b/apc.c
+index 86ed21f..7457b53 100644
+--- a/apc.c
++++ b/apc.c
+@@ -370,8 +370,8 @@ HashTable* apc_flip_hash(HashTable *hash) {
+ /* }}} */
+ 
+ /* {{{ apc_register_serializer */
+-PHP_APCU_API zend_bool apc_register_serializer(const char* name, 
+-                                  apc_serialize_t serialize, 
++PHP_APCU_API int _apc_register_serializer(const char* name,
++                                  apc_serialize_t serialize,
+                                   apc_unserialize_t unserialize,
+                                   void *config TSRMLS_DC) {
+     int i;
+diff --git a/apc.h b/apc.h
+index cd1cb59..256ab01 100644
+--- a/apc.h
++++ b/apc.h
+@@ -127,19 +127,8 @@
+ 
+ /*
+ * Serializer API
+-* Note: This used to live in apc_serializer.h
+ */
+-#define APC_SERIALIZER_NAME(module) module##_apc_serializer
+-#define APC_SERIALIZER_EXTERN(module) extern apc_serialize_t module##_apc_serializer
+-#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer
+-#define APC_UNSERIALIZER_EXTERN(module) extern apc_unserialize_t module##_apc_unserializer
+-
+-#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC
+-#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC
+-
+-/* {{{ */
+-typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS);
+-typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS); /* }}} */
++#include "apc_serializer.h"
+ 
+ /* {{{ struct definition: apc_serializer_t */
+ typedef struct apc_serializer_t {
+@@ -150,10 +139,10 @@
+ } apc_serializer_t;
+ /* }}} */
+ 
+-/* {{{ apc_register_serializer 
++/* {{{ _apc_register_serializer
+  registers the serializer using the given name and paramters */
+-PHP_APCU_API zend_bool apc_register_serializer(const char* name, 
+-                                               apc_serialize_t serialize, 
++PHP_APCU_API int _apc_register_serializer(const char* name,
++                                               apc_serialize_t serialize,
+                                                apc_unserialize_t unserialize,
+                                                void *config TSRMLS_DC); /* }}} */
+ 
+diff --git a/apc_serializer.h b/apc_serializer.h
+new file mode 100644
+index 0000000..0bdaa08
+--- /dev/null
++++ b/apc_serializer.h
+@@ -0,0 +1,84 @@
++/*
++  +----------------------------------------------------------------------+
++  | APC                                                                  |
++  +----------------------------------------------------------------------+
++  | Copyright (c) 2006-2011 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 at php.net so we can mail you a copy immediately.               |
++  +----------------------------------------------------------------------+
++  | Authors: Gopal Vijayaraghavan <gopalv at php.net>                       |
++  +----------------------------------------------------------------------+
++
++ */
++
++/* $Id: $ */
++
++#ifndef APC_SERIALIZER_H
++#define APC_SERIALIZER_H
++
++/* this is a shipped .h file, do not include any other header in this file */
++#define APC_SERIALIZER_NAME(module) module##_apc_serializer
++#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer
++
++#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC
++#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC
++
++typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS);
++typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS);
++
++typedef int (*apc_register_serializer_t)(const char* name,
++                                        apc_serialize_t serialize,
++                                        apc_unserialize_t unserialize,
++                                        void *config TSRMLS_DC);
++
++/*
++ * ABI version for constant hooks. Increment this any time you make any changes
++ * to any function in this file.
++ */
++#define APC_SERIALIZER_ABI "0"
++#define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI
++
++#if !defined(APC_UNUSED)
++# if defined(__GNUC__)
++#  define APC_UNUSED __attribute__((unused))
++# else
++# define APC_UNUSED
++# endif
++#endif
++
++static APC_UNUSED int apc_register_serializer(const char* name,
++                                    apc_serialize_t serialize,
++                                    apc_unserialize_t unserialize,
++                                    void *config TSRMLS_DC)
++{
++    zval apc_magic_constant;
++    int retval = 0;
++
++    /* zend_get_constant will return 1 on success, otherwise apc_magic_constant wouldn't be touched at all */
++    if (zend_get_constant(APC_SERIALIZER_CONSTANT, sizeof(APC_SERIALIZER_CONSTANT)-1, &apc_magic_constant TSRMLS_CC)) {
++        apc_register_serializer_t register_func = (apc_register_serializer_t)(Z_LVAL(apc_magic_constant));
++        if(register_func) {
++            retval = register_func(name, serialize, unserialize, NULL TSRMLS_CC);
++        }
++        zval_dtor(&apc_magic_constant);
++    }
++
++    return retval;
++}
++
++#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
++ */
+diff --git a/config.m4 b/config.m4
+index 8b73ba3..d4fb2fd 100644
+--- a/config.m4
++++ b/config.m4
+@@ -129,7 +129,7 @@ if test "$PHP_APCU" != "no"; then
+   PHP_NEW_EXTENSION(apcu, $apc_sources, $ext_shared,, \\$(APCU_CFLAGS))
+   PHP_SUBST(APCU_SHARED_LIBADD)
+   PHP_SUBST(APCU_CFLAGS)
+-  PHP_INSTALL_HEADERS(ext/apcu, [apc.h apc_api.h apc_cache_api.h apc_lock_api.h apc_pool_api.h apc_sma_api.h apc_bin_api.h])
++  PHP_INSTALL_HEADERS(ext/apcu, [apc.h apc_api.h apc_cache_api.h apc_lock_api.h apc_pool_api.h apc_sma_api.h apc_bin_api.h apc_serializer.h])
+   AC_DEFINE(HAVE_APCU, 1, [ ])
+ fi
+ 
+diff --git a/php_apc.c b/php_apc.c
+index afa69cd..ec1b57b 100644
+--- a/php_apc.c
++++ b/php_apc.c
+@@ -281,6 +281,8 @@ static PHP_MINIT_FUNCTION(apcu)
+ 			apc_sma.init(APCG(shm_segments), APCG(shm_size), NULL TSRMLS_CC);
+ #endif
+ 
++			REGISTER_LONG_CONSTANT(APC_SERIALIZER_CONSTANT, (long)&_apc_register_serializer, CONST_PERSISTENT | CONST_CS);
++
+ 			/* register default serializer */
+ 			apc_register_serializer(
+ 				"php", APC_SERIALIZER_NAME(php), APC_UNSERIALIZER_NAME(php), NULL TSRMLS_CC);
+@@ -288,7 +290,10 @@ static PHP_MINIT_FUNCTION(apcu)
+ 			/* register eval serializer */
+ 			apc_register_serializer(
+ 				"eval", APC_SERIALIZER_NAME(eval), APC_UNSERIALIZER_NAME(eval), NULL TSRMLS_CC);
+-			
++
++			/* test out the constant function pointer */
++			assert(apc_serializers[0].name != NULL);
++
+ 			/* create user cache */
+ 			apc_user_cache = apc_cache_create(
+ 				&apc_sma,
+-- 
+1.8.1.6
+
+
+From 07afc5b8cf67c71903f71f1dd6c768112e5798eb Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora at famillecollet.com>
+Date: Mon, 8 Jul 2013 14:25:48 +0200
+Subject: [PATCH 2/4] php_apc.c:1124:16: warning: variable 'h_files' set but
+ not used [-Wunused-but-set-variable]
+
+---
+ php_apc.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/php_apc.c b/php_apc.c
+index ec1b57b..10a5df3 100644
+--- a/php_apc.c
++++ b/php_apc.c
+@@ -1121,7 +1121,7 @@ void *apc_erealloc_wrapper(void *ptr, size_t size) {
+ PHP_FUNCTION(apc_bin_dumpfile) {
+ 
+     zval *z_files = NULL, *z_user_vars = NULL;
+-    HashTable *h_files, *h_user_vars;
++    HashTable *h_user_vars;
+     char *filename = NULL;
+     int filename_len;
+     long flags=0;
+@@ -1146,7 +1146,6 @@ void *apc_erealloc_wrapper(void *ptr, size_t size) {
+         RETURN_FALSE;
+     }
+ 
+-    h_files = z_files ? Z_ARRVAL_P(z_files) : NULL;
+     h_user_vars = z_user_vars ? Z_ARRVAL_P(z_user_vars) : NULL;
+     bd = apc_bin_dump(apc_user_cache, h_user_vars TSRMLS_CC);
+     if(!bd) {
+-- 
+1.8.1.6
+
+
+From 0c1d7d3af957f4d06c1265bd1b2752007c56ef53 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora at famillecollet.com>
+Date: Mon, 8 Jul 2013 14:29:43 +0200
+Subject: [PATCH 3/4] apc_cache.c:300:5: warning: pointer targets in passing
+ argument 1 of 'php_stream_open_for_zend_ex' differ in signedness
+ [-Wpointer-sign]
+
+---
+ apc_cache.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/apc_cache.c b/apc_cache.c
+index c7a1b7b..23c761b 100644
+--- a/apc_cache.c
++++ b/apc_cache.c
+@@ -297,7 +297,7 @@ PHP_APCU_API int APC_UNSERIALIZER_NAME(eval) (APC_UNSERIALIZER_ARGS)
+ {
+     zend_file_handle zhandle;
+     
+-    if (php_stream_open_for_zend_ex(buf, &zhandle, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) {
++    if (php_stream_open_for_zend_ex((const char *)buf, &zhandle, USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC) == SUCCESS) {
+        zend_op_array *op_array = zend_compile_file(&zhandle, ZEND_INCLUDE TSRMLS_CC);
+        zend_op_array *active_op_array = EG(active_op_array);
+        zval **return_value_ptr_ptr = EG(return_value_ptr_ptr);
+-- 
+1.8.1.6
+
+
+From 38ef422d01422e7ce1059a60e87e5f10a6da7294 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora at famillecollet.com>
+Date: Sat, 27 Jul 2013 08:10:26 +0200
+Subject: [PATCH 4/4] fix apc_serializers undefined
+
+---
+ php_apc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/php_apc.c b/php_apc.c
+index 10a5df3..dccdd37 100644
+--- a/php_apc.c
++++ b/php_apc.c
+@@ -292,7 +292,7 @@ static PHP_MINIT_FUNCTION(apcu)
+ 				"eval", APC_SERIALIZER_NAME(eval), APC_UNSERIALIZER_NAME(eval), NULL TSRMLS_CC);
+ 
+ 			/* test out the constant function pointer */
+-			assert(apc_serializers[0].name != NULL);
++			assert(apc_get_serializers()->name != NULL);
+ 
+ 			/* create user cache */
+ 			apc_user_cache = apc_cache_create(
+-- 
+1.8.1.6
+
diff --git a/php-pecl-apcu.spec b/php-pecl-apcu.spec
index 1dc6c1b..68c883e 100644
--- a/php-pecl-apcu.spec
+++ b/php-pecl-apcu.spec
@@ -22,12 +22,16 @@
 Name:           %{?scl_prefix}php-pecl-apcu
 Summary:        APC User Cache
 Version:        4.0.1
-Release:        2%{?dist}
+Release:        3%{?dist}
 Source0:        http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
 Source1:        %{pecl_name}.ini
 Source2:        %{pecl_name}-panel.conf
 Source3:        %{pecl_name}.conf.php
 
+# Restore APC serializers ABI (merged upstream)
+# https://github.com/krakjoe/apcu/pull/25
+Patch0:         %{pecl_name}-git.patch
+
 License:        PHP
 Group:          Development/Languages
 URL:            http://pecl.php.net/package/APCu
@@ -47,7 +51,7 @@ Provides:       %{?scl_prefix}php-apcu%{?_isa} = %{version}
 Provides:       %{?scl_prefix}php-pecl(apcu) = %{version}
 Provides:       %{?scl_prefix}php-pecl(apcu)%{?_isa} = %{version}
 %if 0%{?fedora} < 20
-Conflicts:      %{?scl_prefix}php-pecl-apc
+Conflicts:      %{?scl_prefix}php-pecl-apc < 4
 %else
 Obsoletes:      %{?scl_prefix}php-pecl-apc < 4
 %endif
@@ -91,7 +95,7 @@ Group:         Development/Libraries
 Requires:      %{name}%{?_isa} = %{version}-%{release}
 Requires:      %{?scl_prefix}php-devel%{?_isa}
 %if 0%{?fedora} < 20
-Conflicts:      %{?scl_prefix}php-pecl-apc-devel
+Conflicts:      %{?scl_prefix}php-pecl-apc-devel < 4
 %else
 Obsoletes:      %{?scl_prefix}php-pecl-apc-devel < 4
 Provides:       %{?scl_prefix}php-pecl-apc-devel = %{version}-%{release}
@@ -109,7 +113,7 @@ BuildArch:     noarch
 Requires:      %{name} = %{version}-%{release}
 Requires:      %{?scl_prefix}mod_php, httpd, %{?scl_prefix}php-gd
 %if 0%{?fedora} < 20
-Conflicts:      %{?scl_prefix}apc-panel
+Conflicts:      %{?scl_prefix}apc-panel < 4
 %else
 Obsoletes:      %{?scl_prefix}apc-panel < 4
 Provides:       %{?scl_prefix}apc-devel = %{version}-%{release}
@@ -125,6 +129,8 @@ configuration, available on http://localhost/apcu-panel/
 mv %{pecl_name}-%{version} NTS
 
 cd NTS
+%patch0 -p1 -b .serializers
+rm -f apc_serializer.h.serializers
 
 # Sanity check, really often broken
 extver=$(sed -n '/#define PHP_APC_VERSION/{s/.* "//;s/".*$//;p}' php_apc.h)
@@ -253,6 +259,9 @@ fi
 
 
 %changelog
+* Sat Jul 27 2013 Remi Collet <remi at fedoraproject.org> - 4.0.1-3
+- restore APC serializers ABI (patch merged upstream)
+
 * Mon Jul 15 2013 Remi Collet <rcollet at redhat.com> - 4.0.1-2
 - adapt for SCL
 


More information about the scm-commits mailing list