X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=m4%2Fpsi_type.m4;h=6324c75e5da342e6d0f47b16795875701aefa6fa;hp=70a9ab1bd1efc6187fc4dc45160543e12ec81904;hb=81b71a515e2024cee739deb6e207eb3b0e7c5d64;hpb=b1720af16e5d7765e2effcd16e23f351c2f82e54 diff --git a/m4/psi_type.m4 b/m4/psi_type.m4 index 70a9ab1..6324c75 100644 --- a/m4/psi_type.m4 +++ b/m4/psi_type.m4 @@ -21,11 +21,11 @@ psi_type_pair() { esac } -dnl PSI_TYPE(type name, basic type, includes) +dnl PSI_TYPE(type name, basic type) AC_DEFUN(PSI_TYPE, [ ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1)) PSI_CHECK_SIZEOF($1, PSI_INCLUDES) - psi_basic_type=$2 + psi_basic_type=AS_TR_SH($2) case $psi_basic_type in int) AX_CHECK_SIGN($1, :, [ @@ -42,6 +42,44 @@ AC_DEFUN(PSI_TYPE, [ fi ]) +AC_DEFUN(PSI_OPAQUE_TYPE, [ + ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1)) + PSI_CHECK_SIZEOF($1, PSI_INCLUDES) + if test "$AS_TR_SH([ac_cv_sizeof_]$1)" -gt 0; then + psi_type_class= + AC_CACHE_CHECK(type class 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) + PSI_TYPE($1, int) + ;; + struct) + PSI_STRUCT($1) + ;; + pointer*) + cat >>$PSI_TYPES <<<" {PSI_T_POINTER, \"void\", \"$1\"}, " + ;; + *) + AC_MSG_WARN(could not detect type class of $1) + ;; + esac + fi +]) + dnl unsigned char* buf[16] -> unsigned char* dnl AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [\(\(struct \)?[^ ]+\)[ *]+[^ ]+$], [\1])]) AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [^\(const \)?\(.*\) \([*]*\)[^ ]+$], [\2\3])])