1 # psi_add_redir(name, symbol)
2 # Add a function redirection to $PSI_REDIRS_H.
4 PSI_REDIRS="$PSI_REDIRS
5 {\"$1\", (psi_func_ptr) $2},"
8 # psi_add_decl(decl, options)
9 # Add a pre-defined decl to $PSI_VA_DECLS_H/$PSI_DECLS_H.
15 dnl PSI_DECL_TYPE(type functor_name, args)
16 dnl Adds a pre-defined functor decl to $PSI_FN_DECLS_H.
17 AC_DEFUN(PSI_DECL_TYPE, [
18 PSI_DECL_ARGS($1, $2, functor)
19 psi_add_decl "$psi_decl_args"
21 dnl PSI_REDIR(name, custom symbol)
22 dnl Create a function redirection to an optional custom symbol.
24 psi_add_redir $1 ifelse([$2],[],[$1],[$2])
27 dnl PSI_DECL_ARGS(decl func, decl args, options)
28 dnl INTERNAL: build psi_decl_args
29 AC_DEFUN(PSI_DECL_ARGS, [
31 PSI_DECL_ARG([$1], [$3])
37 [PSI_DECL_ARG(m4_normalize(],
38 [), [0])], [], m4_bregexp([$2], [(\(.*\))], [\1]))])
41 dnl PSI_DECL_ARG(decl arg, options)
42 dnl INTERNAL: build psi_decl_args
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{]ifelse([$2],,DECL_KIND_STD,[ifelse([$2],0,0,AS_TR_CPP([DECL_KIND_$2]))])[, ]PSI_TYPE_PAIR(member_type)[, \"]member_name[\",] $pl, $as[}]"
54 dnl PSI_DECL(type func, args, flags, libs)
55 dnl Check for a function or macro declaration and a possible asm redirection.
56 dnl Adds a pre-defined (vararg) decl to $PSI_VA_DECLS_H/$PSI_DECLS_H.
57 dnl Calls PSI_MACRO if PSI_FUNC fails.
59 PSI_DECL_ARGS($1, $2, $3)
61 psi_symbol="PSI_VAR_NAME($1)"
62 AC_CACHE_CHECK(for PSI_VAR_NAME($1), [psi_cv_fn_]PSI_VAR_NAME($1), [
68 AC_TRY_LINK(PSI_INCLUDES, [
69 void (*fn)(long, long, long) = (void (*)(long,long,long)) $psi_symbol;
72 psi_symbol_redirect=`nm -g conftest$ac_exeext | $AWK -F ' *|@' '/^@<:@@<:@:space:@:>@@:>@+U '$psi_cv_libc_main'/ {next} /^@<:@@<:@:space:@:>@@:>@+U / {print$[]3; exit}'`
76 if test -n "$psi_symbol_redirect"; then
77 if test -n "$lib"; then
78 psi_decl_check="$psi_symbol_redirect in $lib"
80 psi_decl_check="$psi_symbol_redirect"
85 [psi_cv_fn_]PSI_VAR_NAME($1)=$psi_decl_check
88 psi_symbol_redirect=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]1}'`
89 psi_symbol_libflag=`AS_ECHO("$[psi_cv_fn_]PSI_VAR_NAME($1)") | $AWK -F " in " '{print [$]2}'`
91 if test -n "$psi_symbol_libflag"; then
92 if ! expr "X$LIBS" : "X.*\b$psi_symbol_libflag\b" >/dev/null; then
93 LIBS="$psi_symbol_libflag $LIBS"
97 case "$psi_symbol_redirect" in
98 "$psi_symbol"|"_$psi_symbol")
99 case "$PSI_EXTRA_REDIRS-$3" in
102 psi_add_decl "$psi_decl_args"
106 if test -n "$psi_symbol_libflag"
108 PSI_REDIR($psi_symbol)
110 psi_add_decl "$psi_decl_args"
115 ifelse([$3], vararg, [
116 AC_MSG_WARN(varargs macro support is not implemented)
119 psi_add_decl "$psi_decl_args"
124 PSI_REDIR($psi_symbol)
125 psi_add_decl "$psi_decl_args"