1dnl 2dnl PAC_GET_STDINT_HEADER - Get system header that defines C99 intXX_t. 3dnl 4dnl PAC_GET_STDINT_HEADER( STDINT_H ) 5dnl 6dnl STDINT_H - returned header which defines C99 intXX_t. Empty string 7dnl if there is no system header that defines intXX_t. 8dnl 9AC_DEFUN( [PAC_GET_STDINT_HEADER], [ 10AC_MSG_CHECKING( [for header that defines C99 integer types, intXX_t] ) 11$1="" 12for hdr in stdint.h inttypes.h sys/inttypes.h ; do 13 AC_COMPILE_IFELSE( [ 14 AC_LANG_PROGRAM( [#include <$hdr>], [ 15 int8_t ii08 = 0; 16 int16_t ii16 = 0; 17 int32_t ii32 = 0; 18 int64_t ii64 = 0; 19 ] ) 20 ], [ 21 $1=$hdr 22 break 23 ] ) 24done 25if test -n "[$]$1" ; then 26 AC_MSG_RESULT( [<[$]$1>] ) 27else 28 AC_MSG_RESULT( [none] ) 29fi 30] )dnl 31dnl 32dnl 33dnl PAC_GET_BASIC_INT_TYPES - Get stdint types based on basic types, i.e. 34dnl char, short, int, long & long long. 35dnl 36dnl PAC_GET_BASIC_INT_TYPES( INT8, INT16, INT32, INT64 ) 37dnl 38dnl INT8 - returned int8_t. 39dnl INT16 - returned int16_t. 40dnl INT32 - returned int32_t. 41dnl INT64 - returned int64_t. 42dnl 43AC_DEFUN( [PAC_GET_BASIC_INT_TYPES], [ 44# dnl Determine the sizeof(char) 45 AC_CHECK_SIZEOF(char) 46 if test "$ac_cv_sizeof_char" = 1 ; then 47 $1="char" 48 else 49 PAC_MSG_ERROR( $enable_softerror, 50 [sizeof(char) isn't 1! Aborting...] ) 51 fi 52 53# dnl Determine the sizeof(short) 54 AC_CHECK_SIZEOF(short) 55 if test "$ac_cv_sizeof_short" = 2 ; then 56 $2="short" 57 else 58 PAC_MSG_ERROR( $enable_softerror, 59 [sizeof(short) isn't 2! Aborting...] ) fi 60 61# dnl Determine the sizeof(int) 62 AC_CHECK_SIZEOF(int) 63 if test "$ac_cv_sizeof_int" = 4 ; then 64 $3="int" 65 else 66 PAC_MSG_ERROR( $enable_softerror, 67 [sizeof(int) isn't 4! Aborting...] ) 68 fi 69 70# dnl Determine the sizeof(long) and sizeof(long long) 71 AC_CHECK_SIZEOF(long) 72 AC_CHECK_SIZEOF(long long) 73 if test "$ac_cv_sizeof_long" = 8 ; then 74 $4=long 75 else 76 if test "$ac_cv_sizeof_long_long" = 8 ; then 77 $4="long long" 78 else 79 PAC_MSG_ERROR( $enable_softerror, 80 [Neither sizeof(long) or sizeof(long long) is 8! Aborting...] ) 81 fi 82 fi 83] ) dnl 84dnl 85dnl 86dnl PAC_GET_STDINT_FORMATS - Get printf format specifiers for intXX_t's 87dnl 88dnl PAC_GET_STDINT_FORMATS( INT8, INT16, INT32, INT64, 89dnl INT8FMT, INT16FMT, INT32FMT, INT64FMT, 90dnl INTFMT_H ) 91dnl 92dnl INT8 - int8_t or char. 93dnl INT16 - int16_t or short. 94dnl INT32 - int32_t or int. 95dnl INT64 - int64_t or long/long long. 96dnl INT8FMT - returned format specifiers for int8_t. 97dnl INT16FMT - returned format specifiers for int16_t. 98dnl INT32FMT - returned format specifiers for int32_t. 99dnl INT64FMT - returned format specifiers for int64_t. 100dnl INTFMT_H - returned headers for the format specifiers. 101dnl 102AC_DEFUN( [PAC_GET_STDINT_FORMATS], [ 103mpe_c99_inttypes_h="" 104if test "$3" = "int32_t" -a "$4" = "int64_t" ; then 105 AC_CHECK_HEADERS( inttypes.h, [ 106 dnl If inttypes.h exists, check for PRIdXX 107 AC_MSG_CHECKING( [whether <inttypes.h> defines the PRIdXX macros] ) 108 AC_COMPILE_IFELSE( [ 109 AC_LANG_PROGRAM( [ 110 #include <inttypes.h> 111 #ifdef HAVE_STDIO_H 112 #include <stdio.h> 113 #endif 114 #ifdef HAVE_SYS_TYPES_H 115 #include <sys/types.h> 116 #endif 117 #ifdef HAVE_SYS_BITYPES_H 118 #include <sys/bitypes.h> 119 #endif 120 ], [ 121 printf( "%" PRId8 "\n", ($1) 1 ); 122 printf( "%" PRId16 "\n", ($2) 1 ); 123 printf( "%" PRId32 "\n", ($3) 1 ); 124 printf( "%" PRId64 "\n", ($4) 1 ); 125 ] ) 126 ], [ 127 AC_MSG_RESULT(yes) 128 mpe_c99_inttypes_h="inttypes.h" 129 ], [ 130 AC_MSG_RESULT(no) 131 ] ) dnl Endof AC_COMPILE_IFELSE 132 ] ) dnl Endof AC_CHECK_HEADERS 133fi 134if test "X$mpe_c99_inttypes_h" != "X" ; then 135 $5="\"%\"PRId8" 136 $6="\"%\"PRId16" 137 $7="\"%\"PRId32" 138 $8="\"%\"PRId64" 139 $9="$mpe_c99_inttypes_h" 140else 141 $5="\"%d\"" 142 $6="\"%d\"" 143 $7="\"%d\"" 144 if test "$4" = "long" ; then 145 $8="\"%ld\"" 146 else 147 $8="\"%lld\"" 148 fi 149 $9="" 150fi 151] ) dnl 152dnl 153dnl 154dnl PAC_OUTPUT_STDINT_HEADER - Create/Output an header file that define 155dnl integer types. 156dnl 157dnl PAC_OUTPUT_STDINT_HEADER( OUTPUT_H, STDINT_H, PRIDXX_H, 158dnl INT8, INT16, INT32, INT64, 159dnl INT8FMT, INT16FMT, INT32FMT, INT64FMT, 160dnl 161dnl OUTPUT_H - output header 162dnl STDINT_H - header that defines integer types 163dnl PRIDXX_H - header that defines integer printf format specifiers 164dnl INT8 - int8_t or char. 165dnl INT16 - int16_t or short. 166dnl INT32 - int32_t or int. 167dnl INT64 - int64_t or long/long long. 168dnl INT8FMT - returned format specifiers for int8_t. 169dnl INT16FMT - returned format specifiers for int16_t. 170dnl INT32FMT - returned format specifiers for int32_t. 171dnl INT64FMT - returned format specifiers for int64_t. 172dnl 173AC_DEFUN( [PAC_OUTPUT_STDINT_HEADER], [ 174AC_CONFIG_COMMANDS( [$pac_output_h], [ 175 AC_MSG_NOTICE( [creating $pac_output_h] ) 176 rm -f $pac_output_h 177 echo "/* MPE logging header for C99 integer types */" > $pac_output_h 178 echo "#if !defined( _CLOG_STDINT )" >> $pac_output_h 179 echo "#define _CLOG_STDINT" >> $pac_output_h 180 echo >> $pac_output_h 181# dnl /* Put in the system headers */ 182 if test "X$pac_c99_stdint_h" != "X" ; then 183 echo "#include <$pac_c99_stdint_h>" >> $pac_output_h 184 if test "X$pac_c99_pridxx_h" != "X" ; then 185 if test "$pac_c99_pridxx_h" != "$pac_c99_stdint_h" ; then 186 echo "#include <$pac_c99_pridxx_h>" >> $pac_output_h 187 fi 188 fi 189 fi 190 echo >> $pac_output_h 191 echo "typedef $pac_int8_t CLOG_int8_t;" >> $pac_output_h 192 echo "typedef $pac_int16_t CLOG_int16_t;" >> $pac_output_h 193 echo "typedef $pac_int32_t CLOG_int32_t;" >> $pac_output_h 194 echo "typedef $pac_int64_t CLOG_int64_t;" >> $pac_output_h 195 echo >> $pac_output_h 196# dnl /* Define iXXfmt printf format specifiers */ 197 echo "#define i8fmt $pac_int8_fmt" >> $pac_output_h 198 echo "#define i16fmt $pac_int16_fmt" >> $pac_output_h 199 echo "#define i32fmt $pac_int32_fmt" >> $pac_output_h 200 echo "#define i64fmt $pac_int64_fmt" >> $pac_output_h 201 echo >> $pac_output_h 202 echo "#endif" >> $pac_output_h 203], [ 204 PACKAGE="$PACKAGE" 205 VERSION="$VERSION" 206 pac_output_h="$1" 207 pac_c99_stdint_h="$2" 208 pac_c99_pridxx_h="$3" 209 pac_int8_t="$4" 210 pac_int16_t="$5" 211 pac_int32_t="$6" 212 pac_int64_t="$7" 213 pac_int8_fmt="$8" 214 pac_int16_fmt="$9" 215 pac_int32_fmt="$10" 216 pac_int64_fmt="$11" 217] ) dnl Endof AC_CONFIG_COMMANDS() 218] ) dnl 219