diff --git a/php-fastcommon/fastcommon.c b/php-fastcommon/fastcommon.c index e7a1841..b95c8af 100644 --- a/php-fastcommon/fastcommon.c +++ b/php-fastcommon/fastcommon.c @@ -1,14 +1,4 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include -#include +#include "php7_ext_wrapper.h" #include "ext/standard/info.h" #include #include @@ -28,20 +18,6 @@ #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 diff --git a/src/php7_ext_wrapper.h b/src/php7_ext_wrapper.h index 34206eb..5eaeaa8 100644 --- a/src/php7_ext_wrapper.h +++ b/src/php7_ext_wrapper.h @@ -20,8 +20,9 @@ #if PHP_MAJOR_VERSION < 7 typedef int zend_size_t; -#define ZEND_RETURN_STRINGL_DUP(s, l) RETURN_STRINGL(s, l, 1) -#define ZEND_RETURN_STRINGL_EX(s, l, callback) \ +#define ZEND_RETURN_STRING(s, dup) RETURN_STRING(s, dup) +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l, dup) +#define ZEND_RETURN_STRINGL_CALLBACK(s, l, callback) \ do { \ RETVAL_STRINGL(s, l, 1); \ callback(s); /* generally for free the pointer */ \ @@ -50,6 +51,9 @@ typedef int zend_size_t; #define zend_add_assoc_bool_ex(z, key, key_len, b) \ add_assoc_bool_ex(z, key, key_len, b) +#define zend_add_index_string(z, index, value, dup) \ + add_index_string(z, index, value, dup) + static inline int zend_hash_find_wrapper(HashTable *ht, char *key, int key_len, zval **value) { @@ -77,8 +81,9 @@ static inline int zend_get_configuration_directive_wrapper(char *name, int len, #else typedef size_t zend_size_t; -#define ZEND_RETURN_STRINGL_DUP(s, l) RETURN_STRINGL(s, l) -#define ZEND_RETURN_STRINGL_EX(s, l, callback) \ +#define ZEND_RETURN_STRING(s, dup) RETURN_STRING(s) +#define ZEND_RETURN_STRINGL(s, l, dup) RETURN_STRINGL(s, l) +#define ZEND_RETURN_STRINGL_CALLBACK(s, l, callback) \ do { \ RETVAL_STRINGL(s, l); \ callback(s); \ @@ -108,6 +113,9 @@ typedef size_t zend_size_t; #define zend_add_assoc_bool_ex(z, key, key_len, b) \ add_assoc_bool_ex(z, key, key_len - 1, b) +#define zend_add_index_string(z, index, value, dup) \ + add_index_string(z, index, value) + static inline int zend_hash_find_wrapper(HashTable *ht, char *key, int key_len, zval **value) {