+ psi_add_type "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}"
+ fi
+])
+
+AC_DEFUN(PSI_STDTYPE, [
+ ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1))
+ PSI_CHECK_SIZEOF($1)
+ if PSI_SH_TEST_SIZEOF($1); then
+ m4_case([$1],
+ [float],[psi_add_stdtype "{PSI_T_FLOAT, \"float\", NULL}"],
+ [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)
+ AS_TR_SH(psi_basic_type_$1)=$psi_basic_type
+ psi_add_stdtype "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}"
+ ])
+ fi
+])
+
+dnl PSI_SH_BASIC_TYPE(type)
+dnl Expand to the basic type (int/uint) of a distinct type
+AC_DEFUN(PSI_SH_BASIC_TYPE, [$AS_TR_SH([psi_basic_type_]$1)])
+
+dnl PSI_OPAQUE_TYPE(type name)
+dnl Checks a type for being a scalar, a struct or a pointer type.
+dnl Calls AC_TYPE_<TYPE> (if defined) and PSI_CHECK_SIZEOF.
+dnl Defines a pre-defined type in $PSI_TYPES and a pre-defined struct in
+dnl $PSI_STRUCTS if the type is a struct.
+AC_DEFUN(PSI_OPAQUE_TYPE, [
+ ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1))
+ PSI_CHECK_SIZEOF($1)
+ if PSI_SH_TEST_SIZEOF($1); then
+ psi_type_class=
+ AC_CACHE_CHECK(kind of $1, AS_TR_SH([psi_cv_type_class_]$1), [
+ AC_TRY_COMPILE(PSI_INCLUDES, [char test@<:@($1)1@:>@;], [
+ psi_type_class=scalar
+ ], [
+ AC_TRY_COMPILE(PSI_INCLUDES, [$1 test = 0;], [
+ AC_TRY_COMPILE(PSI_INCLUDES, [$1 test = (($1)0)+1;], [
+ psi_type_class="pointer of known type"
+ ], [
+ psi_type_class="pointer of opaque type"
+ ])
+ ], [
+ psi_type_class=struct
+ ])
+ ])
+ AS_TR_SH([psi_cv_type_class_]$1)="$psi_type_class"
+ ])
+ 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)
+ psi_add_type "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}"
+ ;;
+ struct)
+ PSI_STRUCT($1)
+ ;;
+ pointer*)
+ psi_add_type "{PSI_T_POINTER, \"void\", \"$1\"}"
+ ;;
+ *)
+ AC_MSG_WARN(could not detect kind of $1)
+ ;;
+ esac