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