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