1 AC_DEFUN(PSI_REDIR, [psi_symbol=ifelse([$2],[],[$1],[$2])
2 PSI_REDIRS="{\"$1\", (void(*)(void))$psi_symbol}, $PSI_REDIRS"])
4 AC_DEFUN(PSI_FUNC_LIBC_MAIN, [
5 AC_REQUIRE([AC_PROG_NM])
6 AC_REQUIRE([AC_PROG_AWK])
7 AC_CACHE_CHECK(for libc start main symbol, psi_cv_libc_main, [
9 AC_TRY_LINK(PSI_INCLUDES, [(void)0;], [
10 psi_libc_main=`$NM -g conftest$ac_exeext | $AWK -F" *|@" '/^\s+U / {print$[]3; exit}'`
12 psi_cv_libc_main=$psi_libc_main
16 dnl PSI_FUNC(fn, action-if-yes, action-if-no)
18 AC_REQUIRE([PSI_FUNC_LIBC_MAIN])
20 AC_CACHE_CHECK(for $1, psi_cv_fn_$1, [
22 AC_TRY_LINK(PSI_INCLUDES, [
23 void (*fn)(void) = (void (*)(void)) $psi_symbol;
25 psi_symbol_redirect=`$NM -g conftest$ac_exeext | $AWK -F" *|@" '/^\s+U '$psi_cv_libc_main'/ {next} /^\s+U / {print$[]3; exit}'`
27 psi_cv_fn_$1=$psi_symbol_redirect
29 case "$psi_cv_fn_$1" in
33 "$psi_symbol"|"_$psi_symbol")
43 AC_DEFUN(PSI_DECL_ARG, [
44 m4_define([member_name], PSI_VAR_NAME($1))
45 m4_define([member_type], PSI_VAR_TYPE($1))
47 PSI_TYPE_INDIRECTION([$1],, pl, as)
48 if test -n "$psi_decl_args"; then
49 psi_decl_args="$psi_decl_args, "
51 psi_decl_args="[$psi_decl_args{]PSI_TYPE_PAIR(member_type)[, \"]member_name[\",] $pl, $as[}]"
54 dnl PSI_DECL(type func, args)
61 [m4_map_args_sep([PSI_DECL_ARG(m4_normalize(], [))], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
62 PSI_FUNC(PSI_VAR_NAME($1), [
63 PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"
66 PSI_DECLS="$psi_decl_args, {0}, $PSI_DECLS"