1*3d8817e4Smioddnl @synopsis GCC_HEADER_STDINT [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])] 2*3d8817e4Smioddnl 3*3d8817e4Smioddnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the 4*3d8817e4Smioddnl existence of an include file <stdint.h> that defines a set of 5*3d8817e4Smioddnl typedefs, especially uint8_t,int32_t,uintptr_t. 6*3d8817e4Smioddnl Many older installations will not provide this file, but some will 7*3d8817e4Smioddnl have the very same definitions in <inttypes.h>. In other enviroments 8*3d8817e4Smioddnl we can use the inet-types in <sys/types.h> which would define the 9*3d8817e4Smioddnl typedefs int8_t and u_int8_t respectivly. 10*3d8817e4Smioddnl 11*3d8817e4Smioddnl This macros will create a local "_stdint.h" or the headerfile given as 12*3d8817e4Smioddnl an argument. In many cases that file will pick the definition from a 13*3d8817e4Smioddnl "#include <stdint.h>" or "#include <inttypes.h>" statement, while 14*3d8817e4Smioddnl in other environments it will provide the set of basic 'stdint's defined: 15*3d8817e4Smioddnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t 16*3d8817e4Smioddnl int_least32_t.. int_fast32_t.. intmax_t 17*3d8817e4Smioddnl which may or may not rely on the definitions of other files. 18*3d8817e4Smioddnl 19*3d8817e4Smioddnl Sometimes the stdint.h or inttypes.h headers conflict with sys/types.h, 20*3d8817e4Smioddnl so we test the headers together with sys/types.h and always include it 21*3d8817e4Smioddnl into the generated header (to match the tests with the generated file). 22*3d8817e4Smioddnl Hopefully this is not a big annoyance. 23*3d8817e4Smioddnl 24*3d8817e4Smioddnl If your installed header files require the stdint-types you will want to 25*3d8817e4Smioddnl create an installable file mylib-int.h that all your other installable 26*3d8817e4Smioddnl header may include. So, for a library package named "mylib", just use 27*3d8817e4Smioddnl GCC_HEADER_STDINT(mylib-int.h) 28*3d8817e4Smioddnl in configure.in and install that header file in Makefile.am along with 29*3d8817e4Smioddnl the other headers (mylib.h). The mylib-specific headers can simply 30*3d8817e4Smioddnl use "#include <mylib-int.h>" to obtain the stdint-types. 31*3d8817e4Smioddnl 32*3d8817e4Smioddnl Remember, if the system already had a valid <stdint.h>, the generated 33*3d8817e4Smioddnl file will include it directly. No need for fuzzy HAVE_STDINT_H things... 34*3d8817e4Smioddnl 35*3d8817e4Smioddnl @author Guido Draheim <guidod@gmx.de>, Paolo Bonzini <bonzini@gnu.org> 36*3d8817e4Smiod 37*3d8817e4SmiodAC_DEFUN([GCC_HEADER_STDINT], 38*3d8817e4Smiod[m4_define(_GCC_STDINT_H, m4_ifval($1, $1, _stdint.h)) 39*3d8817e4Smiod 40*3d8817e4Smiodinttype_headers=`echo inttypes.h sys/inttypes.h $2 | sed -e 's/,/ /g'` 41*3d8817e4Smiod 42*3d8817e4Smiodacx_cv_header_stdint=stddef.h 43*3d8817e4Smiodacx_cv_header_stdint_kind="(already complete)" 44*3d8817e4Smiodfor i in stdint.h $inttype_headers; do 45*3d8817e4Smiod unset ac_cv_type_uintptr_t 46*3d8817e4Smiod unset ac_cv_type_uintmax_t 47*3d8817e4Smiod unset ac_cv_type_int_least32_t 48*3d8817e4Smiod unset ac_cv_type_int_fast32_t 49*3d8817e4Smiod unset ac_cv_type_uint64_t 50*3d8817e4Smiod _AS_ECHO_N([looking for a compliant stdint.h in $i, ]) 51*3d8817e4Smiod AC_CHECK_TYPE(uintmax_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 52*3d8817e4Smiod#include <$i>]) 53*3d8817e4Smiod AC_CHECK_TYPE(uintptr_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 54*3d8817e4Smiod#include <$i>]) 55*3d8817e4Smiod AC_CHECK_TYPE(int_least32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 56*3d8817e4Smiod#include <$i>]) 57*3d8817e4Smiod AC_CHECK_TYPE(int_fast32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 58*3d8817e4Smiod#include <$i>]) 59*3d8817e4Smiod AC_CHECK_TYPE(uint64_t,,[acx_cv_header_stdint_kind="(lacks uint64_t)"], [#include <sys/types.h> 60*3d8817e4Smiod#include <$i>]) 61*3d8817e4Smiod break 62*3d8817e4Smioddone 63*3d8817e4Smiodif test "$acx_cv_header_stdint" = stddef.h; then 64*3d8817e4Smiod acx_cv_header_stdint_kind="(lacks uintptr_t)" 65*3d8817e4Smiod for i in stdint.h $inttype_headers; do 66*3d8817e4Smiod unset ac_cv_type_uint32_t 67*3d8817e4Smiod unset ac_cv_type_uint64_t 68*3d8817e4Smiod _AS_ECHO_N([looking for an incomplete stdint.h in $i, ]) 69*3d8817e4Smiod AC_CHECK_TYPE(uint32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 70*3d8817e4Smiod#include <$i>]) 71*3d8817e4Smiod AC_CHECK_TYPE(uint64_t,,[acx_cv_header_stdint_kind="(lacks uintptr_t and uint64_t)"], [#include <sys/types.h> 72*3d8817e4Smiod#include <$i>]) 73*3d8817e4Smiod break 74*3d8817e4Smiod done 75*3d8817e4Smiodfi 76*3d8817e4Smiodif test "$acx_cv_header_stdint" = stddef.h; then 77*3d8817e4Smiod acx_cv_header_stdint_kind="(u_intXX_t style)" 78*3d8817e4Smiod for i in sys/types.h $inttype_headers; do 79*3d8817e4Smiod unset ac_cv_type_u_int32_t 80*3d8817e4Smiod unset ac_cv_type_u_int64_t 81*3d8817e4Smiod _AS_ECHO_N([looking for u_intXX_t types in $i, ]) 82*3d8817e4Smiod AC_CHECK_TYPE(u_int32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 83*3d8817e4Smiod#include <$i>]) 84*3d8817e4Smiod AC_CHECK_TYPE(u_int64_t,,[acx_cv_header_stdint_kind="(u_intXX_t style, lacks u_int64_t)"], [#include <sys/types.h> 85*3d8817e4Smiod#include <$i>]) 86*3d8817e4Smiod break 87*3d8817e4Smiod done 88*3d8817e4Smiodfi 89*3d8817e4Smiodif test "$acx_cv_header_stdint" = stddef.h; then 90*3d8817e4Smiod acx_cv_header_stdint_kind="(using manual detection)" 91*3d8817e4Smiodfi 92*3d8817e4Smiod 93*3d8817e4Smiodtest -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no 94*3d8817e4Smiodtest -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no 95*3d8817e4Smiodtest -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no 96*3d8817e4Smiodtest -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no 97*3d8817e4Smiodtest -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no 98*3d8817e4Smiod 99*3d8817e4Smiod# ----------------- Summarize what we found so far 100*3d8817e4Smiod 101*3d8817e4SmiodAC_MSG_CHECKING([what to include in _GCC_STDINT_H]) 102*3d8817e4Smiod 103*3d8817e4Smiodcase `AS_BASENAME(_GCC_STDINT_H)` in 104*3d8817e4Smiod stdint.h) AC_MSG_WARN([are you sure you want it there?]) ;; 105*3d8817e4Smiod inttypes.h) AC_MSG_WARN([are you sure you want it there?]) ;; 106*3d8817e4Smiod *) ;; 107*3d8817e4Smiodesac 108*3d8817e4Smiod 109*3d8817e4SmiodAC_MSG_RESULT($acx_cv_header_stdint $acx_cv_header_stdint_kind) 110*3d8817e4Smiod 111*3d8817e4Smiod# ----------------- done included file, check C basic types -------- 112*3d8817e4Smiod 113*3d8817e4Smiod# Lacking an uintptr_t? Test size of void * 114*3d8817e4Smiodcase "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in 115*3d8817e4Smiod stddef.h:* | *:no) AC_CHECK_SIZEOF(void *) ;; 116*3d8817e4Smiodesac 117*3d8817e4Smiod 118*3d8817e4Smiod# Lacking an uint64_t? Test size of long 119*3d8817e4Smiodcase "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in 120*3d8817e4Smiod stddef.h:*:* | *:no:no) AC_CHECK_SIZEOF(long) ;; 121*3d8817e4Smiodesac 122*3d8817e4Smiod 123*3d8817e4Smiodif test $acx_cv_header_stdint = stddef.h; then 124*3d8817e4Smiod # Lacking a good header? Test size of everything and deduce all types. 125*3d8817e4Smiod AC_CHECK_SIZEOF(int) 126*3d8817e4Smiod AC_CHECK_SIZEOF(short) 127*3d8817e4Smiod AC_CHECK_SIZEOF(char) 128*3d8817e4Smiod 129*3d8817e4Smiod AC_MSG_CHECKING(for type equivalent to int8_t) 130*3d8817e4Smiod case "$ac_cv_sizeof_char" in 131*3d8817e4Smiod 1) acx_cv_type_int8_t=char ;; 132*3d8817e4Smiod *) AC_MSG_ERROR(no 8-bit type, please report a bug) 133*3d8817e4Smiod esac 134*3d8817e4Smiod AC_MSG_RESULT($acx_cv_type_int8_t) 135*3d8817e4Smiod 136*3d8817e4Smiod AC_MSG_CHECKING(for type equivalent to int16_t) 137*3d8817e4Smiod case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in 138*3d8817e4Smiod 2:*) acx_cv_type_int16_t=int ;; 139*3d8817e4Smiod *:2) acx_cv_type_int16_t=short ;; 140*3d8817e4Smiod *) AC_MSG_ERROR(no 16-bit type, please report a bug) 141*3d8817e4Smiod esac 142*3d8817e4Smiod AC_MSG_RESULT($acx_cv_type_int16_t) 143*3d8817e4Smiod 144*3d8817e4Smiod AC_MSG_CHECKING(for type equivalent to int32_t) 145*3d8817e4Smiod case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in 146*3d8817e4Smiod 4:*) acx_cv_type_int32_t=int ;; 147*3d8817e4Smiod *:4) acx_cv_type_int32_t=long ;; 148*3d8817e4Smiod *) AC_MSG_ERROR(no 32-bit type, please report a bug) 149*3d8817e4Smiod esac 150*3d8817e4Smiod AC_MSG_RESULT($acx_cv_type_int32_t) 151*3d8817e4Smiodfi 152*3d8817e4Smiod 153*3d8817e4Smiod# These tests are here to make the output prettier 154*3d8817e4Smiod 155*3d8817e4Smiodif test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then 156*3d8817e4Smiod case "$ac_cv_sizeof_long" in 157*3d8817e4Smiod 8) acx_cv_type_int64_t=long ;; 158*3d8817e4Smiod esac 159*3d8817e4Smiod AC_MSG_CHECKING(for type equivalent to int64_t) 160*3d8817e4Smiod AC_MSG_RESULT(${acx_cv_type_int64_t-'using preprocessor symbols'}) 161*3d8817e4Smiodfi 162*3d8817e4Smiod 163*3d8817e4Smiod# Now we can use the above types 164*3d8817e4Smiod 165*3d8817e4Smiodif test "$ac_cv_type_uintptr_t" != yes; then 166*3d8817e4Smiod AC_MSG_CHECKING(for type equivalent to intptr_t) 167*3d8817e4Smiod case $ac_cv_sizeof_void_p in 168*3d8817e4Smiod 2) acx_cv_type_intptr_t=int16_t ;; 169*3d8817e4Smiod 4) acx_cv_type_intptr_t=int32_t ;; 170*3d8817e4Smiod 8) acx_cv_type_intptr_t=int64_t ;; 171*3d8817e4Smiod *) AC_MSG_ERROR(no equivalent for intptr_t, please report a bug) 172*3d8817e4Smiod esac 173*3d8817e4Smiod AC_MSG_RESULT($acx_cv_type_intptr_t) 174*3d8817e4Smiodfi 175*3d8817e4Smiod 176*3d8817e4Smiod# ----------------- done all checks, emit header ------------- 177*3d8817e4SmiodAC_CONFIG_COMMANDS(_GCC_STDINT_H, [ 178*3d8817e4Smiodif test "$GCC" = yes; then 179*3d8817e4Smiod echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h 180*3d8817e4Smiodelse 181*3d8817e4Smiod echo "/* generated for $CC */" > tmp-stdint.h 182*3d8817e4Smiodfi 183*3d8817e4Smiod 184*3d8817e4Smiodsed 's/^ *//' >> tmp-stdint.h <<EOF 185*3d8817e4Smiod 186*3d8817e4Smiod #ifndef GCC_GENERATED_STDINT_H 187*3d8817e4Smiod #define GCC_GENERATED_STDINT_H 1 188*3d8817e4Smiod 189*3d8817e4Smiod #include <sys/types.h> 190*3d8817e4SmiodEOF 191*3d8817e4Smiod 192*3d8817e4Smiodif test "$acx_cv_header_stdint" != stdint.h; then 193*3d8817e4Smiod echo "#include <stddef.h>" >> tmp-stdint.h 194*3d8817e4Smiodfi 195*3d8817e4Smiodif test "$acx_cv_header_stdint" != stddef.h; then 196*3d8817e4Smiod echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h 197*3d8817e4Smiodfi 198*3d8817e4Smiod 199*3d8817e4Smiodsed 's/^ *//' >> tmp-stdint.h <<EOF 200*3d8817e4Smiod /* glibc uses these symbols as guards to prevent redefinitions. */ 201*3d8817e4Smiod #ifdef __int8_t_defined 202*3d8817e4Smiod #define _INT8_T 203*3d8817e4Smiod #define _INT16_T 204*3d8817e4Smiod #define _INT32_T 205*3d8817e4Smiod #endif 206*3d8817e4Smiod #ifdef __uint32_t_defined 207*3d8817e4Smiod #define _UINT32_T 208*3d8817e4Smiod #endif 209*3d8817e4Smiod 210*3d8817e4SmiodEOF 211*3d8817e4Smiod 212*3d8817e4Smiod# ----------------- done header, emit basic int types ------------- 213*3d8817e4Smiodif test "$acx_cv_header_stdint" = stddef.h; then 214*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 215*3d8817e4Smiod 216*3d8817e4Smiod #ifndef _UINT8_T 217*3d8817e4Smiod #define _UINT8_T 218*3d8817e4Smiod typedef unsigned $acx_cv_type_int8_t uint8_t; 219*3d8817e4Smiod #endif 220*3d8817e4Smiod 221*3d8817e4Smiod #ifndef _UINT16_T 222*3d8817e4Smiod #define _UINT16_T 223*3d8817e4Smiod typedef unsigned $acx_cv_type_int16_t uint16_t; 224*3d8817e4Smiod #endif 225*3d8817e4Smiod 226*3d8817e4Smiod #ifndef _UINT32_T 227*3d8817e4Smiod #define _UINT32_T 228*3d8817e4Smiod typedef unsigned $acx_cv_type_int32_t uint32_t; 229*3d8817e4Smiod #endif 230*3d8817e4Smiod 231*3d8817e4Smiod #ifndef _INT8_T 232*3d8817e4Smiod #define _INT8_T 233*3d8817e4Smiod typedef $acx_cv_type_int8_t int8_t; 234*3d8817e4Smiod #endif 235*3d8817e4Smiod 236*3d8817e4Smiod #ifndef _INT16_T 237*3d8817e4Smiod #define _INT16_T 238*3d8817e4Smiod typedef $acx_cv_type_int16_t int16_t; 239*3d8817e4Smiod #endif 240*3d8817e4Smiod 241*3d8817e4Smiod #ifndef _INT32_T 242*3d8817e4Smiod #define _INT32_T 243*3d8817e4Smiod typedef $acx_cv_type_int32_t int32_t; 244*3d8817e4Smiod #endif 245*3d8817e4SmiodEOF 246*3d8817e4Smiodelif test "$ac_cv_type_u_int32_t" = yes; then 247*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 248*3d8817e4Smiod 249*3d8817e4Smiod /* int8_t int16_t int32_t defined by inet code, we do the u_intXX types */ 250*3d8817e4Smiod #ifndef _INT8_T 251*3d8817e4Smiod #define _INT8_T 252*3d8817e4Smiod #endif 253*3d8817e4Smiod #ifndef _INT16_T 254*3d8817e4Smiod #define _INT16_T 255*3d8817e4Smiod #endif 256*3d8817e4Smiod #ifndef _INT32_T 257*3d8817e4Smiod #define _INT32_T 258*3d8817e4Smiod #endif 259*3d8817e4Smiod 260*3d8817e4Smiod #ifndef _UINT8_T 261*3d8817e4Smiod #define _UINT8_T 262*3d8817e4Smiod typedef u_int8_t uint8_t; 263*3d8817e4Smiod #endif 264*3d8817e4Smiod 265*3d8817e4Smiod #ifndef _UINT16_T 266*3d8817e4Smiod #define _UINT16_T 267*3d8817e4Smiod typedef u_int16_t uint16_t; 268*3d8817e4Smiod #endif 269*3d8817e4Smiod 270*3d8817e4Smiod #ifndef _UINT32_T 271*3d8817e4Smiod #define _UINT32_T 272*3d8817e4Smiod typedef u_int32_t uint32_t; 273*3d8817e4Smiod #endif 274*3d8817e4SmiodEOF 275*3d8817e4Smiodelse 276*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 277*3d8817e4Smiod 278*3d8817e4Smiod /* Some systems have guard macros to prevent redefinitions, define them. */ 279*3d8817e4Smiod #ifndef _INT8_T 280*3d8817e4Smiod #define _INT8_T 281*3d8817e4Smiod #endif 282*3d8817e4Smiod #ifndef _INT16_T 283*3d8817e4Smiod #define _INT16_T 284*3d8817e4Smiod #endif 285*3d8817e4Smiod #ifndef _INT32_T 286*3d8817e4Smiod #define _INT32_T 287*3d8817e4Smiod #endif 288*3d8817e4Smiod #ifndef _UINT8_T 289*3d8817e4Smiod #define _UINT8_T 290*3d8817e4Smiod #endif 291*3d8817e4Smiod #ifndef _UINT16_T 292*3d8817e4Smiod #define _UINT16_T 293*3d8817e4Smiod #endif 294*3d8817e4Smiod #ifndef _UINT32_T 295*3d8817e4Smiod #define _UINT32_T 296*3d8817e4Smiod #endif 297*3d8817e4SmiodEOF 298*3d8817e4Smiodfi 299*3d8817e4Smiod 300*3d8817e4Smiod# ------------- done basic int types, emit int64_t types ------------ 301*3d8817e4Smiodif test "$ac_cv_type_uint64_t" = yes; then 302*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 303*3d8817e4Smiod 304*3d8817e4Smiod /* system headers have good uint64_t and int64_t */ 305*3d8817e4Smiod #ifndef _INT64_T 306*3d8817e4Smiod #define _INT64_T 307*3d8817e4Smiod #endif 308*3d8817e4Smiod #ifndef _UINT64_T 309*3d8817e4Smiod #define _UINT64_T 310*3d8817e4Smiod #endif 311*3d8817e4SmiodEOF 312*3d8817e4Smiodelif test "$ac_cv_type_u_int64_t" = yes; then 313*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 314*3d8817e4Smiod 315*3d8817e4Smiod /* system headers have an u_int64_t (and int64_t) */ 316*3d8817e4Smiod #ifndef _INT64_T 317*3d8817e4Smiod #define _INT64_T 318*3d8817e4Smiod #endif 319*3d8817e4Smiod #ifndef _UINT64_T 320*3d8817e4Smiod #define _UINT64_T 321*3d8817e4Smiod typedef u_int64_t uint64_t; 322*3d8817e4Smiod #endif 323*3d8817e4SmiodEOF 324*3d8817e4Smiodelif test -n "$acx_cv_type_int64_t"; then 325*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 326*3d8817e4Smiod 327*3d8817e4Smiod /* architecture has a 64-bit type, $acx_cv_type_int64_t */ 328*3d8817e4Smiod #ifndef _INT64_T 329*3d8817e4Smiod #define _INT64_T 330*3d8817e4Smiod typedef $acx_cv_type_int64_t int64_t; 331*3d8817e4Smiod #endif 332*3d8817e4Smiod #ifndef _UINT64_T 333*3d8817e4Smiod #define _UINT64_T 334*3d8817e4Smiod typedef unsigned $acx_cv_type_int64_t uint64_t; 335*3d8817e4Smiod #endif 336*3d8817e4SmiodEOF 337*3d8817e4Smiodelse 338*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 339*3d8817e4Smiod 340*3d8817e4Smiod /* some common heuristics for int64_t, using compiler-specific tests */ 341*3d8817e4Smiod #if defined __STDC_VERSION__ && (__STDC_VERSION__-0) >= 199901L 342*3d8817e4Smiod #ifndef _INT64_T 343*3d8817e4Smiod #define _INT64_T 344*3d8817e4Smiod typedef long long int64_t; 345*3d8817e4Smiod #endif 346*3d8817e4Smiod #ifndef _UINT64_T 347*3d8817e4Smiod #define _UINT64_T 348*3d8817e4Smiod typedef unsigned long long uint64_t; 349*3d8817e4Smiod #endif 350*3d8817e4Smiod 351*3d8817e4Smiod #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0 352*3d8817e4Smiod /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and 353*3d8817e4Smiod does not implement __extension__. But that compiler doesn't define 354*3d8817e4Smiod __GNUC_MINOR__. */ 355*3d8817e4Smiod # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) 356*3d8817e4Smiod # define __extension__ 357*3d8817e4Smiod # endif 358*3d8817e4Smiod 359*3d8817e4Smiod # ifndef _INT64_T 360*3d8817e4Smiod # define _INT64_T 361*3d8817e4Smiod __extension__ typedef long long int64_t; 362*3d8817e4Smiod # endif 363*3d8817e4Smiod # ifndef _UINT64_T 364*3d8817e4Smiod # define _UINT64_T 365*3d8817e4Smiod __extension__ typedef unsigned long long uint64_t; 366*3d8817e4Smiod # endif 367*3d8817e4Smiod 368*3d8817e4Smiod #elif !defined __STRICT_ANSI__ 369*3d8817e4Smiod # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ 370*3d8817e4Smiod 371*3d8817e4Smiod # ifndef _INT64_T 372*3d8817e4Smiod # define _INT64_T 373*3d8817e4Smiod typedef __int64 int64_t; 374*3d8817e4Smiod # endif 375*3d8817e4Smiod # ifndef _UINT64_T 376*3d8817e4Smiod # define _UINT64_T 377*3d8817e4Smiod typedef unsigned __int64 uint64_t; 378*3d8817e4Smiod # endif 379*3d8817e4Smiod # endif /* compiler */ 380*3d8817e4Smiod 381*3d8817e4Smiod #endif /* ANSI version */ 382*3d8817e4SmiodEOF 383*3d8817e4Smiodfi 384*3d8817e4Smiod 385*3d8817e4Smiod# ------------- done int64_t types, emit intptr types ------------ 386*3d8817e4Smiodif test "$ac_cv_type_uintptr_t" != yes; then 387*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 388*3d8817e4Smiod 389*3d8817e4Smiod /* Define intptr_t based on sizeof(void*) = $ac_cv_sizeof_void_p */ 390*3d8817e4Smiod typedef u$acx_cv_type_intptr_t uintptr_t; 391*3d8817e4Smiod typedef $acx_cv_type_intptr_t intptr_t; 392*3d8817e4SmiodEOF 393*3d8817e4Smiodfi 394*3d8817e4Smiod 395*3d8817e4Smiod# ------------- done intptr types, emit int_least types ------------ 396*3d8817e4Smiodif test "$ac_cv_type_int_least32_t" != yes; then 397*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 398*3d8817e4Smiod 399*3d8817e4Smiod /* Define int_least types */ 400*3d8817e4Smiod typedef int8_t int_least8_t; 401*3d8817e4Smiod typedef int16_t int_least16_t; 402*3d8817e4Smiod typedef int32_t int_least32_t; 403*3d8817e4Smiod #ifdef _INT64_T 404*3d8817e4Smiod typedef int64_t int_least64_t; 405*3d8817e4Smiod #endif 406*3d8817e4Smiod 407*3d8817e4Smiod typedef uint8_t uint_least8_t; 408*3d8817e4Smiod typedef uint16_t uint_least16_t; 409*3d8817e4Smiod typedef uint32_t uint_least32_t; 410*3d8817e4Smiod #ifdef _UINT64_T 411*3d8817e4Smiod typedef uint64_t uint_least64_t; 412*3d8817e4Smiod #endif 413*3d8817e4SmiodEOF 414*3d8817e4Smiodfi 415*3d8817e4Smiod 416*3d8817e4Smiod# ------------- done intptr types, emit int_fast types ------------ 417*3d8817e4Smiodif test "$ac_cv_type_int_fast32_t" != yes; then 418*3d8817e4Smiod dnl NOTE: The following code assumes that sizeof (int) > 1. 419*3d8817e4Smiod dnl Fix when strange machines are reported. 420*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 421*3d8817e4Smiod 422*3d8817e4Smiod /* Define int_fast types. short is often slow */ 423*3d8817e4Smiod typedef int8_t int_fast8_t; 424*3d8817e4Smiod typedef int int_fast16_t; 425*3d8817e4Smiod typedef int32_t int_fast32_t; 426*3d8817e4Smiod #ifdef _INT64_T 427*3d8817e4Smiod typedef int64_t int_fast64_t; 428*3d8817e4Smiod #endif 429*3d8817e4Smiod 430*3d8817e4Smiod typedef uint8_t uint_fast8_t; 431*3d8817e4Smiod typedef unsigned int uint_fast16_t; 432*3d8817e4Smiod typedef uint32_t uint_fast32_t; 433*3d8817e4Smiod #ifdef _UINT64_T 434*3d8817e4Smiod typedef uint64_t uint_fast64_t; 435*3d8817e4Smiod #endif 436*3d8817e4SmiodEOF 437*3d8817e4Smiodfi 438*3d8817e4Smiod 439*3d8817e4Smiodif test "$ac_cv_type_uintmax_t" != yes; then 440*3d8817e4Smiod sed 's/^ *//' >> tmp-stdint.h <<EOF 441*3d8817e4Smiod 442*3d8817e4Smiod /* Define intmax based on what we found */ 443*3d8817e4Smiod #ifdef _INT64_T 444*3d8817e4Smiod typedef int64_t intmax_t; 445*3d8817e4Smiod #else 446*3d8817e4Smiod typedef long intmax_t; 447*3d8817e4Smiod #endif 448*3d8817e4Smiod #ifdef _UINT64_T 449*3d8817e4Smiod typedef uint64_t uintmax_t; 450*3d8817e4Smiod #else 451*3d8817e4Smiod typedef unsigned long uintmax_t; 452*3d8817e4Smiod #endif 453*3d8817e4SmiodEOF 454*3d8817e4Smiodfi 455*3d8817e4Smiod 456*3d8817e4Smiodsed 's/^ *//' >> tmp-stdint.h <<EOF 457*3d8817e4Smiod 458*3d8817e4Smiod #endif /* GCC_GENERATED_STDINT_H */ 459*3d8817e4SmiodEOF 460*3d8817e4Smiod 461*3d8817e4Smiodif test -r ]_GCC_STDINT_H[ && cmp -s tmp-stdint.h ]_GCC_STDINT_H[; then 462*3d8817e4Smiod rm -f tmp-stdint.h 463*3d8817e4Smiodelse 464*3d8817e4Smiod mv -f tmp-stdint.h ]_GCC_STDINT_H[ 465*3d8817e4Smiodfi 466*3d8817e4Smiod 467*3d8817e4Smiod], [ 468*3d8817e4SmiodGCC="$GCC" 469*3d8817e4SmiodCC="$CC" 470*3d8817e4Smiodacx_cv_header_stdint="$acx_cv_header_stdint" 471*3d8817e4Smiodacx_cv_type_int8_t="$acx_cv_type_int8_t" 472*3d8817e4Smiodacx_cv_type_int16_t="$acx_cv_type_int16_t" 473*3d8817e4Smiodacx_cv_type_int32_t="$acx_cv_type_int32_t" 474*3d8817e4Smiodacx_cv_type_int64_t="$acx_cv_type_int64_t" 475*3d8817e4Smiodacx_cv_type_intptr_t="$acx_cv_type_intptr_t" 476*3d8817e4Smiodac_cv_type_uintmax_t="$ac_cv_type_uintmax_t" 477*3d8817e4Smiodac_cv_type_uintptr_t="$ac_cv_type_uintptr_t" 478*3d8817e4Smiodac_cv_type_uint64_t="$ac_cv_type_uint64_t" 479*3d8817e4Smiodac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" 480*3d8817e4Smiodac_cv_type_u_int32_t="$ac_cv_type_u_int32_t" 481*3d8817e4Smiodac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" 482*3d8817e4Smiodac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" 483*3d8817e4Smiodac_cv_sizeof_void_p="$ac_cv_sizeof_void_p" 484*3d8817e4Smiod]) 485*3d8817e4Smiod 486*3d8817e4Smiod]) 487