X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=m4%2Fpsi%2Fpsi_type.m4;h=27aeeaccf76e95603a96c9987dc4c81aa25389c8;hb=4d2c075c160bbc1ff49c3499f8fdd07d9c447a12;hp=826ae7e8dc6ba356ac4e82935c56e75c0658b0a7;hpb=c9b3436bd51a4dcf7d6cc6817d4c7a8ad99538d4;p=m6w6%2Fext-psi diff --git a/m4/psi/psi_type.m4 b/m4/psi/psi_type.m4 index 826ae7e..27aeeac 100644 --- a/m4/psi/psi_type.m4 +++ b/m4/psi/psi_type.m4 @@ -1,15 +1,13 @@ # psi_add_type(type triplet) -# Add a pre-defined type to $PSI_TYPES. +# Add a pre-defined type to $PSI_TYPES_H. psi_add_type() { - cat >>$PSI_TYPES <>$PSI_STDTYPES </dev/null; do + psi_type_lower=`printf "%s" "$psi_type_lower" | cut -d " " -f2-` + done case $psi_type_lower in int*|uint*) local psi_type_upper=`printf "%s" "$psi_type_name" | tr a-z A-Z` @@ -42,9 +43,9 @@ psi_type_pair() { dnl PSI_TYPE(type name, basic type) dnl Check for a specific type, optionally referring to a basic type. dnl Calls AC_TYPE_ (if defined) and PSI_CHECK_SIZEOF. -dnl If the basic type is just specified as "int" (in contrast to "sint" or +dnl If the basic type is just specified as "int" (in contrast to "sint" or dnl "uint"), AX_CHECK_SIGN is used to discover signedness of the type. -dnl Defines a pre-defined type in $PSI_TYPES. +dnl Defines a pre-defined type in $PSI_TYPES_H. AC_DEFUN(PSI_TYPE, [ ifdef(AS_TR_CPP(AC_TYPE_$1), AS_TR_CPP(AC_TYPE_$1)) PSI_CHECK_SIZEOF($1) @@ -68,6 +69,7 @@ AC_DEFUN(PSI_STDTYPE, [ PSI_CHECK_SIZEOF($1) if PSI_SH_TEST_SIZEOF($1); then m4_case([$1], + [bool],[psi_add_stdtype "{PSI_T_BOOL, \"bool\", NULL}"], [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}"], @@ -86,7 +88,7 @@ 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_ (if defined) and PSI_CHECK_SIZEOF. -dnl Defines a pre-defined type in $PSI_TYPES and a pre-defined struct in +dnl Defines a pre-defined type in $PSI_TYPES_H 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)) @@ -133,18 +135,20 @@ AC_DEFUN(PSI_FUNCTOR_TYPE, [ dnl psi_add_type "{PSI_T_POINTER, \"void\", \"PSI_VAR_NAME($1)\"}" AS_TR_SH([ac_cv_sizeof_]PSI_VAR_NAME($1))=PSI_SH_SIZEOF(void *) PSI_DECL_TYPE([$1], [$2]) - if test "$PHP_DEBUG" = "1"; then - AC_CHECK_TYPE(PSI_VAR_NAME($1), [], [ - psi_add_macro ["#undef ]PSI_VAR_NAME($1)["] - psi_add_macro ["typedef ]PSI_VAR_TYPE($1)[ (*]PSI_VAR_NAME($1)[)]$2;" - ]) - fi + AC_CHECK_TYPE(PSI_VAR_NAME($1), [], [ + psi_add_macro ["#undef ]PSI_VAR_NAME($1)["] + psi_add_macro ["typedef ]PSI_VAR_TYPE($1)[ (*]PSI_VAR_NAME($1)[)]$2;" + ]) ]) dnl PSI_VAR_TYPE(decl arg) dnl Extracts the type of a decl arg, e.g. dnl unsigned char* buf[16] -> unsigned char*. AC_DEFUN(PSI_VAR_TYPE, [m4_bregexp([$1], [^\(const \)?\(.*\) \([*]*\)[^ ]+$], [\2\3])]) +dnl PSI_VAR_TYPE_RETURN(decl arg) +dnl Extracts the type of a decl arg usable for return types, e.g. dnl unsigned char* buf[16] -> unsigned char**. +AC_DEFUN(PSI_VAR_TYPE_RETURN, [PSI_VAR_TYPE(m4_bpatsubst([$1], [\([^ ]+\) *@<:@[0-9]+@:>@], [* \1]))]) + dnl PSI_VAR_NAME(decl arg) dnl Extracts the var name of a decl arg, e.g. unsigned char* buf[16] -> buf. AC_DEFUN(PSI_VAR_NAME, [m4_bregexp(m4_bregexp([$1], [\([^ ]+\)$], [\1]), [\w+], [\&])]) @@ -187,9 +191,10 @@ AC_DEFUN(PSI_TYPE_PAIR, [m4_case(m4_bregexp([$1], [^\w+], [\&]), [PSI_T_NAME, \"m4_bregexp([$1], [^\(\w+ \)*\w+], [\&])\"])]) dnl PSI_CHECK_STD_TYPES() -dnl Checks for standard ANSI-C and stdint types. +dnl Checks for standard ANSI-C, stdint and stdbool types. AC_DEFUN(PSI_CHECK_STD_TYPES, [ AC_CHECK_HEADERS(stdint.h) + AC_HEADER_STDBOOL AC_TYPE_INT8_T PSI_CHECK_SIZEOF(int8_t) @@ -215,7 +220,7 @@ 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 *) @@ -226,6 +231,9 @@ AC_DEFUN(PSI_CHECK_STD_TYPES, [ PSI_STDTYPE(long double) AC_CHECK_ALIGNOF(long double) + PSI_STDTYPE(bool) + AC_CHECK_ALIGNOF(bool, PSI_INCLUDES) + PSI_STDTYPE(char, int) AC_CHECK_ALIGNOF(char) PSI_STDTYPE(signed char, int) @@ -255,6 +263,6 @@ AC_DEFUN(PSI_CHECK_STD_TYPES, [ 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? + dnl this must come after the check for "unsigned long long int"; autoconf, wth? PSI_STDTYPE(long long int, int) ])