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