From ce68bff524ce4b0d23fad5feffc207c2e5c6cf0f Mon Sep 17 00:00:00 2001 From: Sunpoet Po-Chuan Hsieh Date: Sun, 14 Oct 2018 16:28:27 +0000 Subject: [PATCH] Fix build with PHP 7.3 --- databases/php7-tarantool/Makefile | 2 +- .../files/patch-src-tarantool.c | 14 ++ .../files/patch-src-tarantool_msgpack.c | 122 ++++++++++++++++++ .../php7-tarantool/files/patch-src-utils.c | 13 ++ 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 databases/php7-tarantool/files/patch-src-tarantool.c create mode 100644 databases/php7-tarantool/files/patch-src-tarantool_msgpack.c create mode 100644 databases/php7-tarantool/files/patch-src-utils.c diff --git a/databases/php7-tarantool/Makefile b/databases/php7-tarantool/Makefile index fcbbe7679853..05e9bbdf5e49 100644 --- a/databases/php7-tarantool/Makefile +++ b/databases/php7-tarantool/Makefile @@ -15,7 +15,7 @@ LICENSE_FILE= ${WRKSRC}/LICENSE USES= php:ext CONFIGURE_ARGS= --with-tarantool -IGNORE_WITH_PHP=56 73 +IGNORE_WITH_PHP=56 USE_GITHUB= yes GH_PROJECT= ${PORTNAME}-php diff --git a/databases/php7-tarantool/files/patch-src-tarantool.c b/databases/php7-tarantool/files/patch-src-tarantool.c new file mode 100644 index 000000000000..057cbf33f81a --- /dev/null +++ b/databases/php7-tarantool/files/patch-src-tarantool.c @@ -0,0 +1,14 @@ +--- src/tarantool.c.orig 2018-04-18 13:33:56 UTC ++++ src/tarantool.c +@@ -1151,7 +1151,11 @@ PHP_METHOD(Tarantool, __construct) { + memset(&le, 0, sizeof(zend_resource)); + le.type = php_tarantool_list_entry(); + le.ptr = obj; ++#if PHP_VERSION_ID >= 70300 ++ GC_SET_REFCOUNT(&le, 1); ++#else + GC_REFCOUNT(&le) = 1; ++#endif + + assert(plist_id != NULL); + if (zend_hash_update_mem(&EG(persistent_list), plist_id, diff --git a/databases/php7-tarantool/files/patch-src-tarantool_msgpack.c b/databases/php7-tarantool/files/patch-src-tarantool_msgpack.c new file mode 100644 index 000000000000..94d47e993811 --- /dev/null +++ b/databases/php7-tarantool/files/patch-src-tarantool_msgpack.c @@ -0,0 +1,122 @@ +--- src/tarantool_msgpack.c.orig 2018-04-18 13:33:56 UTC ++++ src/tarantool_msgpack.c +@@ -123,15 +123,30 @@ void php_mp_pack_array_recursively(smart + for (; key_index < n; ++key_index) { + data = zend_hash_index_find(ht, key_index); + if (!data || data == val || (Z_TYPE_P(data) == IS_ARRAY && ++#if PHP_VERSION_ID >= 70300 ++ !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE) && ++ GC_IS_RECURSIVE(Z_ARRVAL_P(data)))) { ++#else + ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data)) && + Z_ARRVAL_P(data)->u.v.nApplyCount > 1)) { ++#endif + php_mp_pack_nil(str); + } else { ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_PROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount++; ++#endif + php_mp_pack(str, data); ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_UNPROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount--; ++#endif + } + } + } +@@ -166,15 +181,30 @@ void php_mp_pack_hash_recursively(smart_ + } + data = zend_hash_get_current_data_ex(ht, &pos); + if (!data || data == val || (Z_TYPE_P(data) == IS_ARRAY && ++#if PHP_VERSION_ID >= 70300 ++ !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE) && ++ GC_IS_RECURSIVE(Z_ARRVAL_P(data)))) { ++#else + ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data)) && + Z_ARRVAL_P(data)->u.v.nApplyCount > 1)) { ++#endif + php_mp_pack_nil(str); + } else { ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_PROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount++; ++#endif + php_mp_pack(str, data); ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_UNPROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount--; ++#endif + } + } + } +@@ -408,14 +438,28 @@ size_t php_mp_sizeof_array_recursively(z + for (; key_index < n; ++key_index) { + data = zend_hash_index_find(ht, key_index); + if (!data || data == val || ++#if PHP_VERSION_ID >= 70300 ++ (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE) && GC_IS_RECURSIVE(Z_ARRVAL_P(data)))) { ++#else + (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data)) && Z_ARRVAL_P(data)->u.v.nApplyCount > 1)) { ++#endif + needed += php_mp_sizeof_nil(); + } else { ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_PROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount++; ++#endif + needed += php_mp_sizeof(data); ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_UNPROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount--; ++#endif + } + } + return needed; +@@ -452,14 +496,28 @@ size_t php_mp_sizeof_hash_recursively(zv + } + data = zend_hash_get_current_data_ex(ht, &pos); + if (!data || data == val || ++#if PHP_VERSION_ID >= 70300 ++ (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE) && GC_IS_RECURSIVE(Z_ARRVAL_P(data)))) { ++#else + (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data)) && Z_ARRVAL_P(data)->u.v.nApplyCount > 1)) { ++#endif + needed += php_mp_sizeof_nil(); + } else { ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_PROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount++; ++#endif + needed += php_mp_sizeof(data); ++#if PHP_VERSION_ID >= 70300 ++ if (Z_TYPE_P(data) == IS_ARRAY && !(GC_FLAGS(Z_ARRVAL_P(data)) & GC_IMMUTABLE)) ++ GC_UNPROTECT_RECURSION(Z_ARRVAL_P(data)); ++#else + if (Z_TYPE_P(data) == IS_ARRAY && ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(data))) + Z_ARRVAL_P(data)->u.v.nApplyCount--; ++#endif + } + } + return needed; diff --git a/databases/php7-tarantool/files/patch-src-utils.c b/databases/php7-tarantool/files/patch-src-utils.c new file mode 100644 index 000000000000..ae69f4cb7191 --- /dev/null +++ b/databases/php7-tarantool/files/patch-src-utils.c @@ -0,0 +1,13 @@ +--- src/utils.c.orig 2018-04-18 13:33:56 UTC ++++ src/utils.c +@@ -29,8 +29,10 @@ const char *tutils_op_to_string(zval *ob + return "RESOURCE"; + case(IS_REFERENCE): + return "REFERENCE"; ++#if PHP_VERSION_ID < 70300 + case(IS_CONSTANT): + return "CONSTANT"; ++#endif + case(IS_CONSTANT_AST): + return "CONSTANT_AST"; + case(IS_CALLABLE):