From eec032be761ffcebdf67108985604db5af454daf Mon Sep 17 00:00:00 2001 From: Yu Qing Date: Mon, 30 Nov 2015 19:00:25 +0800 Subject: [PATCH] php extension compiled on PHP 7 --- HISTORY | 3 +++ php-fastcommon/fastcommon.c | 37 ++++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/HISTORY b/HISTORY index f2b5e23..8b5a0fb 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,7 @@ +Version 1.24 2015-11-30 + * php extension compiled on PHP 7 + Version 1.23 2015-11-16 * sched_thread.c: task can execute in a new thread * sched_thread.c: support delay tasks diff --git a/php-fastcommon/fastcommon.c b/php-fastcommon/fastcommon.c index c8dd301..e7a1841 100644 --- a/php-fastcommon/fastcommon.c +++ b/php-fastcommon/fastcommon.c @@ -28,6 +28,20 @@ #define MINOR_VERSION 0 #define PATCH_VERSION 3 +#if PHP_MAJOR_VERSION < 7 +typedef int zend_size_t; +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l, dup) +#define ZEND_RETURN_STRING(s, dup) RETURN_STRING(s, dup) +#define zend_add_index_string(z, index, value, dup) \ + add_index_string(z, index, value, dup) +#else +typedef size_t zend_size_t; +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l) +#define ZEND_RETURN_STRING(s, dup) RETURN_STRING(s) +#define zend_add_index_string(z, index, value, dup) \ + add_index_string(z, index, value) +#endif + #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3) const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 }; #undef ZEND_BEGIN_ARG_INFO_EX @@ -111,7 +125,7 @@ ZEND_FUNCTION(fastcommon_version) len = sprintf(szVersion, "%d.%d.%d", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION); - RETURN_STRINGL(szVersion, len, 1); + ZEND_RETURN_STRINGL(szVersion, len, 1); } /* @@ -122,7 +136,7 @@ ZEND_FUNCTION(fastcommon_gethostaddrs) { int argc; char *if_alias_prefix; - int if_prefix_len; + zend_size_t if_prefix_len; int count; int uniq_count; int i; @@ -140,7 +154,8 @@ ZEND_FUNCTION(fastcommon_gethostaddrs) RETURN_BOOL(false); } - if_alias_prefix = NULL; + if_alias_prefix = NULL; + if_prefix_len = 0; if (zend_parse_parameters(argc TSRMLS_CC, "|s", &if_alias_prefix, &if_prefix_len) == FAILURE) { @@ -182,7 +197,7 @@ ZEND_FUNCTION(fastcommon_gethostaddrs) array_init(return_value); for (k=0; k