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