1c9710b42Smrgdnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])] 2c9710b42Smrgdnl 3c9710b42Smrgdnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the 4c9710b42Smrgdnl existence of an include file <stdint.h> that defines a set of 5c9710b42Smrgdnl typedefs, especially uint8_t,int32_t,uintptr_t. Many older 6c9710b42Smrgdnl installations will not provide this file, but some will have the 7c9710b42Smrgdnl very same definitions in <inttypes.h>. In other enviroments we can 8c9710b42Smrgdnl use the inet-types in <sys/types.h> which would define the typedefs 9c9710b42Smrgdnl int8_t and u_int8_t respectivly. 10c9710b42Smrgdnl 11c9710b42Smrgdnl This macros will create a local "_stdint.h" or the headerfile given 12c9710b42Smrgdnl as an argument. In many cases that file will just "#include 13c9710b42Smrgdnl <stdint.h>" or "#include <inttypes.h>", while in other environments 14c9710b42Smrgdnl it will provide the set of basic 'stdint's definitions/typedefs: 15c9710b42Smrgdnl 16c9710b42Smrgdnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t 17c9710b42Smrgdnl int_least32_t.. int_fast32_t.. intmax_t 18c9710b42Smrgdnl 19c9710b42Smrgdnl which may or may not rely on the definitions of other files, or 20c9710b42Smrgdnl using the AC_CHECK_SIZEOF macro to determine the actual sizeof each 21c9710b42Smrgdnl type. 22c9710b42Smrgdnl 23c9710b42Smrgdnl if your header files require the stdint-types you will want to 24c9710b42Smrgdnl create an installable file mylib-int.h that all your other 25c9710b42Smrgdnl installable header may include. So if you have a library package 26c9710b42Smrgdnl named "mylib", just use 27c9710b42Smrgdnl 28c9710b42Smrgdnl AX_CREATE_STDINT_H(mylib-int.h) 29c9710b42Smrgdnl 30c9710b42Smrgdnl in configure.ac and go to install that very header file in 31c9710b42Smrgdnl Makefile.am along with the other headers (mylib.h) - and the 32c9710b42Smrgdnl mylib-specific headers can simply use "#include <mylib-int.h>" to 33c9710b42Smrgdnl obtain the stdint-types. 34c9710b42Smrgdnl 35c9710b42Smrgdnl Remember, if the system already had a valid <stdint.h>, the 36c9710b42Smrgdnl generated file will include it directly. No need for fuzzy 37c9710b42Smrgdnl HAVE_STDINT_H things... (oops, GCC 4.2.x has deliberatly 38c9710b42Smrgdnl disabled its stdint.h for non-c99 compilation and the c99-mode 39c9710b42Smrgdnl is not the default. Therefore this macro will not use the 40c9710b42Smrgdnl compiler's stdint.h - please complain to the GCC developers). 41c9710b42Smrgdnl 42c9710b42Smrgdnl @category C 43c9710b42Smrgdnl @author Guido U. Draheim <guidod@gmx.de> 44c9710b42Smrgdnl @version 2003-12-07 45c9710b42Smrgdnl @license GPLWithACException 46c9710b42Smrg 47c9710b42SmrgAC_DEFUN([AX_CHECK_DATA_MODEL],[ 48c9710b42Smrg AC_CHECK_SIZEOF(char) 49c9710b42Smrg AC_CHECK_SIZEOF(short) 50c9710b42Smrg AC_CHECK_SIZEOF(int) 51c9710b42Smrg AC_CHECK_SIZEOF(long) 52c9710b42Smrg AC_CHECK_SIZEOF(void*) 53c9710b42Smrg ac_cv_char_data_model="" 54c9710b42Smrg ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" 55c9710b42Smrg ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" 56c9710b42Smrg ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" 57c9710b42Smrg ac_cv_long_data_model="" 58c9710b42Smrg ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" 59c9710b42Smrg ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" 60c9710b42Smrg ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" 61c9710b42Smrg AC_MSG_CHECKING([data model]) 62c9710b42Smrg case "$ac_cv_char_data_model/$ac_cv_long_data_model" in 63c9710b42Smrg 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; 64c9710b42Smrg 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; 65c9710b42Smrg 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; 66c9710b42Smrg 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; 67c9710b42Smrg 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; 68c9710b42Smrg 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; 69c9710b42Smrg 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; 70c9710b42Smrg 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; 71c9710b42Smrg 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; 72c9710b42Smrg 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; 73c9710b42Smrg 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; 74c9710b42Smrg 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; 75c9710b42Smrg 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; 76c9710b42Smrg 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; 77c9710b42Smrg 222/*|333/*|444/*|666/*|888/*) : 78c9710b42Smrg ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; 79c9710b42Smrg *) ac_cv_data_model="none" ; n="very unusual model" ;; 80c9710b42Smrg esac 81c9710b42Smrg AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)]) 82c9710b42Smrg]) 83c9710b42Smrg 84c9710b42Smrgdnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF]) 85c9710b42SmrgAC_DEFUN([AX_CHECK_HEADER_STDINT_X],[ 86c9710b42SmrgAC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[ 87c9710b42Smrg ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h) 88c9710b42Smrg AC_MSG_RESULT([(..)]) 89c9710b42Smrg for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h sys/types.h]) 90c9710b42Smrg do 91c9710b42Smrg unset ac_cv_type_uintptr_t 92c9710b42Smrg unset ac_cv_type_uint64_t 93c9710b42Smrg AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>]) 94c9710b42Smrg AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) 95c9710b42Smrg m4_ifvaln([$2],[$2]) break 96c9710b42Smrg done 97c9710b42Smrg AC_MSG_CHECKING([for stdint uintptr_t]) 98c9710b42Smrg ]) 99c9710b42Smrg]) 100c9710b42Smrg 101c9710b42SmrgAC_DEFUN([AX_CHECK_HEADER_STDINT_O],[ 102c9710b42SmrgAC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[ 103c9710b42Smrg ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h) 104c9710b42Smrg AC_MSG_RESULT([(..)]) 105c9710b42Smrg for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h sys/types.h stdint.h]) 106c9710b42Smrg do 107c9710b42Smrg unset ac_cv_type_uint32_t 108c9710b42Smrg unset ac_cv_type_uint64_t 109c9710b42Smrg AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>]) 110c9710b42Smrg AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) 111c9710b42Smrg m4_ifvaln([$2],[$2]) break 112c9710b42Smrg break; 113c9710b42Smrg done 114c9710b42Smrg AC_MSG_CHECKING([for stdint uint32_t]) 115c9710b42Smrg ]) 116c9710b42Smrg]) 117c9710b42Smrg 118c9710b42SmrgAC_DEFUN([AX_CHECK_HEADER_STDINT_U],[ 119c9710b42SmrgAC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[ 120c9710b42Smrg ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h) 121c9710b42Smrg AC_MSG_RESULT([(..)]) 122c9710b42Smrg for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do 123c9710b42Smrg unset ac_cv_type_u_int32_t 124c9710b42Smrg unset ac_cv_type_u_int64_t 125c9710b42Smrg AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>]) 126c9710b42Smrg AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>]) 127c9710b42Smrg m4_ifvaln([$2],[$2]) break 128c9710b42Smrg break; 129c9710b42Smrg done 130c9710b42Smrg AC_MSG_CHECKING([for stdint u_int32_t]) 131c9710b42Smrg ]) 132c9710b42Smrg]) 133c9710b42Smrg 134c9710b42SmrgAC_DEFUN([AX_CREATE_STDINT_H], 135c9710b42Smrg[# ------ AX CREATE STDINT H ------------------------------------- 136c9710b42SmrgAC_MSG_CHECKING([for stdint types]) 137c9710b42Smrgac_stdint_h=`echo ifelse($1, , _stdint.h, $1)` 138c9710b42Smrg# try to shortcircuit - if the default include path of the compiler 139c9710b42Smrg# can find a "stdint.h" header then we assume that all compilers can. 140c9710b42SmrgAC_CACHE_VAL([ac_cv_header_stdint_t],[ 141c9710b42Smrgold_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS="" 142c9710b42Smrgold_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="" 143c9710b42Smrgold_CFLAGS="$CFLAGS" ; CFLAGS="" 144c9710b42SmrgAC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;], 145c9710b42Smrg[ac_cv_stdint_result="(assuming C99 compatible system)" 146c9710b42Smrg ac_cv_header_stdint_t="stdint.h"; ], 147c9710b42Smrg[ac_cv_header_stdint_t=""]) 148c9710b42Smrgif test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then 149c9710b42SmrgCFLAGS="-std=c99" 150c9710b42SmrgAC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;], 151c9710b42Smrg[AC_MSG_WARN(your GCC compiler has a defunct stdint.h for its default-mode)]) 152c9710b42Smrgfi 153c9710b42SmrgCXXFLAGS="$old_CXXFLAGS" 154c9710b42SmrgCPPFLAGS="$old_CPPFLAGS" 155c9710b42SmrgCFLAGS="$old_CFLAGS" ]) 156c9710b42Smrg 157c9710b42Smrgv="... $ac_cv_header_stdint_h" 158c9710b42Smrgif test "$ac_stdint_h" = "stdint.h" ; then 159c9710b42Smrg AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)]) 160c9710b42Smrgelif test "$ac_stdint_h" = "inttypes.h" ; then 161c9710b42Smrg AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)]) 162c9710b42Smrgelif test "_$ac_cv_header_stdint_t" = "_" ; then 163c9710b42Smrg AC_MSG_RESULT([(putting them into $ac_stdint_h)$v]) 164c9710b42Smrgelse 165c9710b42Smrg ac_cv_header_stdint="$ac_cv_header_stdint_t" 166c9710b42Smrg AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)]) 167c9710b42Smrgfi 168c9710b42Smrg 169c9710b42Smrgif test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit.. 170c9710b42Smrg 171c9710b42Smrgdnl .....intro message done, now do a few system checks..... 172c9710b42Smrgdnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type, 173c9710b42Smrgdnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW 174c9710b42Smrgdnl instead that is triggered with 3 or more arguments (see types.m4) 175c9710b42Smrg 176c9710b42Smrginttype_headers=`echo $2 | sed -e 's/,/ /g'` 177c9710b42Smrg 178c9710b42Smrgac_cv_stdint_result="(no helpful system typedefs seen)" 179c9710b42SmrgAX_CHECK_HEADER_STDINT_X(dnl 180c9710b42Smrg stdint.h inttypes.h sys/inttypes.h $inttype_headers, 181c9710b42Smrg ac_cv_stdint_result="(seen uintptr_t$and64 in $i)") 182c9710b42Smrg 183c9710b42Smrgif test "_$ac_cv_header_stdint_x" = "_" ; then 184c9710b42SmrgAX_CHECK_HEADER_STDINT_O(dnl, 185c9710b42Smrg inttypes.h sys/inttypes.h stdint.h $inttype_headers, 186c9710b42Smrg ac_cv_stdint_result="(seen uint32_t$and64 in $i)") 187c9710b42Smrgfi 188c9710b42Smrg 189c9710b42Smrgif test "_$ac_cv_header_stdint_x" = "_" ; then 190c9710b42Smrgif test "_$ac_cv_header_stdint_o" = "_" ; then 191c9710b42SmrgAX_CHECK_HEADER_STDINT_U(dnl, 192c9710b42Smrg sys/types.h inttypes.h sys/inttypes.h $inttype_headers, 193c9710b42Smrg ac_cv_stdint_result="(seen u_int32_t$and64 in $i)") 194c9710b42Smrgfi fi 195c9710b42Smrg 196c9710b42Smrgdnl if there was no good C99 header file, do some typedef checks... 197c9710b42Smrgif test "_$ac_cv_header_stdint_x" = "_" ; then 198c9710b42Smrg AC_MSG_CHECKING([for stdint datatype model]) 199c9710b42Smrg AC_MSG_RESULT([(..)]) 200c9710b42Smrg AX_CHECK_DATA_MODEL 201c9710b42Smrgfi 202c9710b42Smrg 203c9710b42Smrgif test "_$ac_cv_header_stdint_x" != "_" ; then 204c9710b42Smrg ac_cv_header_stdint="$ac_cv_header_stdint_x" 205c9710b42Smrgelif test "_$ac_cv_header_stdint_o" != "_" ; then 206c9710b42Smrg ac_cv_header_stdint="$ac_cv_header_stdint_o" 207c9710b42Smrgelif test "_$ac_cv_header_stdint_u" != "_" ; then 208c9710b42Smrg ac_cv_header_stdint="$ac_cv_header_stdint_u" 209c9710b42Smrgelse 210c9710b42Smrg ac_cv_header_stdint="stddef.h" 211c9710b42Smrgfi 212c9710b42Smrg 213c9710b42SmrgAC_MSG_CHECKING([for extra inttypes in chosen header]) 214c9710b42SmrgAC_MSG_RESULT([($ac_cv_header_stdint)]) 215c9710b42Smrgdnl see if int_least and int_fast types are present in _this_ header. 216c9710b42Smrgunset ac_cv_type_int_least32_t 217c9710b42Smrgunset ac_cv_type_int_fast32_t 218c9710b42SmrgAC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>]) 219c9710b42SmrgAC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>]) 220c9710b42SmrgAC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>]) 221c9710b42Smrg 222c9710b42Smrgfi # shortcircut to system "stdint.h" 223c9710b42Smrg# ------------------ PREPARE VARIABLES ------------------------------ 224c9710b42Smrgif test "$GCC" = "yes" ; then 225c9710b42Smrgac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` 226c9710b42Smrgelse 227c9710b42Smrgac_cv_stdint_message="using $CC" 228c9710b42Smrgfi 229c9710b42Smrg 230c9710b42SmrgAC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl 231c9710b42Smrg$ac_cv_stdint_result]) 232c9710b42Smrg 233c9710b42Smrgdnl ----------------------------------------------------------------- 234c9710b42Smrg# ----------------- DONE inttypes.h checks START header ------------- 235c9710b42SmrgAC_CONFIG_COMMANDS([$ac_stdint_h],[ 236c9710b42SmrgAC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h) 237c9710b42Smrgac_stdint=$tmp/_stdint.h 238c9710b42Smrg 239c9710b42Smrgecho "#ifndef" $_ac_stdint_h >$ac_stdint 240c9710b42Smrgecho "#define" $_ac_stdint_h "1" >>$ac_stdint 241c9710b42Smrgecho "#ifndef" _GENERATED_STDINT_H >>$ac_stdint 242c9710b42Smrgecho "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint 243c9710b42Smrgecho "/* generated $ac_cv_stdint_message */" >>$ac_stdint 244c9710b42Smrgif test "_$ac_cv_header_stdint_t" != "_" ; then 245c9710b42Smrgecho "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint 246c9710b42Smrgecho "#include <stdint.h>" >>$ac_stdint 247c9710b42Smrgecho "#endif" >>$ac_stdint 248c9710b42Smrgecho "#endif" >>$ac_stdint 249c9710b42Smrgelse 250c9710b42Smrg 251c9710b42Smrgcat >>$ac_stdint <<STDINT_EOF 252c9710b42Smrg 253c9710b42Smrg/* ................... shortcircuit part ........................... */ 254c9710b42Smrg 255c9710b42Smrg#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H 256c9710b42Smrg#include <stdint.h> 257c9710b42Smrg#else 258c9710b42Smrg#include <stddef.h> 259c9710b42Smrg 260c9710b42Smrg/* .................... configured part ............................ */ 261c9710b42Smrg 262c9710b42SmrgSTDINT_EOF 263c9710b42Smrg 264c9710b42Smrgecho "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint 265c9710b42Smrgif test "_$ac_cv_header_stdint_x" != "_" ; then 266c9710b42Smrg ac_header="$ac_cv_header_stdint_x" 267c9710b42Smrg echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint 268c9710b42Smrgelse 269c9710b42Smrg echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint 270c9710b42Smrgfi 271c9710b42Smrg 272c9710b42Smrgecho "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint 273c9710b42Smrgif test "_$ac_cv_header_stdint_o" != "_" ; then 274c9710b42Smrg ac_header="$ac_cv_header_stdint_o" 275c9710b42Smrg echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint 276c9710b42Smrgelse 277c9710b42Smrg echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint 278c9710b42Smrgfi 279c9710b42Smrg 280c9710b42Smrgecho "/* whether we have a BSD compatible inet types header */" >>$ac_stdint 281c9710b42Smrgif test "_$ac_cv_header_stdint_u" != "_" ; then 282c9710b42Smrg ac_header="$ac_cv_header_stdint_u" 283c9710b42Smrg echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint 284c9710b42Smrgelse 285c9710b42Smrg echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint 286c9710b42Smrgfi 287c9710b42Smrg 288c9710b42Smrgecho "" >>$ac_stdint 289c9710b42Smrg 290c9710b42Smrgif test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then 291c9710b42Smrg echo "#include <$ac_header>" >>$ac_stdint 292c9710b42Smrg echo "" >>$ac_stdint 293c9710b42Smrgfi fi 294c9710b42Smrg 295c9710b42Smrgecho "/* which 64bit typedef has been found */" >>$ac_stdint 296c9710b42Smrgif test "$ac_cv_type_uint64_t" = "yes" ; then 297c9710b42Smrgecho "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint 298c9710b42Smrgelse 299c9710b42Smrgecho "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint 300c9710b42Smrgfi 301c9710b42Smrgif test "$ac_cv_type_u_int64_t" = "yes" ; then 302c9710b42Smrgecho "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint 303c9710b42Smrgelse 304c9710b42Smrgecho "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint 305c9710b42Smrgfi 306c9710b42Smrgecho "" >>$ac_stdint 307c9710b42Smrg 308c9710b42Smrgecho "/* which type model has been detected */" >>$ac_stdint 309c9710b42Smrgif test "_$ac_cv_char_data_model" != "_" ; then 310c9710b42Smrgecho "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint 311c9710b42Smrgecho "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint 312c9710b42Smrgelse 313c9710b42Smrgecho "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint 314c9710b42Smrgecho "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint 315c9710b42Smrgfi 316c9710b42Smrgecho "" >>$ac_stdint 317c9710b42Smrg 318c9710b42Smrgecho "/* whether int_least types were detected */" >>$ac_stdint 319c9710b42Smrgif test "$ac_cv_type_int_least32_t" = "yes"; then 320c9710b42Smrgecho "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint 321c9710b42Smrgelse 322c9710b42Smrgecho "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint 323c9710b42Smrgfi 324c9710b42Smrgecho "/* whether int_fast types were detected */" >>$ac_stdint 325c9710b42Smrgif test "$ac_cv_type_int_fast32_t" = "yes"; then 326c9710b42Smrgecho "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint 327c9710b42Smrgelse 328c9710b42Smrgecho "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint 329c9710b42Smrgfi 330c9710b42Smrgecho "/* whether intmax_t type was detected */" >>$ac_stdint 331c9710b42Smrgif test "$ac_cv_type_intmax_t" = "yes"; then 332c9710b42Smrgecho "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint 333c9710b42Smrgelse 334c9710b42Smrgecho "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint 335c9710b42Smrgfi 336c9710b42Smrgecho "" >>$ac_stdint 337c9710b42Smrg 338c9710b42Smrg cat >>$ac_stdint <<STDINT_EOF 339c9710b42Smrg/* .................... detections part ............................ */ 340c9710b42Smrg 341c9710b42Smrg/* whether we need to define bitspecific types from compiler base types */ 342c9710b42Smrg#ifndef _STDINT_HEADER_INTPTR 343c9710b42Smrg#ifndef _STDINT_HEADER_UINT32 344c9710b42Smrg#ifndef _STDINT_HEADER_U_INT32 345c9710b42Smrg#define _STDINT_NEED_INT_MODEL_T 346c9710b42Smrg#else 347c9710b42Smrg#define _STDINT_HAVE_U_INT_TYPES 348c9710b42Smrg#endif 349c9710b42Smrg#endif 350c9710b42Smrg#endif 351c9710b42Smrg 352c9710b42Smrg#ifdef _STDINT_HAVE_U_INT_TYPES 353c9710b42Smrg#undef _STDINT_NEED_INT_MODEL_T 354c9710b42Smrg#endif 355c9710b42Smrg 356c9710b42Smrg#ifdef _STDINT_CHAR_MODEL 357c9710b42Smrg#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124 358c9710b42Smrg#ifndef _STDINT_BYTE_MODEL 359c9710b42Smrg#define _STDINT_BYTE_MODEL 12 360c9710b42Smrg#endif 361c9710b42Smrg#endif 362c9710b42Smrg#endif 363c9710b42Smrg 364c9710b42Smrg#ifndef _STDINT_HAVE_INT_LEAST32_T 365c9710b42Smrg#define _STDINT_NEED_INT_LEAST_T 366c9710b42Smrg#endif 367c9710b42Smrg 368c9710b42Smrg#ifndef _STDINT_HAVE_INT_FAST32_T 369c9710b42Smrg#define _STDINT_NEED_INT_FAST_T 370c9710b42Smrg#endif 371c9710b42Smrg 372c9710b42Smrg#ifndef _STDINT_HEADER_INTPTR 373c9710b42Smrg#define _STDINT_NEED_INTPTR_T 374c9710b42Smrg#ifndef _STDINT_HAVE_INTMAX_T 375c9710b42Smrg#define _STDINT_NEED_INTMAX_T 376c9710b42Smrg#endif 377c9710b42Smrg#endif 378c9710b42Smrg 379c9710b42Smrg 380c9710b42Smrg/* .................... definition part ............................ */ 381c9710b42Smrg 382c9710b42Smrg/* some system headers have good uint64_t */ 383c9710b42Smrg#ifndef _HAVE_UINT64_T 384c9710b42Smrg#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T 385c9710b42Smrg#define _HAVE_UINT64_T 386c9710b42Smrg#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T 387c9710b42Smrg#define _HAVE_UINT64_T 388c9710b42Smrgtypedef u_int64_t uint64_t; 389c9710b42Smrg#endif 390c9710b42Smrg#endif 391c9710b42Smrg 392c9710b42Smrg#ifndef _HAVE_UINT64_T 393c9710b42Smrg/* .. here are some common heuristics using compiler runtime specifics */ 394c9710b42Smrg#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L 395c9710b42Smrg#define _HAVE_UINT64_T 396c9710b42Smrg#define _HAVE_LONGLONG_UINT64_T 397c9710b42Smrgtypedef long long int64_t; 398c9710b42Smrgtypedef unsigned long long uint64_t; 399c9710b42Smrg 400c9710b42Smrg#elif !defined __STRICT_ANSI__ 401c9710b42Smrg#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ 402c9710b42Smrg#define _HAVE_UINT64_T 403c9710b42Smrgtypedef __int64 int64_t; 404c9710b42Smrgtypedef unsigned __int64 uint64_t; 405c9710b42Smrg 406c9710b42Smrg#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__ 407c9710b42Smrg/* note: all ELF-systems seem to have loff-support which needs 64-bit */ 408c9710b42Smrg#if !defined _NO_LONGLONG 409c9710b42Smrg#define _HAVE_UINT64_T 410c9710b42Smrg#define _HAVE_LONGLONG_UINT64_T 411c9710b42Smrgtypedef long long int64_t; 412c9710b42Smrgtypedef unsigned long long uint64_t; 413c9710b42Smrg#endif 414c9710b42Smrg 415c9710b42Smrg#elif defined __alpha || (defined __mips && defined _ABIN32) 416c9710b42Smrg#if !defined _NO_LONGLONG 417c9710b42Smrgtypedef long int64_t; 418c9710b42Smrgtypedef unsigned long uint64_t; 419c9710b42Smrg#endif 420c9710b42Smrg /* compiler/cpu type to define int64_t */ 421c9710b42Smrg#endif 422c9710b42Smrg#endif 423c9710b42Smrg#endif 424c9710b42Smrg 425c9710b42Smrg#if defined _STDINT_HAVE_U_INT_TYPES 426c9710b42Smrg/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */ 427c9710b42Smrgtypedef u_int8_t uint8_t; 428c9710b42Smrgtypedef u_int16_t uint16_t; 429c9710b42Smrgtypedef u_int32_t uint32_t; 430c9710b42Smrg 431c9710b42Smrg/* glibc compatibility */ 432c9710b42Smrg#ifndef __int8_t_defined 433c9710b42Smrg#define __int8_t_defined 434c9710b42Smrg#endif 435c9710b42Smrg#endif 436c9710b42Smrg 437c9710b42Smrg#ifdef _STDINT_NEED_INT_MODEL_T 438c9710b42Smrg/* we must guess all the basic types. Apart from byte-adressable system, */ 439c9710b42Smrg/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */ 440c9710b42Smrg/* (btw, those nibble-addressable systems are way off, or so we assume) */ 441c9710b42Smrg 442c9710b42Smrgdnl /* have a look at "64bit and data size neutrality" at */ 443c9710b42Smrgdnl /* http://unix.org/version2/whatsnew/login_64bit.html */ 444c9710b42Smrgdnl /* (the shorthand "ILP" types always have a "P" part) */ 445c9710b42Smrg 446c9710b42Smrg#if defined _STDINT_BYTE_MODEL 447c9710b42Smrg#if _STDINT_LONG_MODEL+0 == 242 448c9710b42Smrg/* 2:4:2 = IP16 = a normal 16-bit system */ 449c9710b42Smrgtypedef unsigned char uint8_t; 450c9710b42Smrgtypedef unsigned short uint16_t; 451c9710b42Smrgtypedef unsigned long uint32_t; 452c9710b42Smrg#ifndef __int8_t_defined 453c9710b42Smrg#define __int8_t_defined 454c9710b42Smrgtypedef char int8_t; 455c9710b42Smrgtypedef short int16_t; 456c9710b42Smrgtypedef long int32_t; 457c9710b42Smrg#endif 458c9710b42Smrg#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444 459c9710b42Smrg/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */ 460c9710b42Smrg/* 4:4:4 = ILP32 = a normal 32-bit system */ 461c9710b42Smrgtypedef unsigned char uint8_t; 462c9710b42Smrgtypedef unsigned short uint16_t; 463c9710b42Smrgtypedef unsigned int uint32_t; 464c9710b42Smrg#ifndef __int8_t_defined 465c9710b42Smrg#define __int8_t_defined 466c9710b42Smrgtypedef char int8_t; 467c9710b42Smrgtypedef short int16_t; 468c9710b42Smrgtypedef int int32_t; 469c9710b42Smrg#endif 470c9710b42Smrg#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488 471c9710b42Smrg/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */ 472c9710b42Smrg/* 4:8:8 = LP64 = a normal 64-bit system */ 473c9710b42Smrgtypedef unsigned char uint8_t; 474c9710b42Smrgtypedef unsigned short uint16_t; 475c9710b42Smrgtypedef unsigned int uint32_t; 476c9710b42Smrg#ifndef __int8_t_defined 477c9710b42Smrg#define __int8_t_defined 478c9710b42Smrgtypedef char int8_t; 479c9710b42Smrgtypedef short int16_t; 480c9710b42Smrgtypedef int int32_t; 481c9710b42Smrg#endif 482c9710b42Smrg/* this system has a "long" of 64bit */ 483c9710b42Smrg#ifndef _HAVE_UINT64_T 484c9710b42Smrg#define _HAVE_UINT64_T 485c9710b42Smrgtypedef unsigned long uint64_t; 486c9710b42Smrgtypedef long int64_t; 487c9710b42Smrg#endif 488c9710b42Smrg#elif _STDINT_LONG_MODEL+0 == 448 489c9710b42Smrg/* LLP64 a 64-bit system derived from a 32-bit system */ 490c9710b42Smrgtypedef unsigned char uint8_t; 491c9710b42Smrgtypedef unsigned short uint16_t; 492c9710b42Smrgtypedef unsigned int uint32_t; 493c9710b42Smrg#ifndef __int8_t_defined 494c9710b42Smrg#define __int8_t_defined 495c9710b42Smrgtypedef char int8_t; 496c9710b42Smrgtypedef short int16_t; 497c9710b42Smrgtypedef int int32_t; 498c9710b42Smrg#endif 499c9710b42Smrg/* assuming the system has a "long long" */ 500c9710b42Smrg#ifndef _HAVE_UINT64_T 501c9710b42Smrg#define _HAVE_UINT64_T 502c9710b42Smrg#define _HAVE_LONGLONG_UINT64_T 503c9710b42Smrgtypedef unsigned long long uint64_t; 504c9710b42Smrgtypedef long long int64_t; 505c9710b42Smrg#endif 506c9710b42Smrg#else 507c9710b42Smrg#define _STDINT_NO_INT32_T 508c9710b42Smrg#endif 509c9710b42Smrg#else 510c9710b42Smrg#define _STDINT_NO_INT8_T 511c9710b42Smrg#define _STDINT_NO_INT32_T 512c9710b42Smrg#endif 513c9710b42Smrg#endif 514c9710b42Smrg 515c9710b42Smrg/* 516c9710b42Smrg * quote from SunOS-5.8 sys/inttypes.h: 517c9710b42Smrg * Use at your own risk. As of February 1996, the committee is squarely 518c9710b42Smrg * behind the fixed sized types; the "least" and "fast" types are still being 519c9710b42Smrg * discussed. The probability that the "fast" types may be removed before 520c9710b42Smrg * the standard is finalized is high enough that they are not currently 521c9710b42Smrg * implemented. 522c9710b42Smrg */ 523c9710b42Smrg 524c9710b42Smrg#if defined _STDINT_NEED_INT_LEAST_T 525c9710b42Smrgtypedef int8_t int_least8_t; 526c9710b42Smrgtypedef int16_t int_least16_t; 527c9710b42Smrgtypedef int32_t int_least32_t; 528c9710b42Smrg#ifdef _HAVE_UINT64_T 529c9710b42Smrgtypedef int64_t int_least64_t; 530c9710b42Smrg#endif 531c9710b42Smrg 532c9710b42Smrgtypedef uint8_t uint_least8_t; 533c9710b42Smrgtypedef uint16_t uint_least16_t; 534c9710b42Smrgtypedef uint32_t uint_least32_t; 535c9710b42Smrg#ifdef _HAVE_UINT64_T 536c9710b42Smrgtypedef uint64_t uint_least64_t; 537c9710b42Smrg#endif 538c9710b42Smrg /* least types */ 539c9710b42Smrg#endif 540c9710b42Smrg 541c9710b42Smrg#if defined _STDINT_NEED_INT_FAST_T 542c9710b42Smrgtypedef int8_t int_fast8_t; 543c9710b42Smrgtypedef int int_fast16_t; 544c9710b42Smrgtypedef int32_t int_fast32_t; 545c9710b42Smrg#ifdef _HAVE_UINT64_T 546c9710b42Smrgtypedef int64_t int_fast64_t; 547c9710b42Smrg#endif 548c9710b42Smrg 549c9710b42Smrgtypedef uint8_t uint_fast8_t; 550c9710b42Smrgtypedef unsigned uint_fast16_t; 551c9710b42Smrgtypedef uint32_t uint_fast32_t; 552c9710b42Smrg#ifdef _HAVE_UINT64_T 553c9710b42Smrgtypedef uint64_t uint_fast64_t; 554c9710b42Smrg#endif 555c9710b42Smrg /* fast types */ 556c9710b42Smrg#endif 557c9710b42Smrg 558c9710b42Smrg#ifdef _STDINT_NEED_INTMAX_T 559c9710b42Smrg#ifdef _HAVE_UINT64_T 560c9710b42Smrgtypedef int64_t intmax_t; 561c9710b42Smrgtypedef uint64_t uintmax_t; 562c9710b42Smrg#else 563c9710b42Smrgtypedef long intmax_t; 564c9710b42Smrgtypedef unsigned long uintmax_t; 565c9710b42Smrg#endif 566c9710b42Smrg#endif 567c9710b42Smrg 568c9710b42Smrg#ifdef _STDINT_NEED_INTPTR_T 569c9710b42Smrg#ifndef __intptr_t_defined 570c9710b42Smrg#define __intptr_t_defined 571c9710b42Smrg/* we encourage using "long" to store pointer values, never use "int" ! */ 572c9710b42Smrg#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484 573c9710b42Smrgtypedef unsigned int uintptr_t; 574c9710b42Smrgtypedef int intptr_t; 575c9710b42Smrg#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444 576c9710b42Smrgtypedef unsigned long uintptr_t; 577c9710b42Smrgtypedef long intptr_t; 578c9710b42Smrg#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T 579c9710b42Smrgtypedef uint64_t uintptr_t; 580c9710b42Smrgtypedef int64_t intptr_t; 581c9710b42Smrg#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */ 582c9710b42Smrgtypedef unsigned long uintptr_t; 583c9710b42Smrgtypedef long intptr_t; 584c9710b42Smrg#endif 585c9710b42Smrg#endif 586c9710b42Smrg#endif 587c9710b42Smrg 588c9710b42Smrg/* The ISO C99 standard specifies that in C++ implementations these 589c9710b42Smrg should only be defined if explicitly requested. */ 590c9710b42Smrg#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS 591c9710b42Smrg#ifndef UINT32_C 592c9710b42Smrg 593c9710b42Smrg/* Signed. */ 594c9710b42Smrg# define INT8_C(c) c 595c9710b42Smrg# define INT16_C(c) c 596c9710b42Smrg# define INT32_C(c) c 597c9710b42Smrg# ifdef _HAVE_LONGLONG_UINT64_T 598c9710b42Smrg# define INT64_C(c) c ## L 599c9710b42Smrg# else 600c9710b42Smrg# define INT64_C(c) c ## LL 601c9710b42Smrg# endif 602c9710b42Smrg 603c9710b42Smrg/* Unsigned. */ 604c9710b42Smrg# define UINT8_C(c) c ## U 605c9710b42Smrg# define UINT16_C(c) c ## U 606c9710b42Smrg# define UINT32_C(c) c ## U 607c9710b42Smrg# ifdef _HAVE_LONGLONG_UINT64_T 608c9710b42Smrg# define UINT64_C(c) c ## UL 609c9710b42Smrg# else 610c9710b42Smrg# define UINT64_C(c) c ## ULL 611c9710b42Smrg# endif 612c9710b42Smrg 613c9710b42Smrg/* Maximal type. */ 614c9710b42Smrg# ifdef _HAVE_LONGLONG_UINT64_T 615c9710b42Smrg# define INTMAX_C(c) c ## L 616c9710b42Smrg# define UINTMAX_C(c) c ## UL 617c9710b42Smrg# else 618c9710b42Smrg# define INTMAX_C(c) c ## LL 619c9710b42Smrg# define UINTMAX_C(c) c ## ULL 620c9710b42Smrg# endif 621c9710b42Smrg 622c9710b42Smrg /* literalnumbers */ 623c9710b42Smrg#endif 624c9710b42Smrg#endif 625c9710b42Smrg 626c9710b42Smrg/* These limits are merily those of a two complement byte-oriented system */ 627c9710b42Smrg 628c9710b42Smrg/* Minimum of signed integral types. */ 629c9710b42Smrg# define INT8_MIN (-128) 630c9710b42Smrg# define INT16_MIN (-32767-1) 631c9710b42Smrg# define INT32_MIN (-2147483647-1) 632c9710b42Smrg# define INT64_MIN (-__INT64_C(9223372036854775807)-1) 633c9710b42Smrg/* Maximum of signed integral types. */ 634c9710b42Smrg# define INT8_MAX (127) 635c9710b42Smrg# define INT16_MAX (32767) 636c9710b42Smrg# define INT32_MAX (2147483647) 637c9710b42Smrg# define INT64_MAX (__INT64_C(9223372036854775807)) 638c9710b42Smrg 639c9710b42Smrg/* Maximum of unsigned integral types. */ 640c9710b42Smrg# define UINT8_MAX (255) 641c9710b42Smrg# define UINT16_MAX (65535) 642c9710b42Smrg# define UINT32_MAX (4294967295U) 643c9710b42Smrg# define UINT64_MAX (__UINT64_C(18446744073709551615)) 644c9710b42Smrg 645c9710b42Smrg/* Minimum of signed integral types having a minimum size. */ 646c9710b42Smrg# define INT_LEAST8_MIN INT8_MIN 647c9710b42Smrg# define INT_LEAST16_MIN INT16_MIN 648c9710b42Smrg# define INT_LEAST32_MIN INT32_MIN 649c9710b42Smrg# define INT_LEAST64_MIN INT64_MIN 650c9710b42Smrg/* Maximum of signed integral types having a minimum size. */ 651c9710b42Smrg# define INT_LEAST8_MAX INT8_MAX 652c9710b42Smrg# define INT_LEAST16_MAX INT16_MAX 653c9710b42Smrg# define INT_LEAST32_MAX INT32_MAX 654c9710b42Smrg# define INT_LEAST64_MAX INT64_MAX 655c9710b42Smrg 656c9710b42Smrg/* Maximum of unsigned integral types having a minimum size. */ 657c9710b42Smrg# define UINT_LEAST8_MAX UINT8_MAX 658c9710b42Smrg# define UINT_LEAST16_MAX UINT16_MAX 659c9710b42Smrg# define UINT_LEAST32_MAX UINT32_MAX 660c9710b42Smrg# define UINT_LEAST64_MAX UINT64_MAX 661c9710b42Smrg 662c9710b42Smrg /* shortcircuit*/ 663c9710b42Smrg#endif 664c9710b42Smrg /* once */ 665c9710b42Smrg#endif 666c9710b42Smrg#endif 667c9710b42SmrgSTDINT_EOF 668c9710b42Smrgfi 669c9710b42Smrg if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then 670c9710b42Smrg AC_MSG_NOTICE([$ac_stdint_h is unchanged]) 671c9710b42Smrg else 672c9710b42Smrg ac_dir=`AS_DIRNAME(["$ac_stdint_h"])` 673c9710b42Smrg AS_MKDIR_P(["$ac_dir"]) 674c9710b42Smrg rm -f $ac_stdint_h 675c9710b42Smrg mv $ac_stdint $ac_stdint_h 676c9710b42Smrg fi 677c9710b42Smrg],[# variables for create stdint.h replacement 678c9710b42SmrgPACKAGE="$PACKAGE" 679c9710b42SmrgVERSION="$VERSION" 680c9710b42Smrgac_stdint_h="$ac_stdint_h" 681c9710b42Smrg_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h) 682c9710b42Smrgac_cv_stdint_message="$ac_cv_stdint_message" 683c9710b42Smrgac_cv_header_stdint_t="$ac_cv_header_stdint_t" 684c9710b42Smrgac_cv_header_stdint_x="$ac_cv_header_stdint_x" 685c9710b42Smrgac_cv_header_stdint_o="$ac_cv_header_stdint_o" 686c9710b42Smrgac_cv_header_stdint_u="$ac_cv_header_stdint_u" 687c9710b42Smrgac_cv_type_uint64_t="$ac_cv_type_uint64_t" 688c9710b42Smrgac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" 689c9710b42Smrgac_cv_char_data_model="$ac_cv_char_data_model" 690c9710b42Smrgac_cv_long_data_model="$ac_cv_long_data_model" 691c9710b42Smrgac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" 692c9710b42Smrgac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" 693c9710b42Smrgac_cv_type_intmax_t="$ac_cv_type_intmax_t" 694c9710b42Smrg]) 695c9710b42Smrg]) 696