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