1597410b8SchristosAC_DEFUN([GCC_STDINT_TYPES], 2597410b8Schristos[AC_REQUIRE([AC_TYPE_INT8_T]) 3597410b8SchristosAC_REQUIRE([AC_TYPE_INT16_T]) 4597410b8SchristosAC_REQUIRE([AC_TYPE_INT32_T]) 5597410b8SchristosAC_REQUIRE([AC_TYPE_INT64_T]) 6597410b8SchristosAC_REQUIRE([AC_TYPE_INTMAX_T]) 7597410b8SchristosAC_REQUIRE([AC_TYPE_INTPTR_T]) 8597410b8SchristosAC_REQUIRE([AC_TYPE_UINT8_T]) 9597410b8SchristosAC_REQUIRE([AC_TYPE_UINT16_T]) 10597410b8SchristosAC_REQUIRE([AC_TYPE_UINT32_T]) 11597410b8SchristosAC_REQUIRE([AC_TYPE_UINT64_T]) 12597410b8SchristosAC_REQUIRE([AC_TYPE_UINTMAX_T]) 13597410b8SchristosAC_REQUIRE([AC_TYPE_UINTPTR_T])]) 14597410b8Schristos 15597410b8Schristosdnl @synopsis GCC_HEADER_STDINT [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])] 16597410b8Schristosdnl 17597410b8Schristosdnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the 18597410b8Schristosdnl existence of an include file <stdint.h> that defines a set of 19597410b8Schristosdnl typedefs, especially uint8_t,int32_t,uintptr_t. 20597410b8Schristosdnl Many older installations will not provide this file, but some will 2105598a80Schristosdnl have the very same definitions in <inttypes.h>. In other environments 22597410b8Schristosdnl we can use the inet-types in <sys/types.h> which would define the 23597410b8Schristosdnl typedefs int8_t and u_int8_t respectivly. 24597410b8Schristosdnl 25597410b8Schristosdnl This macros will create a local "_stdint.h" or the headerfile given as 26597410b8Schristosdnl an argument. In many cases that file will pick the definition from a 27597410b8Schristosdnl "#include <stdint.h>" or "#include <inttypes.h>" statement, while 28597410b8Schristosdnl in other environments it will provide the set of basic 'stdint's defined: 29597410b8Schristosdnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t 30597410b8Schristosdnl int_least32_t.. int_fast32_t.. intmax_t 31597410b8Schristosdnl which may or may not rely on the definitions of other files. 32597410b8Schristosdnl 33597410b8Schristosdnl Sometimes the stdint.h or inttypes.h headers conflict with sys/types.h, 34597410b8Schristosdnl so we test the headers together with sys/types.h and always include it 35597410b8Schristosdnl into the generated header (to match the tests with the generated file). 36597410b8Schristosdnl Hopefully this is not a big annoyance. 37597410b8Schristosdnl 38597410b8Schristosdnl If your installed header files require the stdint-types you will want to 39597410b8Schristosdnl create an installable file mylib-int.h that all your other installable 40597410b8Schristosdnl header may include. So, for a library package named "mylib", just use 41597410b8Schristosdnl GCC_HEADER_STDINT(mylib-int.h) 42*ba340e45Schristosdnl in configure.ac and install that header file in Makefile.am along with 43597410b8Schristosdnl the other headers (mylib.h). The mylib-specific headers can simply 44597410b8Schristosdnl use "#include <mylib-int.h>" to obtain the stdint-types. 45597410b8Schristosdnl 46597410b8Schristosdnl Remember, if the system already had a valid <stdint.h>, the generated 47597410b8Schristosdnl file will include it directly. No need for fuzzy HAVE_STDINT_H things... 48597410b8Schristosdnl 49597410b8Schristosdnl @author Guido Draheim <guidod@gmx.de>, Paolo Bonzini <bonzini@gnu.org> 50597410b8Schristos 51597410b8SchristosAC_DEFUN([GCC_HEADER_STDINT], 52597410b8Schristos[m4_define(_GCC_STDINT_H, m4_ifval($1, $1, _stdint.h)) 53597410b8Schristos 54597410b8Schristosinttype_headers=`echo inttypes.h sys/inttypes.h $2 | sed -e 's/,/ /g'` 55597410b8Schristos 56597410b8Schristosacx_cv_header_stdint=stddef.h 57597410b8Schristosacx_cv_header_stdint_kind="(already complete)" 58597410b8Schristosfor i in stdint.h $inttype_headers; do 59597410b8Schristos unset ac_cv_type_uintptr_t 60597410b8Schristos unset ac_cv_type_uintmax_t 61597410b8Schristos unset ac_cv_type_int_least32_t 62597410b8Schristos unset ac_cv_type_int_fast32_t 63597410b8Schristos unset ac_cv_type_uint64_t 64597410b8Schristos _AS_ECHO_N([looking for a compliant stdint.h in $i, ]) 65597410b8Schristos AC_CHECK_TYPE(uintmax_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 66597410b8Schristos#include <$i>]) 67597410b8Schristos AC_CHECK_TYPE(uintptr_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 68597410b8Schristos#include <$i>]) 69597410b8Schristos AC_CHECK_TYPE(int_least32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 70597410b8Schristos#include <$i>]) 71597410b8Schristos AC_CHECK_TYPE(int_fast32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include <sys/types.h> 72597410b8Schristos#include <$i>]) 73597410b8Schristos AC_CHECK_TYPE(uint64_t,,[acx_cv_header_stdint_kind="(lacks uint64_t)"], [#include <sys/types.h> 74597410b8Schristos#include <$i>]) 75597410b8Schristos break 76597410b8Schristosdone 77597410b8Schristosif test "$acx_cv_header_stdint" = stddef.h; then 78597410b8Schristos acx_cv_header_stdint_kind="(lacks uintmax_t)" 79597410b8Schristos for i in stdint.h $inttype_headers; do 80597410b8Schristos unset ac_cv_type_uintptr_t 81597410b8Schristos unset ac_cv_type_uint32_t 82597410b8Schristos unset ac_cv_type_uint64_t 83597410b8Schristos _AS_ECHO_N([looking for an incomplete stdint.h in $i, ]) 84597410b8Schristos AC_CHECK_TYPE(uint32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 85597410b8Schristos#include <$i>]) 86597410b8Schristos AC_CHECK_TYPE(uint64_t,,,[#include <sys/types.h> 87597410b8Schristos#include <$i>]) 88597410b8Schristos AC_CHECK_TYPE(uintptr_t,,,[#include <sys/types.h> 89597410b8Schristos#include <$i>]) 90597410b8Schristos break 91597410b8Schristos done 92597410b8Schristosfi 93597410b8Schristosif test "$acx_cv_header_stdint" = stddef.h; then 94597410b8Schristos acx_cv_header_stdint_kind="(u_intXX_t style)" 95597410b8Schristos for i in sys/types.h $inttype_headers; do 96597410b8Schristos unset ac_cv_type_u_int32_t 97597410b8Schristos unset ac_cv_type_u_int64_t 98597410b8Schristos _AS_ECHO_N([looking for u_intXX_t types in $i, ]) 99597410b8Schristos AC_CHECK_TYPE(u_int32_t,[acx_cv_header_stdint=$i],continue,[#include <sys/types.h> 100597410b8Schristos#include <$i>]) 101597410b8Schristos AC_CHECK_TYPE(u_int64_t,,,[#include <sys/types.h> 102597410b8Schristos#include <$i>]) 103597410b8Schristos break 104597410b8Schristos done 105597410b8Schristosfi 106597410b8Schristosif test "$acx_cv_header_stdint" = stddef.h; then 107597410b8Schristos acx_cv_header_stdint_kind="(using manual detection)" 108597410b8Schristosfi 109597410b8Schristos 110597410b8Schristostest -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no 111597410b8Schristostest -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no 112597410b8Schristostest -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no 113597410b8Schristostest -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no 114597410b8Schristostest -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no 115597410b8Schristos 116597410b8Schristos# ----------------- Summarize what we found so far 117597410b8Schristos 118597410b8SchristosAC_MSG_CHECKING([what to include in _GCC_STDINT_H]) 119597410b8Schristos 120597410b8Schristoscase `AS_BASENAME(_GCC_STDINT_H)` in 121597410b8Schristos stdint.h) AC_MSG_WARN([are you sure you want it there?]) ;; 122597410b8Schristos inttypes.h) AC_MSG_WARN([are you sure you want it there?]) ;; 123597410b8Schristos *) ;; 124597410b8Schristosesac 125597410b8Schristos 126597410b8SchristosAC_MSG_RESULT($acx_cv_header_stdint $acx_cv_header_stdint_kind) 127597410b8Schristos 128597410b8Schristos# ----------------- done included file, check C basic types -------- 129597410b8Schristos 130597410b8Schristos# Lacking an uintptr_t? Test size of void * 131597410b8Schristoscase "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in 132597410b8Schristos stddef.h:* | *:no) AC_CHECK_SIZEOF(void *) ;; 133597410b8Schristosesac 134597410b8Schristos 135597410b8Schristos# Lacking an uint64_t? Test size of long 136597410b8Schristoscase "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in 137597410b8Schristos stddef.h:*:* | *:no:no) AC_CHECK_SIZEOF(long) ;; 138597410b8Schristosesac 139597410b8Schristos 140597410b8Schristosif test $acx_cv_header_stdint = stddef.h; then 141597410b8Schristos # Lacking a good header? Test size of everything and deduce all types. 142597410b8Schristos AC_CHECK_SIZEOF(int) 143597410b8Schristos AC_CHECK_SIZEOF(short) 144597410b8Schristos AC_CHECK_SIZEOF(char) 145597410b8Schristos 146597410b8Schristos AC_MSG_CHECKING(for type equivalent to int8_t) 147597410b8Schristos case "$ac_cv_sizeof_char" in 148597410b8Schristos 1) acx_cv_type_int8_t=char ;; 149597410b8Schristos *) AC_MSG_ERROR([no 8-bit type, please report a bug]) 150597410b8Schristos esac 151597410b8Schristos AC_MSG_RESULT($acx_cv_type_int8_t) 152597410b8Schristos 153597410b8Schristos AC_MSG_CHECKING(for type equivalent to int16_t) 154597410b8Schristos case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in 155597410b8Schristos 2:*) acx_cv_type_int16_t=int ;; 156597410b8Schristos *:2) acx_cv_type_int16_t=short ;; 157597410b8Schristos *) AC_MSG_ERROR([no 16-bit type, please report a bug]) 158597410b8Schristos esac 159597410b8Schristos AC_MSG_RESULT($acx_cv_type_int16_t) 160597410b8Schristos 161597410b8Schristos AC_MSG_CHECKING(for type equivalent to int32_t) 162597410b8Schristos case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in 163597410b8Schristos 4:*) acx_cv_type_int32_t=int ;; 164597410b8Schristos *:4) acx_cv_type_int32_t=long ;; 165597410b8Schristos *) AC_MSG_ERROR([no 32-bit type, please report a bug]) 166597410b8Schristos esac 167597410b8Schristos AC_MSG_RESULT($acx_cv_type_int32_t) 168597410b8Schristosfi 169597410b8Schristos 170597410b8Schristos# These tests are here to make the output prettier 171597410b8Schristos 172597410b8Schristosif test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then 173597410b8Schristos case "$ac_cv_sizeof_long" in 174597410b8Schristos 8) acx_cv_type_int64_t=long ;; 175597410b8Schristos esac 176597410b8Schristos AC_MSG_CHECKING(for type equivalent to int64_t) 177597410b8Schristos AC_MSG_RESULT(${acx_cv_type_int64_t-'using preprocessor symbols'}) 178597410b8Schristosfi 179597410b8Schristos 180597410b8Schristos# Now we can use the above types 181597410b8Schristos 182597410b8Schristosif test "$ac_cv_type_uintptr_t" != yes; then 183597410b8Schristos AC_MSG_CHECKING(for type equivalent to intptr_t) 184597410b8Schristos case $ac_cv_sizeof_void_p in 185597410b8Schristos 2) acx_cv_type_intptr_t=int16_t ;; 186597410b8Schristos 4) acx_cv_type_intptr_t=int32_t ;; 187597410b8Schristos 8) acx_cv_type_intptr_t=int64_t ;; 188597410b8Schristos *) AC_MSG_ERROR([no equivalent for intptr_t, please report a bug]) 189597410b8Schristos esac 190597410b8Schristos AC_MSG_RESULT($acx_cv_type_intptr_t) 191597410b8Schristosfi 192597410b8Schristos 193597410b8Schristos# ----------------- done all checks, emit header ------------- 194597410b8SchristosAC_CONFIG_COMMANDS(_GCC_STDINT_H, [ 195597410b8Schristosif test "$GCC" = yes; then 196597410b8Schristos echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h 197597410b8Schristoselse 198597410b8Schristos echo "/* generated for $CC */" > tmp-stdint.h 199597410b8Schristosfi 200597410b8Schristos 201597410b8Schristossed 's/^ *//' >> tmp-stdint.h <<EOF 202597410b8Schristos 203597410b8Schristos #ifndef GCC_GENERATED_STDINT_H 204597410b8Schristos #define GCC_GENERATED_STDINT_H 1 205597410b8Schristos 206597410b8Schristos #include <sys/types.h> 207597410b8SchristosEOF 208597410b8Schristos 209597410b8Schristosif test "$acx_cv_header_stdint" != stdint.h; then 210597410b8Schristos echo "#include <stddef.h>" >> tmp-stdint.h 211597410b8Schristosfi 212597410b8Schristosif test "$acx_cv_header_stdint" != stddef.h; then 213597410b8Schristos echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h 214597410b8Schristosfi 215597410b8Schristos 216597410b8Schristossed 's/^ *//' >> tmp-stdint.h <<EOF 217597410b8Schristos /* glibc uses these symbols as guards to prevent redefinitions. */ 218597410b8Schristos #ifdef __int8_t_defined 219597410b8Schristos #define _INT8_T 220597410b8Schristos #define _INT16_T 221597410b8Schristos #define _INT32_T 222597410b8Schristos #endif 223597410b8Schristos #ifdef __uint32_t_defined 224597410b8Schristos #define _UINT32_T 225597410b8Schristos #endif 226597410b8Schristos 227597410b8SchristosEOF 228597410b8Schristos 229597410b8Schristos# ----------------- done header, emit basic int types ------------- 230597410b8Schristosif test "$acx_cv_header_stdint" = stddef.h; then 231597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 232597410b8Schristos 233597410b8Schristos #ifndef _UINT8_T 234597410b8Schristos #define _UINT8_T 235597410b8Schristos #ifndef __uint8_t_defined 236597410b8Schristos #define __uint8_t_defined 237597410b8Schristos #ifndef uint8_t 238597410b8Schristos typedef unsigned $acx_cv_type_int8_t uint8_t; 239597410b8Schristos #endif 240597410b8Schristos #endif 241597410b8Schristos #endif 242597410b8Schristos 243597410b8Schristos #ifndef _UINT16_T 244597410b8Schristos #define _UINT16_T 245597410b8Schristos #ifndef __uint16_t_defined 246597410b8Schristos #define __uint16_t_defined 247597410b8Schristos #ifndef uint16_t 248597410b8Schristos typedef unsigned $acx_cv_type_int16_t uint16_t; 249597410b8Schristos #endif 250597410b8Schristos #endif 251597410b8Schristos #endif 252597410b8Schristos 253597410b8Schristos #ifndef _UINT32_T 254597410b8Schristos #define _UINT32_T 255597410b8Schristos #ifndef __uint32_t_defined 256597410b8Schristos #define __uint32_t_defined 257597410b8Schristos #ifndef uint32_t 258597410b8Schristos typedef unsigned $acx_cv_type_int32_t uint32_t; 259597410b8Schristos #endif 260597410b8Schristos #endif 261597410b8Schristos #endif 262597410b8Schristos 263597410b8Schristos #ifndef _INT8_T 264597410b8Schristos #define _INT8_T 265597410b8Schristos #ifndef __int8_t_defined 266597410b8Schristos #define __int8_t_defined 267597410b8Schristos #ifndef int8_t 268597410b8Schristos typedef $acx_cv_type_int8_t int8_t; 269597410b8Schristos #endif 270597410b8Schristos #endif 271597410b8Schristos #endif 272597410b8Schristos 273597410b8Schristos #ifndef _INT16_T 274597410b8Schristos #define _INT16_T 275597410b8Schristos #ifndef __int16_t_defined 276597410b8Schristos #define __int16_t_defined 277597410b8Schristos #ifndef int16_t 278597410b8Schristos typedef $acx_cv_type_int16_t int16_t; 279597410b8Schristos #endif 280597410b8Schristos #endif 281597410b8Schristos #endif 282597410b8Schristos 283597410b8Schristos #ifndef _INT32_T 284597410b8Schristos #define _INT32_T 285597410b8Schristos #ifndef __int32_t_defined 286597410b8Schristos #define __int32_t_defined 287597410b8Schristos #ifndef int32_t 288597410b8Schristos typedef $acx_cv_type_int32_t int32_t; 289597410b8Schristos #endif 290597410b8Schristos #endif 291597410b8Schristos #endif 292597410b8SchristosEOF 293597410b8Schristoselif test "$ac_cv_type_u_int32_t" = yes; then 294597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 295597410b8Schristos 296597410b8Schristos /* int8_t int16_t int32_t defined by inet code, we do the u_intXX types */ 297597410b8Schristos #ifndef _INT8_T 298597410b8Schristos #define _INT8_T 299597410b8Schristos #endif 300597410b8Schristos #ifndef _INT16_T 301597410b8Schristos #define _INT16_T 302597410b8Schristos #endif 303597410b8Schristos #ifndef _INT32_T 304597410b8Schristos #define _INT32_T 305597410b8Schristos #endif 306597410b8Schristos 307597410b8Schristos #ifndef _UINT8_T 308597410b8Schristos #define _UINT8_T 309597410b8Schristos #ifndef __uint8_t_defined 310597410b8Schristos #define __uint8_t_defined 311597410b8Schristos #ifndef uint8_t 312597410b8Schristos typedef u_int8_t uint8_t; 313597410b8Schristos #endif 314597410b8Schristos #endif 315597410b8Schristos #endif 316597410b8Schristos 317597410b8Schristos #ifndef _UINT16_T 318597410b8Schristos #define _UINT16_T 319597410b8Schristos #ifndef __uint16_t_defined 320597410b8Schristos #define __uint16_t_defined 321597410b8Schristos #ifndef uint16_t 322597410b8Schristos typedef u_int16_t uint16_t; 323597410b8Schristos #endif 324597410b8Schristos #endif 325597410b8Schristos #endif 326597410b8Schristos 327597410b8Schristos #ifndef _UINT32_T 328597410b8Schristos #define _UINT32_T 329597410b8Schristos #ifndef __uint32_t_defined 330597410b8Schristos #define __uint32_t_defined 331597410b8Schristos #ifndef uint32_t 332597410b8Schristos typedef u_int32_t uint32_t; 333597410b8Schristos #endif 334597410b8Schristos #endif 335597410b8Schristos #endif 336597410b8SchristosEOF 337597410b8Schristoselse 338597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 339597410b8Schristos 340597410b8Schristos /* Some systems have guard macros to prevent redefinitions, define them. */ 341597410b8Schristos #ifndef _INT8_T 342597410b8Schristos #define _INT8_T 343597410b8Schristos #endif 344597410b8Schristos #ifndef _INT16_T 345597410b8Schristos #define _INT16_T 346597410b8Schristos #endif 347597410b8Schristos #ifndef _INT32_T 348597410b8Schristos #define _INT32_T 349597410b8Schristos #endif 350597410b8Schristos #ifndef _UINT8_T 351597410b8Schristos #define _UINT8_T 352597410b8Schristos #endif 353597410b8Schristos #ifndef _UINT16_T 354597410b8Schristos #define _UINT16_T 355597410b8Schristos #endif 356597410b8Schristos #ifndef _UINT32_T 357597410b8Schristos #define _UINT32_T 358597410b8Schristos #endif 359597410b8SchristosEOF 360597410b8Schristosfi 361597410b8Schristos 362597410b8Schristos# ------------- done basic int types, emit int64_t types ------------ 363597410b8Schristosif test "$ac_cv_type_uint64_t" = yes; then 364597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 365597410b8Schristos 366597410b8Schristos /* system headers have good uint64_t and int64_t */ 367597410b8Schristos #ifndef _INT64_T 368597410b8Schristos #define _INT64_T 369597410b8Schristos #endif 370597410b8Schristos #ifndef _UINT64_T 371597410b8Schristos #define _UINT64_T 372597410b8Schristos #endif 373597410b8SchristosEOF 374597410b8Schristoselif test "$ac_cv_type_u_int64_t" = yes; then 375597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 376597410b8Schristos 377597410b8Schristos /* system headers have an u_int64_t (and int64_t) */ 378597410b8Schristos #ifndef _INT64_T 379597410b8Schristos #define _INT64_T 380597410b8Schristos #endif 381597410b8Schristos #ifndef _UINT64_T 382597410b8Schristos #define _UINT64_T 383597410b8Schristos #ifndef __uint64_t_defined 384597410b8Schristos #define __uint64_t_defined 385597410b8Schristos #ifndef uint64_t 386597410b8Schristos typedef u_int64_t uint64_t; 387597410b8Schristos #endif 388597410b8Schristos #endif 389597410b8Schristos #endif 390597410b8SchristosEOF 391597410b8Schristoselif test -n "$acx_cv_type_int64_t"; then 392597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 393597410b8Schristos 394597410b8Schristos /* architecture has a 64-bit type, $acx_cv_type_int64_t */ 395597410b8Schristos #ifndef _INT64_T 396597410b8Schristos #define _INT64_T 397597410b8Schristos #ifndef int64_t 398597410b8Schristos typedef $acx_cv_type_int64_t int64_t; 399597410b8Schristos #endif 400597410b8Schristos #endif 401597410b8Schristos #ifndef _UINT64_T 402597410b8Schristos #define _UINT64_T 403597410b8Schristos #ifndef __uint64_t_defined 404597410b8Schristos #define __uint64_t_defined 405597410b8Schristos #ifndef uint64_t 406597410b8Schristos typedef unsigned $acx_cv_type_int64_t uint64_t; 407597410b8Schristos #endif 408597410b8Schristos #endif 409597410b8Schristos #endif 410597410b8SchristosEOF 411597410b8Schristoselse 412597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 413597410b8Schristos 414597410b8Schristos /* some common heuristics for int64_t, using compiler-specific tests */ 415597410b8Schristos #if defined __STDC_VERSION__ && (__STDC_VERSION__-0) >= 199901L 416597410b8Schristos #ifndef _INT64_T 417597410b8Schristos #define _INT64_T 418597410b8Schristos #ifndef __int64_t_defined 419597410b8Schristos #ifndef int64_t 420597410b8Schristos typedef long long int64_t; 421597410b8Schristos #endif 422597410b8Schristos #endif 423597410b8Schristos #endif 424597410b8Schristos #ifndef _UINT64_T 425597410b8Schristos #define _UINT64_T 426597410b8Schristos #ifndef uint64_t 427597410b8Schristos typedef unsigned long long uint64_t; 428597410b8Schristos #endif 429597410b8Schristos #endif 430597410b8Schristos 431597410b8Schristos #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0 432597410b8Schristos /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and 433597410b8Schristos does not implement __extension__. But that compiler doesn't define 434597410b8Schristos __GNUC_MINOR__. */ 435597410b8Schristos # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) 436597410b8Schristos # define __extension__ 437597410b8Schristos # endif 438597410b8Schristos 439597410b8Schristos # ifndef _INT64_T 440597410b8Schristos # define _INT64_T 441597410b8Schristos # ifndef int64_t 442597410b8Schristos __extension__ typedef long long int64_t; 443597410b8Schristos # endif 444597410b8Schristos # endif 445597410b8Schristos # ifndef _UINT64_T 446597410b8Schristos # define _UINT64_T 447597410b8Schristos # ifndef uint64_t 448597410b8Schristos __extension__ typedef unsigned long long uint64_t; 449597410b8Schristos # endif 450597410b8Schristos # endif 451597410b8Schristos 452597410b8Schristos #elif !defined __STRICT_ANSI__ 453597410b8Schristos # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ 454597410b8Schristos 455597410b8Schristos # ifndef _INT64_T 456597410b8Schristos # define _INT64_T 457597410b8Schristos # ifndef int64_t 458597410b8Schristos typedef __int64 int64_t; 459597410b8Schristos # endif 460597410b8Schristos # endif 461597410b8Schristos # ifndef _UINT64_T 462597410b8Schristos # define _UINT64_T 463597410b8Schristos # ifndef uint64_t 464597410b8Schristos typedef unsigned __int64 uint64_t; 465597410b8Schristos # endif 466597410b8Schristos # endif 467597410b8Schristos # endif /* compiler */ 468597410b8Schristos 469597410b8Schristos #endif /* ANSI version */ 470597410b8SchristosEOF 471597410b8Schristosfi 472597410b8Schristos 473597410b8Schristos# ------------- done int64_t types, emit intptr types ------------ 474597410b8Schristosif test "$ac_cv_type_uintptr_t" != yes; then 475597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 476597410b8Schristos 477597410b8Schristos /* Define intptr_t based on sizeof(void*) = $ac_cv_sizeof_void_p */ 478597410b8Schristos #ifndef __uintptr_t_defined 479597410b8Schristos #ifndef uintptr_t 480597410b8Schristos typedef u$acx_cv_type_intptr_t uintptr_t; 481597410b8Schristos #endif 482597410b8Schristos #endif 483597410b8Schristos #ifndef __intptr_t_defined 484597410b8Schristos #ifndef intptr_t 485597410b8Schristos typedef $acx_cv_type_intptr_t intptr_t; 486597410b8Schristos #endif 487597410b8Schristos #endif 488597410b8SchristosEOF 489597410b8Schristosfi 490597410b8Schristos 491597410b8Schristos# ------------- done intptr types, emit int_least types ------------ 492597410b8Schristosif test "$ac_cv_type_int_least32_t" != yes; then 493597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 494597410b8Schristos 495597410b8Schristos /* Define int_least types */ 496597410b8Schristos typedef int8_t int_least8_t; 497597410b8Schristos typedef int16_t int_least16_t; 498597410b8Schristos typedef int32_t int_least32_t; 499597410b8Schristos #ifdef _INT64_T 500597410b8Schristos typedef int64_t int_least64_t; 501597410b8Schristos #endif 502597410b8Schristos 503597410b8Schristos typedef uint8_t uint_least8_t; 504597410b8Schristos typedef uint16_t uint_least16_t; 505597410b8Schristos typedef uint32_t uint_least32_t; 506597410b8Schristos #ifdef _UINT64_T 507597410b8Schristos typedef uint64_t uint_least64_t; 508597410b8Schristos #endif 509597410b8SchristosEOF 510597410b8Schristosfi 511597410b8Schristos 512597410b8Schristos# ------------- done intptr types, emit int_fast types ------------ 513597410b8Schristosif test "$ac_cv_type_int_fast32_t" != yes; then 514597410b8Schristos dnl NOTE: The following code assumes that sizeof (int) > 1. 515597410b8Schristos dnl Fix when strange machines are reported. 516597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 517597410b8Schristos 518597410b8Schristos /* Define int_fast types. short is often slow */ 519597410b8Schristos typedef int8_t int_fast8_t; 520597410b8Schristos typedef int int_fast16_t; 521597410b8Schristos typedef int32_t int_fast32_t; 522597410b8Schristos #ifdef _INT64_T 523597410b8Schristos typedef int64_t int_fast64_t; 524597410b8Schristos #endif 525597410b8Schristos 526597410b8Schristos typedef uint8_t uint_fast8_t; 527597410b8Schristos typedef unsigned int uint_fast16_t; 528597410b8Schristos typedef uint32_t uint_fast32_t; 529597410b8Schristos #ifdef _UINT64_T 530597410b8Schristos typedef uint64_t uint_fast64_t; 531597410b8Schristos #endif 532597410b8SchristosEOF 533597410b8Schristosfi 534597410b8Schristos 535597410b8Schristosif test "$ac_cv_type_uintmax_t" != yes; then 536597410b8Schristos sed 's/^ *//' >> tmp-stdint.h <<EOF 537597410b8Schristos 538597410b8Schristos /* Define intmax based on what we found */ 539597410b8Schristos #ifndef intmax_t 540597410b8Schristos #ifdef _INT64_T 541597410b8Schristos typedef int64_t intmax_t; 542597410b8Schristos #else 543597410b8Schristos typedef long intmax_t; 544597410b8Schristos #endif 545597410b8Schristos #endif 546597410b8Schristos #ifndef uintmax_t 547597410b8Schristos #ifdef _UINT64_T 548597410b8Schristos typedef uint64_t uintmax_t; 549597410b8Schristos #else 550597410b8Schristos typedef unsigned long uintmax_t; 551597410b8Schristos #endif 552597410b8Schristos #endif 553597410b8SchristosEOF 554597410b8Schristosfi 555597410b8Schristos 556597410b8Schristossed 's/^ *//' >> tmp-stdint.h <<EOF 557597410b8Schristos 558597410b8Schristos #endif /* GCC_GENERATED_STDINT_H */ 559597410b8SchristosEOF 560597410b8Schristos 561597410b8Schristosif test -r ]_GCC_STDINT_H[ && cmp -s tmp-stdint.h ]_GCC_STDINT_H[; then 562597410b8Schristos rm -f tmp-stdint.h 563597410b8Schristoselse 564597410b8Schristos mv -f tmp-stdint.h ]_GCC_STDINT_H[ 565597410b8Schristosfi 566597410b8Schristos 567597410b8Schristos], [ 568597410b8SchristosGCC="$GCC" 569597410b8SchristosCC="$CC" 570597410b8Schristosacx_cv_header_stdint="$acx_cv_header_stdint" 571597410b8Schristosacx_cv_type_int8_t="$acx_cv_type_int8_t" 572597410b8Schristosacx_cv_type_int16_t="$acx_cv_type_int16_t" 573597410b8Schristosacx_cv_type_int32_t="$acx_cv_type_int32_t" 574597410b8Schristosacx_cv_type_int64_t="$acx_cv_type_int64_t" 575597410b8Schristosacx_cv_type_intptr_t="$acx_cv_type_intptr_t" 576597410b8Schristosac_cv_type_uintmax_t="$ac_cv_type_uintmax_t" 577597410b8Schristosac_cv_type_uintptr_t="$ac_cv_type_uintptr_t" 578597410b8Schristosac_cv_type_uint64_t="$ac_cv_type_uint64_t" 579597410b8Schristosac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" 580597410b8Schristosac_cv_type_u_int32_t="$ac_cv_type_u_int32_t" 581597410b8Schristosac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" 582597410b8Schristosac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" 583597410b8Schristosac_cv_sizeof_void_p="$ac_cv_sizeof_void_p" 584597410b8Schristos]) 585597410b8Schristos 586597410b8Schristos]) 587