-PSI_CONSTS=""
-# add_str_const(name, value)
-add_str_const() {
- PSI_CONSTS="{PSI_T_STRING, \"string\", \"psi\\\\$1\", $2, PSI_T_QUOTED_STRING}, $PSI_CONSTS"
-}
-# add_int_const(name, value)
-add_int_const() {
- PSI_CONSTS="{PSI_T_INT, \"int\", \"psi\\\\$1\", \"$2\", PSI_T_NUMBER}, $PSI_CONSTS"
-}
-dnl PSI_CONST(const name, type)
-AC_DEFUN(PSI_CONST, [
- AC_CACHE_CHECK(value of $1, psi_cv_const_$1, [
- psi_const_val=
- case $2 in
- str*)
- if test "$cross_compiling" = "yes"
- then
- AC_TRY_CPP(PSI_INCLUDES $1, psi_const_val=`eval "$ac_try|tail -n1"`, psi_const_val=)
- else
- PSI_COMPUTE_STR(psi_const_val, $1, PSI_INCLUDES)
- fi
- ;;
- int)
- AC_COMPUTE_INT(psi_const_val, $1, PSI_INCLUDES)
- ;;
- esac
- psi_cv_const_$1=$psi_const_val
- ])
- if test "$psi_cv_const_$1"
- then
- case $2 in
- str*)
- add_str_const "$1" "$psi_cv_const_$1"
- ;;
- int)
- add_int_const "$1" "$psi_cv_const_$1"
- ;;
- esac
- fi
-])
-
-PSI_DECLS=
-# add_decl(ret type, symbol, args)
-add_decl() {
- local size
- eval size=\$ac_cv_sizeof_$1
- PSI_DECLS="{`psi_type_pair \"$1\" \"$size\"`, \"$2\"}, $PSI_DECLS"
-}
-PSI_REDIR=
-# add_redir(symbol, macro=symbol)
-add_redir() {
- local sym=$2
- test -z "$sym" && sym=$1
- PSI_REDIR="{\"$1\", (void (*)(void)) $sym}, $PSI_REDIR"
-}
-# arg_names(typed args)
-arg_names() {
- AS_ECHO_N([$1]) \
- | tr -cd '()' \
- | $AWK -F, '{for (i=1;i<NF;++i) print $i ","; print $NF}' \
- | $AWK '{print $NF}' \
- | xargs
-}
-PSI_MACROS=
-# gen_macro(ret type, symbol, args)
-gen_macro() {
- local dargs="$3"
- test -z "$3" && dargs="()"
- AS_ECHO_N(["static $1 psi_macro_$2$dargs {"])
- if test "$1" != "void"; then
- AS_ECHO_N(["return "])
- fi
- arg_names "$3"
- AS_ECHO_N(["$2`arg_names \"$3\"`;}"])
-}
-# add_macro(ret type, symbol, args)
-add_macro() {
- PSI_MACROS="`gen_macro \"$1\" \"$2\" \"$3\"` $PSI_MACROS"
- add_redir "$2" "psi_macro_$2"
-}
-
-dnl PSI_MACRO(macro, decl args, action-if-true)
-AC_DEFUN(PSI_MACRO, [
- AC_CHECK_DECL($1$2, $3, [], PSI_INCLUDES)
-])
+dnl unsigned char* buf[16] -> char
+AC_DEFUN(PSI_TYPE_NAME, [m4_bregexp([$1], [\(\(struct \)?[^ ]+\)[ *]+[^ ]+$], [\1])])
+dnl unsigned char* buf[16] -> buf
+AC_DEFUN(PSI_VAR_NAME, [m4_bregexp(m4_bregexp([$1], [[^ ]+$], [\&]), [\w+], [\&])])
+dnl PSI_TYPE_SIZE(type, pointer level, array size)
+AC_DEFUN(PSI_TYPE_SIZE, [ifelse(
+ [$3], 0,
+ [ifelse([$2], 0, $AS_TR_SH([ac_cv_sizeof_]$1), $ac_cv_sizeof_void_p)],
+ [ifelse([$2], 1, [`expr $3 \* $AS_TR_SH([ac_cv_sizeof_]$1)`], $ac_cv_sizeof_void_p)]
+)])
+dnl PSI_TYPE_BITS(type)
+AC_DEFUN(PSI_TYPE_BITS, [`expr 8 \* $AS_TR_SH([ac_cv_sizeof_]$1)`])