From: Michael Wallner Date: Mon, 20 Feb 2017 18:27:28 +0000 (+0100) Subject: build: PHP<7.2 compatibility X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=commitdiff_plain;h=6d8fda8d1cd382e6d6626df5353d285176bd9bf2 build: PHP<7.2 compatibility --- diff --git a/config.m4 b/config.m4 index 828c937..76c1066 100644 --- a/config.m4 +++ b/config.m4 @@ -90,7 +90,6 @@ if test "$PHP_PSI" != no; then PSI_CHECK_LIBJIT PSI_CHECK_LIBFFI - AC_PATH_PROG(NM, nm) AC_FUNC_FNMATCH AC_FUNC_MMAP diff --git a/m4/ax/ax_check_sign.m4 b/m4/ax/ax_check_sign.m4 index 5c925c2..e0292bc 100644 --- a/m4/ax/ax_check_sign.m4 +++ b/m4/ax/ax_check_sign.m4 @@ -40,7 +40,7 @@ AC_DEFUN([AX_CHECK_SIGN], [ typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"` AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [ - AC_TRY_COMPILE([$4], + AC_TRY_COMPILE($4, [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ], [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ], [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])]) diff --git a/m4/psi/psi.m4 b/m4/psi/psi.m4 index 9bb1a4b..d9dd4c4 100644 --- a/m4/psi/psi.m4 +++ b/m4/psi/psi.m4 @@ -7,6 +7,16 @@ AC_DEFUN(PSI_CONFIG_INIT, [ psi_save_LIBS=$LIBS LIBS= + AC_PROG_AWK + AC_PATH_PROG(NM, nm) + AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [ + psi_libc_main= + AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [ + psi_libc_main=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'` + ]) + psi_cv_libc_main=$psi_libc_main + ]) + if test "$PHP_PSI_MAINTAINER_MODE" = "yes"; then PSI_FAST_CONFIG=true PSI_DEPS=true @@ -15,7 +25,6 @@ AC_DEFUN(PSI_CONFIG_INIT, [ PHP_SUBST(PSI_DEPS) PSI_CONFIG_TMP=$(mktemp -d) - PSI_FUNC_LIBC_MAIN else PSI_FAST_CONFIG=false PSI_DEPS=false diff --git a/m4/psi/psi_decl.m4 b/m4/psi/psi_decl.m4 index 1ac4983..d699dd8 100644 --- a/m4/psi/psi_decl.m4 +++ b/m4/psi/psi_decl.m4 @@ -24,19 +24,6 @@ AC_DEFUN(PSI_REDIR, [ psi_add_redir $1 ifelse([$2],[],[$1],[$2]) ]) -dnl PSI_FUNC_LIBC_MAIN() -dnl Check for the platforms default stub in executables. -AC_DEFUN(PSI_FUNC_LIBC_MAIN, [ - AC_REQUIRE([AC_PROG_AWK]) - AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [ - psi_libc_main= - AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [ - psi_libc_main=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'` - ]) - psi_cv_libc_main=$psi_libc_main - ]) -]) - dnl PSI_DECL_ARGS(decl func, decl args, options) dnl INTERNAL: build psi_decl_args AC_DEFUN(PSI_DECL_ARGS, [ @@ -69,8 +56,6 @@ dnl Check for a function or macro declaration and a possible asm redirection. dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS_H/$PSI_DECLS_H. dnl Calls PSI_MACRO if PSI_FUNC fails. AC_DEFUN(PSI_DECL, [ - AC_REQUIRE([PSI_FUNC_LIBC_MAIN])dnl - PSI_DECL_ARGS($1, $2, $3) psi_symbol="PSI_VAR_NAME($1)" diff --git a/m4/psi/psi_type.m4 b/m4/psi/psi_type.m4 index 27aeeac..28aa580 100644 --- a/m4/psi/psi_type.m4 +++ b/m4/psi/psi_type.m4 @@ -52,7 +52,7 @@ AC_DEFUN(PSI_TYPE, [ psi_basic_type=AS_TR_SH($2) case $psi_basic_type in int) - AX_CHECK_SIGN($1, :, [psi_basic_type=uint], PSI_INCLUDES) + AX_CHECK_SIGN($1, :, [psi_basic_type=uint], [PSI_INCLUDES]) ;; sint) psi_basic_type=int @@ -74,7 +74,7 @@ AC_DEFUN(PSI_STDTYPE, [ [double],[psi_add_stdtype "{PSI_T_DOUBLE, \"double\", NULL}"], [long double],[psi_add_stdtype "{PSI_T_LONG_DOUBLE, \"long double\", NULL}"], [ - AX_CHECK_SIGN($1, psi_basic_type=int, psi_basic_type=uint, PSI_INCLUDES) + AX_CHECK_SIGN($1, psi_basic_type=int, psi_basic_type=uint, [PSI_INCLUDES]) AS_TR_SH(psi_basic_type_$1)=$psi_basic_type psi_add_stdtype "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}" ]) @@ -113,7 +113,7 @@ AC_DEFUN(PSI_OPAQUE_TYPE, [ ]) case "$AS_TR_SH([psi_cv_type_class_]$1)" in scalar) - AX_CHECK_SIGN($1, [psi_basic_type=int], [psi_basic_type=uint], PSI_INCLUDES) + AX_CHECK_SIGN($1, [psi_basic_type=int], [psi_basic_type=uint], [PSI_INCLUDES]) psi_add_type "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}" ;; struct) @@ -232,7 +232,7 @@ AC_DEFUN(PSI_CHECK_STD_TYPES, [ AC_CHECK_ALIGNOF(long double) PSI_STDTYPE(bool) - AC_CHECK_ALIGNOF(bool, PSI_INCLUDES) + AC_CHECK_ALIGNOF(bool, [PSI_INCLUDES]) PSI_STDTYPE(char, int) AC_CHECK_ALIGNOF(char) diff --git a/src/marshal.c b/src/marshal.c index c771e79..63a7dc9 100644 --- a/src/marshal.c +++ b/src/marshal.c @@ -99,7 +99,12 @@ zend_internal_arg_info *psi_internal_arginfo(struct psi_impl *impl) aip = calloc(argc + 1 + !!impl->func->vararg, sizeof(*aip)); fi = (zend_internal_function_info *) &aip[0]; +#ifdef ZEND_TYPE_ENCODE fi->type = ZEND_TYPE_ENCODE(psi_internal_type(impl->func->return_type), 1); +#else + fi->allow_null = 1; + fi->type_hint = psi_internal_type(impl->func->return_type); +#endif fi->required_num_args = psi_impl_num_min_args(impl); fi->return_reference = impl->func->return_reference; @@ -108,7 +113,12 @@ zend_internal_arg_info *psi_internal_arginfo(struct psi_impl *impl) zend_internal_arg_info *ai = &aip[argc]; ai->name = vararg->var->name; +#ifdef ZEND_TYPE_ENCODE ai->type = ZEND_TYPE_ENCODE(psi_internal_type(vararg->type), 1); +#else + ai->allow_null = 1; + ai->type_hint = psi_internal_type(vararg->type); +#endif if (vararg->var->reference) { ai->pass_by_reference = 1; } @@ -119,7 +129,12 @@ zend_internal_arg_info *psi_internal_arginfo(struct psi_impl *impl) zend_internal_arg_info *ai = &aip[i]; ai->name = iarg->var->name; +#ifdef ZEND_TYPE_ENCODE ai->type = ZEND_TYPE_ENCODE(psi_internal_type(iarg->type), 1); +#else + ai->allow_null = 1; + ai->type_hint = psi_internal_type(iarg->type); +#endif if (iarg->var->reference) { ai->pass_by_reference = 1; }