1 # psi_add_redir(name, symbol)
2 # Add a function redirection to $PSI_REDIRS.
4 cat >>$PSI_REDIRS <<EOF
5 {"$1", (psi_func_ptr) $2},
9 # psi_add_decl(decl, options)
10 # Add a pre-defined decl to $PSI_VA_DECLS/$PSI_DECLS.
14 cat >>$PSI_FN_DECLS <<EOF
19 cat >>$PSI_VA_DECLS <<EOF
24 cat >>$PSI_DECLS <<EOF
31 dnl PSI_DECL_TYPE(type functor_name, args)
32 dnl Adds a pre-defined functor decl to $PSI_FN_DECLS.
33 AC_DEFUN(PSI_DECL_TYPE, [
35 psi_add_decl "$psi_decl_args" functor
37 dnl PSI_REDIR(name, custom symbol)
38 dnl Create a function redirection to an optional custom symbol.
40 psi_add_redir $1 ifelse([$2],[],[$1],[$2])
43 dnl PSI_FUNC_LIBC_MAIN()
44 dnl Check for the platforms default stub in executables.
45 AC_DEFUN(PSI_FUNC_LIBC_MAIN, [
46 AC_REQUIRE([AC_PROG_AWK])
47 AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [
49 AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [
50 psi_libc_main=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
52 psi_cv_libc_main=$psi_libc_main
56 dnl PSI_DECL_ARGS(decl args)
57 dnl INTERNAL: build psi_decl_args
58 AC_DEFUN(PSI_DECL_ARGS, [
65 [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
68 dnl PSI_DECL_ARG(decl arg)
69 dnl INTERNAL: build psi_decl_args
70 AC_DEFUN(PSI_DECL_ARG, [
71 m4_define([member_name], PSI_VAR_NAME($1))
72 m4_define([member_type], PSI_VAR_TYPE($1))
74 PSI_TYPE_INDIRECTION([$1],, pl, as)
75 if test -n "$psi_decl_args"; then
76 psi_decl_args="$psi_decl_args, "
78 psi_decl_args="[$psi_decl_args{]PSI_TYPE_PAIR(member_type)[, \"]member_name[\",] $pl, $as[}]"
81 dnl PSI_DECL(type func, args, flags, libs)
82 dnl Check for a function or macro declaration and a possible asm redirection.
83 dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS/$PSI_DECLS.
84 dnl Calls PSI_MACRO if PSI_FUNC fails.
86 AC_REQUIRE([PSI_FUNC_LIBC_MAIN])dnl
90 psi_symbol="PSI_VAR_NAME($1)"
91 AC_CACHE_CHECK(for PSI_VAR_NAME($1), [psi_cv_fn_]PSI_VAR_NAME($1), [
97 AC_TRY_LINK(PSI_INCLUDES, [
98 void (*fn)(void) = (void (*)(void)) $psi_symbol; (*fn)()
100 psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
104 if test -n "$psi_symbol_redirect"; then
105 if test -n "$lib"; then
106 psi_decl_check="$psi_symbol_redirect in $lib"
108 psi_decl_check="$psi_symbol_redirect"
113 [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_decl_check
116 psi_symbol_redirect=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]1}'`
117 psi_symbol_libflag=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]2}'`
119 if test -n "$psi_symbol_libflag"; then
120 if ! expr "X$LIBS" : "X.*\b$psi_symbol_libflag\b" >/dev/null; then
121 LIBS="$psi_symbol_libflag $LIBS"
125 case "$psi_symbol_redirect" in
126 "$psi_symbol"|"_$psi_symbol")
127 case "$PHP_DEBUG-$3" in
130 psi_add_decl "$psi_decl_args"
134 psi_add_decl "$psi_decl_args" $3
139 ifelse([$3], vararg, [
140 AC_MSG_WARN(varargs macro support is not implemented)
143 psi_add_decl "$psi_decl_args"
148 PSI_REDIR($psi_symbol)
149 psi_add_decl "$psi_decl_args" $3