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