X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=m4%2Fpsi_type.m4;h=ef073ca3191f844bb5325a41310ef76ee99556ef;hb=7fa8158cfcdd526f247d063202dc57c7f76901d8;hp=7e4badbbbacb4bf3ab26e24d5c6aa4214d04e969;hpb=7e3b009ddee1508720d3493c3985654e8f21ea0e;p=m6w6%2Fext-psi diff --git a/m4/psi_type.m4 b/m4/psi_type.m4 index 7e4badb..ef073ca 100644 --- a/m4/psi_type.m4 +++ b/m4/psi_type.m4 @@ -1,24 +1,35 @@ # psi_add_type(type triplet) # Add a pre-defined type to $PSI_TYPES. psi_add_type() { - cat >>$PSI_TYPES <<<" $1, " + cat >>$PSI_TYPES <>$PSI_STDTYPES <, \"\" tuple. # Uses stdint types when possible. psi_type_pair() { - local psi_type_name=`tr -cd A-Za-z0-9_ <<<$1` - local psi_type_lower=`tr A-Z a-z <<<$psi_type_name` + local psi_type_name=`printf "%s" "$1" | tr -cd A-Za-z0-9_` + local psi_type_lower=`printf "%s" "$1" | tr A-Z a-z` case $psi_type_lower in int*|uint*) - local psi_type_upper=`tr a-z A-Z <<<$psi_type_name` + local psi_type_upper=`printf "%s" "$psi_type_name" | tr a-z A-Z` local psi_type_bits=`expr $2 \* 8` echo "PSI_T_${psi_type_upper}${psi_type_bits}, \"${psi_type_lower}${psi_type_bits}_t\"" ;; struct*) echo "PSI_T_STRUCT, \"$2\"" ;; + union*) + echo "PSI_T_UNION, \"$2\"" + ;; void) echo "PSI_T_VOID, \"void\"" ;; @@ -48,7 +59,23 @@ AC_DEFUN(PSI_TYPE, [ esac if test "$2" && PSI_SH_TEST_SIZEOF($1); then AS_TR_SH(psi_basic_type_$1)=$psi_basic_type - psi_add_type "{`psi_type_pair $psi_basic_type $AS_TR_SH([ac_cv_sizeof_]$1)`, \"$1\"}" + 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 ]) @@ -66,7 +93,7 @@ AC_DEFUN(PSI_OPAQUE_TYPE, [ PSI_CHECK_SIZEOF($1) if PSI_SH_TEST_SIZEOF($1); then psi_type_class= - AC_CACHE_CHECK(type class of $1, AS_TR_SH([psi_cv_type_class_]$1), [ + 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 ], [ @@ -85,7 +112,7 @@ AC_DEFUN(PSI_OPAQUE_TYPE, [ 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 $AS_TR_SH([ac_cv_sizeof_]$1)`, \"$1\"}" + psi_add_type "{`psi_type_pair $psi_basic_type PSI_SH_SIZEOF($1)`, \"$1\"}" ;; struct) PSI_STRUCT($1) @@ -94,7 +121,7 @@ AC_DEFUN(PSI_OPAQUE_TYPE, [ psi_add_type "{PSI_T_POINTER, \"void\", \"$1\"}" ;; *) - AC_MSG_WARN(could not detect type class of $1) + AC_MSG_WARN(could not detect kind of $1) ;; esac fi @@ -142,6 +169,7 @@ dnl FIXME: There is also psi_type_pair()? AC_DEFUN(PSI_TYPE_PAIR, [m4_case(m4_bregexp([$1], [^\w+], [\&]), [void], [PSI_T_VOID, \"void\"], [struct], [PSI_T_STRUCT, \"m4_bregexp([$1], [^struct \(\w+\)], [\1])\"], + [union], [PSI_T_UNION, \"m4_bregexp([$1], [^union \(\w+\)], [\1])\"], [PSI_T_NAME, \"m4_bregexp([$1], [^\(\w+ \)*\w+], [\&])\"])]) dnl PSI_CHECK_STD_TYPES() @@ -173,40 +201,46 @@ AC_DEFUN(PSI_CHECK_STD_TYPES, [ AC_TYPE_UINT64_T PSI_CHECK_SIZEOF(uint64_t) AC_CHECK_ALIGNOF(uint64_t) + + PSI_CHECK_SIZEOF(void *) + AC_CHECK_ALIGNOF(void *) - PSI_TYPE(float) + PSI_STDTYPE(float) AC_CHECK_ALIGNOF(float) - PSI_TYPE(double) + PSI_STDTYPE(double) AC_CHECK_ALIGNOF(double) - PSI_TYPE(long double) + PSI_STDTYPE(long double) AC_CHECK_ALIGNOF(long double) - PSI_TYPE(void *) - AC_CHECK_ALIGNOF(void *) - PSI_TYPE(char, int) - PSI_TYPE(signed char, int) - PSI_TYPE(unsigned char, uint) - PSI_TYPE(short, int) - PSI_TYPE(short int, int) - PSI_TYPE(signed short, int) - PSI_TYPE(signed short int, int) - PSI_TYPE(unsigned short, uint) - PSI_TYPE(unsigned short int, uint) - PSI_TYPE(int, int) - PSI_TYPE(signed int, int) - PSI_TYPE(signed, int) - PSI_TYPE(unsigned int, uint) - PSI_TYPE(unsigned, uint) - PSI_TYPE(long, int) - PSI_TYPE(long int, int) - PSI_TYPE(signed long int, int) - PSI_TYPE(unsigned long, uint) - PSI_TYPE(unsigned long int, uint) - PSI_TYPE(long long, int) - PSI_TYPE(signed long long, int) - PSI_TYPE(signed long long int, int) - PSI_TYPE(unsigned long long, uint) - PSI_TYPE(unsigned long long int, uint) + PSI_STDTYPE(char, int) + AC_CHECK_ALIGNOF(char) + PSI_STDTYPE(signed char, int) + PSI_STDTYPE(unsigned char, uint) + PSI_STDTYPE(short, int) + AC_CHECK_ALIGNOF(short) + PSI_STDTYPE(short int, int) + PSI_STDTYPE(signed short, int) + PSI_STDTYPE(signed short int, int) + PSI_STDTYPE(unsigned short, uint) + PSI_STDTYPE(unsigned short int, uint) + PSI_STDTYPE(int, int) + AC_CHECK_ALIGNOF(int) + PSI_STDTYPE(signed int, int) + PSI_STDTYPE(signed, int) + PSI_STDTYPE(unsigned int, uint) + PSI_STDTYPE(unsigned, uint) + PSI_STDTYPE(long, int) + AC_CHECK_ALIGNOF(long) + PSI_STDTYPE(long int, int) + PSI_STDTYPE(signed long int, int) + PSI_STDTYPE(unsigned long, uint) + PSI_STDTYPE(unsigned long int, uint) + PSI_STDTYPE(long long, int) + AC_CHECK_ALIGNOF(long long) + PSI_STDTYPE(signed long long, int) + PSI_STDTYPE(signed long long int, int) + PSI_STDTYPE(unsigned long long, uint) + PSI_STDTYPE(unsigned long long int, uint) dnl this must come after the check fo "unsigned long long int"; autoconf, wth? - PSI_TYPE(long long int, int) + PSI_STDTYPE(long long int, int) ])