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