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