-dnl Set gl_cv_header_stdint_h to yes and define HAVE_STDINT_H if
-dnl <stdint.h> exists and doesn't clash with <sys/types.h>.
-AC_DEFUN([gl_HEADER_STDINT_H],
-[
- dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
- AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, [
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <stdint.h>],
- [], gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)
- ])
- if test $gl_cv_header_stdint_h = yes; then
- AC_DEFINE_UNQUOTED(HAVE_STDINT_H, 1,
- [Define if <stdint.h> exists and doesn't clash with <sys/types.h>.])
- fi
-])
-
-dnl Set gl_cv_header_inttypes_h to yes and define HAVE_INTTYPES_H if
-dnl <inttypes.h> exists and doesn't clash with <sys/types.h>.
-AC_DEFUN([gl_HEADER_INTTYPES_H],
-[
- dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
- dnl On IRIX 5.3, <inttypes.h> conflicts with <sys/types.h>.
- AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, [
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <inttypes.h>],
- [], gl_cv_header_inttypes_h=yes, gl_cv_header_inttypes_h=no)
- ])
- if test $gl_cv_header_inttypes_h = yes; then
- AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
- [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
- fi
-])
-
-dnl gl_STDINT_CHECK_TYPES(TYPES, INCLUDES, CACHE_VAR_PREFIX, MACRO_SUFFIX, DESCRIPTION_SUFFIX)
-dnl Check each of the given types, whether they are defined in the given
-dnl include files.
-AC_DEFUN([gl_STDINT_CHECK_TYPES],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in,
- dnl - extra AC_SUBST calls, so that the right substitutions are made.
- AC_FOREACH([gltype], [$1],
- [AH_TEMPLATE([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4],
- [Define to 1 if the type ']gltype[' is already defined$5.])])
- for gltype in $1 ; do
- AC_MSG_CHECKING([for $gltype])
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([$2
-/* Test if the type exists. */
-$gltype x = 17;
- ])],
- result=yes, result=no)
- eval $3${gltype}=\$result
- AC_MSG_RESULT($result)
- GLTYPE=`echo "$gltype" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- if test $result = yes; then
- AC_DEFINE_UNQUOTED([HAVE_${GLTYPE}$4], 1)
- eval HAVE_${GLTYPE}$4=1
- else
- eval HAVE_${GLTYPE}$4=0
- fi
- done
- AC_FOREACH([gltype], [$1],
- [AC_SUBST([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4])])
-])
-
-dnl gl_STDINT_MISSING_BOUND(TYPE_BOUND, DEFAULT, DESCRIPTION)
-dnl assumes an otherwise complete <stdint.h> and defines TYPE_BOUND if
-dnl <stdint.h> doesn't define it.
-AC_DEFUN([gl_STDINT_MISSING_BOUND],
-[
- AC_CACHE_CHECK([for $1], [gl_cv_stdint_$1],
- [AC_EGREP_CPP([found it], [#include <stdint.h>
-#ifdef $1
-found it
-#endif
- ], [gl_cv_stdint_$1=yes], [gl_cv_stdint_$1="$2"])])
- if test "$gl_cv_stdint_$1" != yes; then
- AC_DEFINE_UNQUOTED([$1], [$2], [$3])
- fi
-])
-
-dnl gl_STDINT_MISSING_BOUNDS(BOUNDS, INCLUDES)
-dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
-dnl if <stdint.h> doesn't define it.
-dnl Use this for types whose signedness is determined by the first letter
-dnl ('u' or not).
-AC_DEFUN([gl_STDINT_MISSING_BOUNDS],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in.
- AC_FOREACH([bound], [$1],
- [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
-changequote(,)dnl
- sed_unsigned='s,^\(U*\).*,\1,'
- sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
-changequote([,])dnl
- for bound in $1; do
- type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
- unsigned=`echo $bound | sed -e "$sed_unsigned" | tr U u`
- width=`echo $bound | sed -e 's,^U*INT,,' -e 's,_MIN,,' -e 's,_MAX,,'`
- limitkind=`echo $bound | sed -e "$sed_limitkind"`
- AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
- [AC_EGREP_CPP([found it], [#include <stdint.h>
-#ifdef $bound
-found it
-#endif
- ], [eval gl_cv_stdint_$bound=yes],
- [result=
- case $width in
- *8) widthlist="8 16 32 64" ;;
- *16) widthlist="16 32 64" ;;
- *32 | PTR | MAX | PTRDIFF) widthlist="32 64" ;;
- *64) widthlist="64" ;;
- esac
- for w in $widthlist; do
- if test -z "$result"; then
- AC_COMPILE_IFELSE([[$2
-#include <stdint.h>
-int verify[2 * (sizeof ($type) == sizeof (${unsigned}int${w}_t)) - 1];
- ]], [result=`echo "$unsigned" | tr u U`INT${w}${limitkind}])
- else
- break
- fi
- done
- if test -z "$result"; then
- result=no
- fi
- eval gl_cv_stdint_$bound=\$result
- ])])
- eval result=\$gl_cv_stdint_$bound
- if test "$result" != yes && test "$result" != no; then
- AC_DEFINE_UNQUOTED([$bound], [$result],
- [Define if <stdint.h> doesn't define it.])
- fi
- done
-])
-
-dnl gl_STDINT_MISSING_BOUNDS2(BOUNDS, INCLUDES)
-dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
-dnl if <stdint.h> doesn't define it.
-dnl Use this for types whose signedness is a priori unknown.
-AC_DEFUN([gl_STDINT_MISSING_BOUNDS2],
-[
- dnl Use a shell loop, to avoid bloating configure, and
- dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
- dnl config.h.in.
- AC_FOREACH([bound], [$1],
- [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
-changequote(,)dnl
- sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
-changequote([,])dnl
- for bound in $1; do
- type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
- limitkind=`echo $bound | sed -e "$sed_limitkind"`
- AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
- [AC_EGREP_CPP([found it], [#include <stdint.h>
-#ifdef $bound
-found it
-#endif
- ], [eval gl_cv_stdint_$bound=yes],
- [result=
- AC_COMPILE_IFELSE([[$2
- int verify[2 * (($type) -1 >= ($type) 0) - 1];
- ]],
- [eval gl_cv_${type}_signed=no],
- [eval gl_cv_${type}_signed=yes])
- if eval test \$gl_cv_${type}_signed = yes; then
- for w in 8 16 32 64; do
- if test -z "$result"; then
- AC_COMPILE_IFELSE([[$2
-#include <stdint.h>
-int verify[2 * (sizeof ($type) == sizeof (int${w}_t)) - 1];
- ]], [result=INT${w}${limitkind}])
- else
- break
- fi
- done
- else
- if test ${limitkind} = _MIN; then
- result=0
- else
- for w in 8 16 32 64; do
- if test -z "$result"; then
- AC_COMPILE_IFELSE([[$2
-#include <stdint.h>
-int verify[2 * (sizeof ($type) == sizeof (uint${w}_t)) - 1];
- ]], [result=UINT${w}${limitkind}])
- else
- break
- fi
- done
- fi
- fi
- if test -z "$result"; then
- result=no
- fi
- eval gl_cv_stdint_$bound=\$result
- ])])
- eval result=\$gl_cv_stdint_$bound
- if test "$result" != yes && test "$result" != no; then
- AC_DEFINE_UNQUOTED([$bound], [$result],
- [Define if <stdint.h> doesn't define it.])
- fi
- done
-])
-