1 dnl Try to detect the type of the third arg to getsockname() et al
2 AC_DEFUN([LSH_TYPE_SOCKLEN_T],
3 [AH_TEMPLATE([socklen_t], [Length type used by getsockopt])
4 AC_CACHE_CHECK([for socklen_t in sys/socket.h], ac_cv_type_socklen_t,
5 [AC_EGREP_HEADER(socklen_t, sys/socket.h,
6 [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])])
7 if test $ac_cv_type_socklen_t = no; then
8 AC_MSG_CHECKING(for AIX)
15 AC_DEFINE(socklen_t, size_t)
18 AC_DEFINE(socklen_t, int)
23 dnl LSH_PATH_ADD(path-id, directory)
24 AC_DEFUN([LSH_PATH_ADD],
27 if test -d "$2/." ; then
28 ac_real_dir=`cd $2 && pwd`
29 if test -n "$ac_real_dir" ; then
31 for old in $1_REAL_DIRS ; do
33 if test x$ac_real_dir = x$old ; then
38 if test $ac_found = yes ; then
39 AC_MSG_RESULT(already added)
42 # LDFLAGS="$LDFLAGS -L $2"
43 $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
44 $1_DIRS="$2 [$]$1_DIRS"
48 if test $ac_exists = no ; then
49 AC_MSG_RESULT(not found)
53 dnl LSH_RPATH_ADD(dir)
54 AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
56 dnl LSH_RPATH_INIT(candidates)
57 AC_DEFUN([LSH_RPATH_INIT],
58 [AC_MSG_CHECKING([for -R flag])
71 if test "$TCC" = "yes"; then
72 # tcc doesn't know about -R
79 RPATHFLAG="-Wl,-rpath,"
86 if test x$RPATHFLAG = x ; then
89 AC_MSG_RESULT([using $RPATHFLAG])
92 RPATH_CANDIDATE_REAL_DIRS=''
93 RPATH_CANDIDATE_DIRS=''
95 AC_MSG_RESULT([Searching for libraries])
102 dnl Try to execute a main program, and if it fails, try adding some
105 AC_DEFUN([LSH_RPATH_FIX],
106 [if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
108 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
109 ac_success=yes, ac_success=no, :)
111 if test $ac_success = no ; then
112 AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
113 dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
115 ac_rpath_save_LDFLAGS="$LDFLAGS"
116 for d in $RPATH_CANDIDATE_DIRS ; do
117 if test $ac_success = yes ; then
118 ac_remaining_dirs="$ac_remaining_dirs $d"
120 LDFLAGS="$RPATHFLAG$d $LDFLAGS"
121 dnl echo LDFLAGS = $LDFLAGS
122 AC_TRY_RUN([int main(int argc, char **argv) { return 0; }],
124 ac_rpath_save_LDFLAGS="$LDFLAGS"
125 AC_MSG_RESULT([adding $RPATHFLAG$d])
127 [ac_remaining_dirs="$ac_remaining_dirs $d"], :)
128 LDFLAGS="$ac_rpath_save_LDFLAGS"
131 RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
133 if test $ac_success = no ; then
134 AC_MSG_RESULT(failed)
139 dnl Like AC_CHECK_LIB, but uses $KRB_LIBS rather than $LIBS.
140 dnl LSH_CHECK_KRB_LIB(LIBRARY, FUNCTION, [, ACTION-IF-FOUND [,
141 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
143 AC_DEFUN([LSH_CHECK_KRB_LIB],
144 [AC_CHECK_LIB([$1], [$2],
146 [[ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
147 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
148 AC_DEFINE_UNQUOTED($ac_tr_lib)
149 KRB_LIBS="-l$1 $KRB_LIBS"
156 dnl LSH_LIB_ARGP(ACTION-IF-OK, ACTION-IF-BAD)
157 AC_DEFUN([LSH_LIB_ARGP],
158 [ ac_argp_save_LIBS="$LIBS"
159 ac_argp_save_LDFLAGS="$LDFLAGS"
161 # First check if we can link with argp.
162 AC_SEARCH_LIBS(argp_parse, argp,
164 AC_CACHE_CHECK([for working argp],
165 lsh_cv_lib_argp_works,
170 static const struct argp_option
173 { NULL, 0, NULL, 0, NULL, 0 }
182 child_parser(int key, char *arg, struct argp_state *state)
184 struct child_state *input = (struct child_state *) state->input;
189 return ARGP_ERR_UNKNOWN;
198 const struct argp child_argp =
202 NULL, NULL, NULL, NULL, NULL
207 struct child_state child;
212 main_parser(int key, char *arg, struct argp_state *state)
214 struct main_state *input = (struct main_state *) state->input;
219 return ARGP_ERR_UNKNOWN;
221 state->child_inputs[0] = &input->child;
225 input->m = input->child.n;
232 static const struct argp_child
235 { &child_argp, 0, "", 0 },
239 static const struct argp
241 { options, main_parser,
248 int main(int argc, char **argv)
250 struct main_state input = { { 0 }, 0 };
251 char *v[2] = { "foo", NULL };
253 argp_parse(&main_argp, 1, v, 0, NULL, &input);
255 if ( (input.m == 1) && (input.child.n == 1) )
260 ], lsh_cv_lib_argp_works=yes,
261 lsh_cv_lib_argp_works=no,
262 lsh_cv_lib_argp_works=no)])
264 if test x$lsh_cv_lib_argp_works = xyes ; then
268 LIBS="$ac_argp_save_LIBS"
269 LDFLAGS="$ac_argp_save_LDFLAGS"
272 if test x$ac_argp_ok = xyes ; then
273 ifelse([$1],, true, [$1])
275 ifelse([$2],, true, [$2])
279 dnl LSH_GCC_ATTRIBUTES
280 dnl Check for gcc's __attribute__ construction
282 AC_DEFUN([LSH_GCC_ATTRIBUTES],
283 [AC_CACHE_CHECK(for __attribute__,
289 static void foo(void) __attribute__ ((noreturn));
291 static void __attribute__ ((noreturn))
297 lsh_cv_c_attribute=yes,
298 lsh_cv_c_attribute=no)])
300 AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
301 if test "x$lsh_cv_c_attribute" = "xyes"; then
302 AC_DEFINE(HAVE_GCC_ATTRIBUTE)
306 [#if __GNUC__ && HAVE_GCC_ATTRIBUTE
307 # define NORETURN __attribute__ ((__noreturn__))
308 # define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
309 # define UNUSED __attribute__ ((__unused__))
312 # define PRINTF_STYLE(f, a)
317 AC_DEFUN([LSH_GCC_FUNCTION_NAME],
318 [# Check for gcc's __FUNCTION__ variable
319 AH_TEMPLATE([HAVE_GCC_FUNCTION],
320 [Define if the compiler understands __FUNCTION__])
322 [#if HAVE_GCC_FUNCTION
323 # define FUNCTION_NAME __FUNCTION__
325 # define FUNCTION_NAME "Unknown"
329 AC_CACHE_CHECK(for __FUNCTION__,
333 # error __FUNCTION__ is broken in gcc-3
335 void foo(void) { char c = __FUNCTION__[0]; } ],
336 lsh_cv_c_FUNCTION=yes,
337 lsh_cv_c_FUNCTION=no)])
339 if test "x$lsh_cv_c_FUNCTION" = "xyes"; then
340 AC_DEFINE(HAVE_GCC_FUNCTION)
344 # Check for alloca, and include the standard blurb in config.h
345 AC_DEFUN([LSH_FUNC_ALLOCA],
348 [/* AIX requires this to be the first thing in the file. */
356 # ifndef alloca /* predefined by HP cc +Olibcalls */
361 #else /* defined __GNUC__ */
368 AC_DEFUN([LSH_FUNC_STRERROR],
369 [AC_CHECK_FUNCS(strerror)
372 #define STRERROR strerror
374 #define STRERROR(x) (sys_errlist[x])
378 AC_DEFUN([LSH_FUNC_STRSIGNAL],
379 [AC_CHECK_FUNCS(strsignal)
380 AC_CHECK_DECLS([sys_siglist, _sys_siglist])
383 # define STRSIGNAL strsignal
384 #else /* !HAVE_STRSIGNAL */
385 # if HAVE_DECL_SYS_SIGLIST
386 # define STRSIGNAL(x) (sys_siglist[x])
388 # if HAVE_DECL__SYS_SIGLIST
389 # define STRSIGNAL(x) (_sys_siglist[x])
391 # define STRSIGNAL(x) "Unknown signal"
393 # warning Using dummy STRSIGNAL
397 #endif /* !HAVE_STRSIGNAL */
400 dnl @synopsis AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])]
402 dnl the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
403 dnl existence of an include file <stdint.h> that defines a set of
404 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
405 dnl Many older installations will not provide this file, but some will
406 dnl have the very same definitions in <inttypes.h>. In other enviroments
407 dnl we can use the inet-types in <sys/types.h> which would define the
408 dnl typedefs int8_t and u_int8_t respectivly.
410 dnl This macros will create a local "_stdint.h" or the headerfile given as
411 dnl an argument. In many cases that file will just "#include <stdint.h>"
412 dnl or "#include <inttypes.h>", while in other environments it will provide
413 dnl the set of basic 'stdint's definitions/typedefs:
414 dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
415 dnl int_least32_t.. int_fast32_t.. intmax_t
416 dnl which may or may not rely on the definitions of other files,
417 dnl or using the AC_CHECK_SIZEOF macro to determine the actual
418 dnl sizeof each type.
420 dnl if your header files require the stdint-types you will want to create an
421 dnl installable file mylib-int.h that all your other installable header
422 dnl may include. So if you have a library package named "mylib", just use
423 dnl AX_CREATE_STDINT_H(mylib-int.h)
424 dnl in configure.ac and go to install that very header file in Makefile.am
425 dnl along with the other headers (mylib.h) - and the mylib-specific headers
426 dnl can simply use "#include <mylib-int.h>" to obtain the stdint-types.
428 dnl Remember, if the system already had a valid <stdint.h>, the generated
429 dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things...
431 dnl @, (status: used on new platforms) (see http://ac-archive.sf.net/gstdint/)
432 dnl @version $Id: acinclude.m4,v 1.18 2004/02/07 14:21:04 nisse Exp $
433 dnl @author Guido Draheim <guidod@gmx.de>
435 AC_DEFUN([AX_CREATE_STDINT_H],
436 [# ------ AX CREATE STDINT H -------------------------------------
437 AC_MSG_CHECKING([for stdint types])
438 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
439 # try to shortcircuit - if the default include path of the compiler
440 # can find a "stdint.h" header then we assume that all compilers can.
441 AC_CACHE_VAL([ac_cv_header_stdint_t],[
442 old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
443 old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
444 old_CFLAGS="$CFLAGS" ; CFLAGS=""
445 AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
446 [ac_cv_stdint_result="(assuming C99 compatible system)"
447 ac_cv_header_stdint_t="stdint.h"; ],
448 [ac_cv_header_stdint_t=""])
449 CXXFLAGS="$old_CXXFLAGS"
450 CPPFLAGS="$old_CPPFLAGS"
451 CFLAGS="$old_CFLAGS" ])
453 v="... $ac_cv_header_stdint_h"
454 if test "$ac_stdint_h" = "stdint.h" ; then
455 AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
456 elif test "$ac_stdint_h" = "inttypes.h" ; then
457 AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
458 elif test "_$ac_cv_header_stdint_t" = "_" ; then
459 AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
461 ac_cv_header_stdint="$ac_cv_header_stdint_t"
462 AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
465 if test "_$ac_cv_header_stdint_t" = "_" ; then # can not shortcircuit..
467 dnl .....intro message done, now do a few system checks.....
468 dnl btw, all CHECK_TYPE macros do automatically "DEFINE" a type, therefore
469 dnl we use the autoconf implementation detail _AC CHECK_TYPE_NEW instead
471 inttype_headers=`echo $2 | sed -e 's/,/ /g'`
473 ac_cv_stdint_result="(no helpful system typedefs seen)"
474 AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
475 ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
476 AC_MSG_RESULT([(..)])
477 for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers ; do
478 unset ac_cv_type_uintptr_t
479 unset ac_cv_type_uint64_t
480 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
481 continue,[#include <$i>])
482 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
483 ac_cv_stdint_result="(seen uintptr_t$and64 in $i)"
486 AC_MSG_CHECKING([for stdint uintptr_t])
489 if test "_$ac_cv_header_stdint_x" = "_" ; then
490 AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
491 ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
492 AC_MSG_RESULT([(..)])
493 for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers ; do
494 unset ac_cv_type_uint32_t
495 unset ac_cv_type_uint64_t
496 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
497 continue,[#include <$i>])
498 AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
499 ac_cv_stdint_result="(seen uint32_t$and64 in $i)"
502 AC_MSG_CHECKING([for stdint uint32_t])
506 if test "_$ac_cv_header_stdint_x" = "_" ; then
507 if test "_$ac_cv_header_stdint_o" = "_" ; then
508 AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
509 ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
510 AC_MSG_RESULT([(..)])
511 for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do
512 unset ac_cv_type_u_int32_t
513 unset ac_cv_type_u_int64_t
514 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
515 continue,[#include <$i>])
516 AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
517 ac_cv_stdint_result="(seen u_int32_t$and64 in $i)"
520 AC_MSG_CHECKING([for stdint u_int32_t])
524 dnl if there was no good C99 header file, do some typedef checks...
525 if test "_$ac_cv_header_stdint_x" = "_" ; then
526 AC_MSG_CHECKING([for stdint datatype model])
527 AC_MSG_RESULT([(..)])
528 AC_CHECK_SIZEOF(char)
529 AC_CHECK_SIZEOF(short)
531 AC_CHECK_SIZEOF(long)
532 AC_CHECK_SIZEOF(void*)
533 ac_cv_stdint_char_model=""
534 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_char"
535 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_short"
536 ac_cv_stdint_char_model="$ac_cv_stdint_char_model$ac_cv_sizeof_int"
537 ac_cv_stdint_long_model=""
538 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_int"
539 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_long"
540 ac_cv_stdint_long_model="$ac_cv_stdint_long_model$ac_cv_sizeof_voidp"
541 name="$ac_cv_stdint_long_model"
542 case "$ac_cv_stdint_char_model/$ac_cv_stdint_long_model" in
543 122/242) name="$name, IP16 (standard 16bit machine)" ;;
544 122/244) name="$name, LP32 (standard 32bit mac/win)" ;;
545 122/*) name="$name (unusual int16 model)" ;;
546 124/444) name="$name, ILP32 (standard 32bit unixish)" ;;
547 124/488) name="$name, LP64 (standard 64bit unixish)" ;;
548 124/448) name="$name, LLP64 (unusual 64bit unixish)" ;;
549 124/*) name="$name (unusual int32 model)" ;;
550 128/888) name="$name, ILP64 (unusual 64bit numeric)" ;;
551 128/*) name="$name (unusual int64 model)" ;;
552 222/*|444/*) name="$name (unusual dsptype)" ;;
553 *) name="$name (very unusal model)" ;;
555 AC_MSG_RESULT([combined for stdint datatype model... $name])
558 if test "_$ac_cv_header_stdint_x" != "_" ; then
559 ac_cv_header_stdint="$ac_cv_header_stdint_x"
560 elif test "_$ac_cv_header_stdint_o" != "_" ; then
561 ac_cv_header_stdint="$ac_cv_header_stdint_o"
562 elif test "_$ac_cv_header_stdint_u" != "_" ; then
563 ac_cv_header_stdint="$ac_cv_header_stdint_u"
565 ac_cv_header_stdint="stddef.h"
568 AC_MSG_CHECKING([for extra inttypes in chosen header])
569 AC_MSG_RESULT([($ac_cv_header_stdint)])
570 dnl see if int_least and int_fast types are present in _this_ header.
571 unset ac_cv_type_int_least32_t
572 unset ac_cv_type_int_fast32_t
573 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
574 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
575 AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
577 fi # shortcircut to system "stdint.h"
578 # ------------------ PREPARE VARIABLES ------------------------------
579 if test "$GCC" = "yes" ; then
580 ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
582 ac_cv_stdint_message="using $CC"
585 AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
586 $ac_cv_stdint_result])
588 # ----------------- DONE inttypes.h checks START header -------------
589 AC_CONFIG_COMMANDS([$ac_stdint_h],[
590 AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
591 ac_stdint=$tmp/_stdint.h
593 echo "#ifndef" $_ac_stdint_h >$ac_stdint
594 echo "#define" $_ac_stdint_h "1" >>$ac_stdint
595 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
596 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
597 echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
598 if test "_$ac_cv_header_stdint_t" != "_" ; then
599 echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
602 cat >>$ac_stdint <<STDINT_EOF
604 /* ................... shortcircuit part ........................... */
606 #if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
611 /* .................... configured part ............................ */
615 echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
616 if test "_$ac_cv_header_stdint_x" != "_" ; then
617 ac_header="$ac_cv_header_stdint_x"
618 echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
620 echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
623 echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
624 if test "_$ac_cv_header_stdint_o" != "_" ; then
625 ac_header="$ac_cv_header_stdint_o"
626 echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
628 echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
631 echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
632 if test "_$ac_cv_header_stdint_u" != "_" ; then
633 ac_header="$ac_cv_header_stdint_u"
634 echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
636 echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
641 if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
642 echo "#include <$ac_header>" >>$ac_stdint
646 echo "/* which 64bit typedef has been found */" >>$ac_stdint
647 if test "$ac_cv_type_uint64_t" = "yes" ; then
648 echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
650 echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
652 if test "$ac_cv_type_u_int64_t" = "yes" ; then
653 echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
655 echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
659 echo "/* which type model has been detected */" >>$ac_stdint
660 if test "_$ac_cv_stdint_char_model" != "_" ; then
661 echo "#define _STDINT_CHAR_MODEL" "$ac_cv_stdint_char_model" >>$ac_stdint
662 echo "#define _STDINT_LONG_MODEL" "$ac_cv_stdint_long_model" >>$ac_stdint
664 echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
665 echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
669 echo "/* whether int_least types were detected */" >>$ac_stdint
670 if test "$ac_cv_type_int_least32_t" = "yes"; then
671 echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
673 echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
675 echo "/* whether int_fast types were detected */" >>$ac_stdint
676 if test "$ac_cv_type_int_fast32_t" = "yes"; then
677 echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
679 echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
681 echo "/* whether intmax_t type was detected */" >>$ac_stdint
682 if test "$ac_cv_type_intmax_t" = "yes"; then
683 echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
685 echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
689 cat >>$ac_stdint <<STDINT_EOF
690 /* .................... detections part ............................ */
692 /* whether we need to define bitspecific types from compiler base types */
693 #ifndef _STDINT_HEADER_INTPTR
694 #ifndef _STDINT_HEADER_UINT32
695 #ifndef _STDINT_HEADER_U_INT32
696 #define _STDINT_NEED_INT_MODEL_T
698 #define _STDINT_HAVE_U_INT_TYPES
703 #ifdef _STDINT_HAVE_U_INT_TYPES
704 #undef _STDINT_NEED_INT_MODEL_T
707 #ifdef _STDINT_CHAR_MODEL
708 #if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
709 #ifndef _STDINT_BYTE_MODEL
710 #define _STDINT_BYTE_MODEL 12
715 #ifndef _STDINT_HAVE_INT_LEAST32_T
716 #define _STDINT_NEED_INT_LEAST_T
719 #ifndef _STDINT_HAVE_INT_FAST32_T
720 #define _STDINT_NEED_INT_FAST_T
723 #ifndef _STDINT_HEADER_INTPTR
724 #define _STDINT_NEED_INTPTR_T
725 #ifndef _STDINT_HAVE_INTMAX_T
726 #define _STDINT_NEED_INTMAX_T
731 /* .................... definition part ............................ */
733 /* some system headers have good uint64_t */
734 #ifndef _HAVE_UINT64_T
735 #if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
736 #define _HAVE_UINT64_T
737 #elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
738 #define _HAVE_UINT64_T
739 typedef u_int64_t uint64_t;
743 #ifndef _HAVE_UINT64_T
744 /* .. here are some common heuristics using compiler runtime specifics */
745 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
746 #define _HAVE_UINT64_T
747 typedef long long int64_t;
748 typedef unsigned long long uint64_t;
750 #elif !defined __STRICT_ANSI__
751 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
752 #define _HAVE_UINT64_T
753 typedef __int64 int64_t;
754 typedef unsigned __int64 uint64_t;
756 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
757 /* note: all ELF-systems seem to have loff-support which needs 64-bit */
758 #if !defined _NO_LONGLONG
759 #define _HAVE_UINT64_T
760 typedef long long int64_t;
761 typedef unsigned long long uint64_t;
764 #elif defined __alpha || (defined __mips && defined _ABIN32)
765 #if !defined _NO_LONGLONG
766 typedef long int64_t;
767 typedef unsigned long uint64_t;
769 /* compiler/cpu type to define int64_t */
774 #if defined _STDINT_HAVE_U_INT_TYPES
775 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
776 typedef u_int8_t uint8_t;
777 typedef u_int16_t uint16_t;
778 typedef u_int32_t uint32_t;
780 /* glibc compatibility */
781 #ifndef __int8_t_defined
782 #define __int8_t_defined
786 #ifdef _STDINT_NEED_INT_MODEL_T
787 /* we must guess all the basic types. Apart from byte-adressable system, */
788 /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
789 /* (btw, those nibble-addressable systems are way off, or so we assume) */
791 dnl /* have a look at "64bit and data size neutrality" at */
792 dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
793 dnl /* (the shorthand "ILP" types always have a "P" part) */
795 #if defined _STDINT_BYTE_MODEL
796 #if _STDINT_LONG_MODEL+0 == 242
797 /* 2:4:2 = IP16 = a normal 16-bit system */
798 typedef unsigned char uint8_t;
799 typedef unsigned short uint16_t;
800 typedef unsigned long uint32_t;
801 #ifndef __int8_t_defined
802 #define __int8_t_defined
804 typedef short int16_t;
805 typedef long int32_t;
807 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
808 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
809 /* 4:4:4 = ILP32 = a normal 32-bit system */
810 typedef unsigned char uint8_t;
811 typedef unsigned short uint16_t;
812 typedef unsigned int uint32_t;
813 #ifndef __int8_t_defined
814 #define __int8_t_defined
816 typedef short int16_t;
819 #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
820 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
821 /* 4:8:8 = LP64 = a normal 64-bit system */
822 typedef unsigned char uint8_t;
823 typedef unsigned short uint16_t;
824 typedef unsigned int uint32_t;
825 #ifndef __int8_t_defined
826 #define __int8_t_defined
828 typedef short int16_t;
831 /* this system has a "long" of 64bit */
832 #ifndef _HAVE_UINT64_T
833 #define _HAVE_UINT64_T
834 typedef unsigned long uint64_t;
835 typedef long int64_t;
837 #elif _STDINT_LONG_MODEL+0 == 448
838 /* LLP64 a 64-bit system derived from a 32-bit system */
839 typedef unsigned char uint8_t;
840 typedef unsigned short uint16_t;
841 typedef unsigned int uint32_t;
842 #ifndef __int8_t_defined
843 #define __int8_t_defined
845 typedef short int16_t;
848 /* assuming the system has a "long long" */
849 #ifndef _HAVE_UINT64_T
850 #define _HAVE_UINT64_T
851 typedef unsigned long long uint64_t;
852 typedef long long int64_t;
855 #define _STDINT_NO_INT32_T
858 #define _STDINT_NO_INT8_T
859 #define _STDINT_NO_INT32_T
864 * quote from SunOS-5.8 sys/inttypes.h:
865 * Use at your own risk. As of February 1996, the committee is squarely
866 * behind the fixed sized types; the "least" and "fast" types are still being
867 * discussed. The probability that the "fast" types may be removed before
868 * the standard is finalized is high enough that they are not currently
872 #if defined _STDINT_NEED_INT_LEAST_T
873 typedef int8_t int_least8_t;
874 typedef int16_t int_least16_t;
875 typedef int32_t int_least32_t;
876 #ifdef _HAVE_UINT64_T
877 typedef int64_t int_least64_t;
880 typedef uint8_t uint_least8_t;
881 typedef uint16_t uint_least16_t;
882 typedef uint32_t uint_least32_t;
883 #ifdef _HAVE_UINT64_T
884 typedef uint64_t uint_least64_t;
889 #if defined _STDINT_NEED_INT_FAST_T
890 typedef int8_t int_fast8_t;
891 typedef int int_fast16_t;
892 typedef int32_t int_fast32_t;
893 #ifdef _HAVE_UINT64_T
894 typedef int64_t int_fast64_t;
897 typedef uint8_t uint_fast8_t;
898 typedef unsigned uint_fast16_t;
899 typedef uint32_t uint_fast32_t;
900 #ifdef _HAVE_UINT64_T
901 typedef uint64_t uint_fast64_t;
906 #ifdef _STDINT_NEED_INTMAX_T
907 #ifdef _HAVE_UINT64_T
908 typedef int64_t intmax_t;
909 typedef uint64_t uintmax_t;
911 typedef long intmax_t;
912 typedef unsigned long uintmax_t;
916 #ifdef _STDINT_NEED_INTPTR_T
917 #ifndef __intptr_t_defined
918 #define __intptr_t_defined
919 /* we encourage using "long" to store pointer values, never use "int" ! */
920 #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
921 typedef unsinged int uintptr_t;
922 typedef int intptr_t;
923 #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
924 typedef unsigned long uintptr_t;
925 typedef long intptr_t;
926 #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
927 typedef uint64_t uintptr_t;
928 typedef int64_t intptr_t;
929 #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
930 typedef unsigned long uintptr_t;
931 typedef long intptr_t;
942 if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
943 AC_MSG_NOTICE([$ac_stdint_h is unchanged])
945 ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
946 AS_MKDIR_P(["$ac_dir"])
948 mv $ac_stdint $ac_stdint_h
950 ],[# variables for create stdint.h replacement
953 ac_stdint_h="$ac_stdint_h"
954 _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
955 ac_cv_stdint_message="$ac_cv_stdint_message"
956 ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
957 ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
958 ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
959 ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
960 ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
961 ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
962 ac_cv_stdint_char_model="$ac_cv_stdint_char_model"
963 ac_cv_stdint_long_model="$ac_cv_stdint_long_model"
964 ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
965 ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
966 ac_cv_type_intmax_t="$ac_cv_type_intmax_t"