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