Blame m4/stdint.m4

Packit Service a2489d
# stdint.m4 serial 51
Packit Service a2489d
dnl Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
dnl From Paul Eggert and Bruno Haible.
Packit Service a2489d
dnl Test whether <stdint.h> is supported or must be substituted.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN_ONCE([gl_STDINT_H],
Packit Service a2489d
[
Packit Service a2489d
  AC_PREREQ([2.59])dnl
Packit Service a2489d
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service a2489d
Packit Service a2489d
  AC_REQUIRE([gl_LIMITS_H])
Packit Service a2489d
  AC_REQUIRE([gt_TYPE_WINT_T])
Packit Service a2489d
Packit Service a2489d
  dnl Check for long long int and unsigned long long int.
Packit Service a2489d
  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
Packit Service a2489d
  if test $ac_cv_type_long_long_int = yes; then
Packit Service a2489d
    HAVE_LONG_LONG_INT=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_LONG_LONG_INT=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_LONG_LONG_INT])
Packit Service a2489d
  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
Packit Service a2489d
  if test $ac_cv_type_unsigned_long_long_int = yes; then
Packit Service a2489d
    HAVE_UNSIGNED_LONG_LONG_INT=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_UNSIGNED_LONG_LONG_INT=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
Packit Service a2489d
Packit Service a2489d
  dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
Packit Service a2489d
  AC_CHECK_HEADERS_ONCE([wchar.h])
Packit Service a2489d
  if test $ac_cv_header_wchar_h = yes; then
Packit Service a2489d
    HAVE_WCHAR_H=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_WCHAR_H=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_WCHAR_H])
Packit Service a2489d
Packit Service a2489d
  dnl Check for <inttypes.h>.
Packit Service a2489d
  dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
Packit Service a2489d
  if test $ac_cv_header_inttypes_h = yes; then
Packit Service a2489d
    HAVE_INTTYPES_H=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_INTTYPES_H=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_INTTYPES_H])
Packit Service a2489d
Packit Service a2489d
  dnl Check for <sys/types.h>.
Packit Service a2489d
  dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
Packit Service a2489d
  if test $ac_cv_header_sys_types_h = yes; then
Packit Service a2489d
    HAVE_SYS_TYPES_H=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_SYS_TYPES_H=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_SYS_TYPES_H])
Packit Service a2489d
Packit Service a2489d
  gl_CHECK_NEXT_HEADERS([stdint.h])
Packit Service a2489d
  if test $ac_cv_header_stdint_h = yes; then
Packit Service a2489d
    HAVE_STDINT_H=1
Packit Service a2489d
  else
Packit Service a2489d
    HAVE_STDINT_H=0
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([HAVE_STDINT_H])
Packit Service a2489d
Packit Service a2489d
  dnl Now see whether we need a substitute <stdint.h>.
Packit Service a2489d
  if test $ac_cv_header_stdint_h = yes; then
Packit Service a2489d
    AC_CACHE_CHECK([whether stdint.h conforms to C99],
Packit Service a2489d
      [gl_cv_header_working_stdint_h],
Packit Service a2489d
      [gl_cv_header_working_stdint_h=no
Packit Service a2489d
       AC_COMPILE_IFELSE([
Packit Service a2489d
         AC_LANG_PROGRAM([[
Packit Service a2489d
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
Packit Service a2489d
#define __STDC_CONSTANT_MACROS 1
Packit Service a2489d
#define __STDC_LIMIT_MACROS 1
Packit Service a2489d
#include <stdint.h>
Packit Service a2489d
/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
Packit Service a2489d
#if !(defined WCHAR_MIN && defined WCHAR_MAX)
Packit Service a2489d
#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
Packit Service a2489d
#endif
Packit Service a2489d
]
Packit Service a2489d
gl_STDINT_INCLUDES
Packit Service a2489d
[
Packit Service a2489d
#ifdef INT8_MAX
Packit Service a2489d
int8_t a1 = INT8_MAX;
Packit Service a2489d
int8_t a1min = INT8_MIN;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT16_MAX
Packit Service a2489d
int16_t a2 = INT16_MAX;
Packit Service a2489d
int16_t a2min = INT16_MIN;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT32_MAX
Packit Service a2489d
int32_t a3 = INT32_MAX;
Packit Service a2489d
int32_t a3min = INT32_MIN;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT64_MAX
Packit Service a2489d
int64_t a4 = INT64_MAX;
Packit Service a2489d
int64_t a4min = INT64_MIN;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT8_MAX
Packit Service a2489d
uint8_t b1 = UINT8_MAX;
Packit Service a2489d
#else
Packit Service a2489d
typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT16_MAX
Packit Service a2489d
uint16_t b2 = UINT16_MAX;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT32_MAX
Packit Service a2489d
uint32_t b3 = UINT32_MAX;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT64_MAX
Packit Service a2489d
uint64_t b4 = UINT64_MAX;
Packit Service a2489d
#endif
Packit Service a2489d
int_least8_t c1 = INT8_C (0x7f);
Packit Service a2489d
int_least8_t c1max = INT_LEAST8_MAX;
Packit Service a2489d
int_least8_t c1min = INT_LEAST8_MIN;
Packit Service a2489d
int_least16_t c2 = INT16_C (0x7fff);
Packit Service a2489d
int_least16_t c2max = INT_LEAST16_MAX;
Packit Service a2489d
int_least16_t c2min = INT_LEAST16_MIN;
Packit Service a2489d
int_least32_t c3 = INT32_C (0x7fffffff);
Packit Service a2489d
int_least32_t c3max = INT_LEAST32_MAX;
Packit Service a2489d
int_least32_t c3min = INT_LEAST32_MIN;
Packit Service a2489d
int_least64_t c4 = INT64_C (0x7fffffffffffffff);
Packit Service a2489d
int_least64_t c4max = INT_LEAST64_MAX;
Packit Service a2489d
int_least64_t c4min = INT_LEAST64_MIN;
Packit Service a2489d
uint_least8_t d1 = UINT8_C (0xff);
Packit Service a2489d
uint_least8_t d1max = UINT_LEAST8_MAX;
Packit Service a2489d
uint_least16_t d2 = UINT16_C (0xffff);
Packit Service a2489d
uint_least16_t d2max = UINT_LEAST16_MAX;
Packit Service a2489d
uint_least32_t d3 = UINT32_C (0xffffffff);
Packit Service a2489d
uint_least32_t d3max = UINT_LEAST32_MAX;
Packit Service a2489d
uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
Packit Service a2489d
uint_least64_t d4max = UINT_LEAST64_MAX;
Packit Service a2489d
int_fast8_t e1 = INT_FAST8_MAX;
Packit Service a2489d
int_fast8_t e1min = INT_FAST8_MIN;
Packit Service a2489d
int_fast16_t e2 = INT_FAST16_MAX;
Packit Service a2489d
int_fast16_t e2min = INT_FAST16_MIN;
Packit Service a2489d
int_fast32_t e3 = INT_FAST32_MAX;
Packit Service a2489d
int_fast32_t e3min = INT_FAST32_MIN;
Packit Service a2489d
int_fast64_t e4 = INT_FAST64_MAX;
Packit Service a2489d
int_fast64_t e4min = INT_FAST64_MIN;
Packit Service a2489d
uint_fast8_t f1 = UINT_FAST8_MAX;
Packit Service a2489d
uint_fast16_t f2 = UINT_FAST16_MAX;
Packit Service a2489d
uint_fast32_t f3 = UINT_FAST32_MAX;
Packit Service a2489d
uint_fast64_t f4 = UINT_FAST64_MAX;
Packit Service a2489d
#ifdef INTPTR_MAX
Packit Service a2489d
intptr_t g = INTPTR_MAX;
Packit Service a2489d
intptr_t gmin = INTPTR_MIN;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINTPTR_MAX
Packit Service a2489d
uintptr_t h = UINTPTR_MAX;
Packit Service a2489d
#endif
Packit Service a2489d
intmax_t i = INTMAX_MAX;
Packit Service a2489d
uintmax_t j = UINTMAX_MAX;
Packit Service a2489d
Packit Service a2489d
/* Check that SIZE_MAX has the correct type, if possible.  */
Packit Service a2489d
#if 201112 <= __STDC_VERSION__
Packit Service a2489d
int k = _Generic (SIZE_MAX, size_t: 0);
Packit Service a2489d
#elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
Packit Service a2489d
       || (0x5110 <= __SUNPRO_C && !__STDC__))
Packit Service a2489d
extern size_t k;
Packit Service a2489d
extern __typeof__ (SIZE_MAX) k;
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
#include <limits.h> /* for CHAR_BIT */
Packit Service a2489d
#define TYPE_MINIMUM(t) \
Packit Service a2489d
  ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
Packit Service a2489d
#define TYPE_MAXIMUM(t) \
Packit Service a2489d
  ((t) ((t) 0 < (t) -1 \
Packit Service a2489d
        ? (t) -1 \
Packit Service a2489d
        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
Packit Service a2489d
struct s {
Packit Service a2489d
  int check_PTRDIFF:
Packit Service a2489d
      PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
Packit Service a2489d
      && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
Packit Service a2489d
      ? 1 : -1;
Packit Service a2489d
  /* Detect bug in FreeBSD 6.0 / ia64.  */
Packit Service a2489d
  int check_SIG_ATOMIC:
Packit Service a2489d
      SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
Packit Service a2489d
      && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
Packit Service a2489d
      ? 1 : -1;
Packit Service a2489d
  int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
Packit Service a2489d
  int check_WCHAR:
Packit Service a2489d
      WCHAR_MIN == TYPE_MINIMUM (wchar_t)
Packit Service a2489d
      && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
Packit Service a2489d
      ? 1 : -1;
Packit Service a2489d
  /* Detect bug in mingw.  */
Packit Service a2489d
  int check_WINT:
Packit Service a2489d
      WINT_MIN == TYPE_MINIMUM (wint_t)
Packit Service a2489d
      && WINT_MAX == TYPE_MAXIMUM (wint_t)
Packit Service a2489d
      ? 1 : -1;
Packit Service a2489d
Packit Service a2489d
  /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
Packit Service a2489d
  int check_UINT8_C:
Packit Service a2489d
        (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
Packit Service a2489d
  int check_UINT16_C:
Packit Service a2489d
        (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
Packit Service a2489d
Packit Service a2489d
  /* Detect bugs in OpenBSD 3.9 stdint.h.  */
Packit Service a2489d
#ifdef UINT8_MAX
Packit Service a2489d
  int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT16_MAX
Packit Service a2489d
  int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT32_MAX
Packit Service a2489d
  int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT64_MAX
Packit Service a2489d
  int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
Packit Service a2489d
#endif
Packit Service a2489d
  int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
Packit Service a2489d
  int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
Packit Service a2489d
  int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
Packit Service a2489d
  int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
Packit Service a2489d
  int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
Packit Service a2489d
};
Packit Service a2489d
         ]])],
Packit Service a2489d
         [dnl Determine whether the various *_MIN, *_MAX macros are usable
Packit Service a2489d
          dnl in preprocessor expression. We could do it by compiling a test
Packit Service a2489d
          dnl program for each of these macros. It is faster to run a program
Packit Service a2489d
          dnl that inspects the macro expansion.
Packit Service a2489d
          dnl This detects a bug on HP-UX 11.23/ia64.
Packit Service a2489d
          AC_RUN_IFELSE([
Packit Service a2489d
            AC_LANG_PROGRAM([[
Packit Service a2489d
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
Packit Service a2489d
#define __STDC_CONSTANT_MACROS 1
Packit Service a2489d
#define __STDC_LIMIT_MACROS 1
Packit Service a2489d
#include <stdint.h>
Packit Service a2489d
]
Packit Service a2489d
gl_STDINT_INCLUDES
Packit Service a2489d
[
Packit Service a2489d
#include <stdio.h>
Packit Service a2489d
#include <string.h>
Packit Service a2489d
#define MVAL(macro) MVAL1(macro)
Packit Service a2489d
#define MVAL1(expression) #expression
Packit Service a2489d
static const char *macro_values[] =
Packit Service a2489d
  {
Packit Service a2489d
#ifdef INT8_MAX
Packit Service a2489d
    MVAL (INT8_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT16_MAX
Packit Service a2489d
    MVAL (INT16_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT32_MAX
Packit Service a2489d
    MVAL (INT32_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef INT64_MAX
Packit Service a2489d
    MVAL (INT64_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT8_MAX
Packit Service a2489d
    MVAL (UINT8_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT16_MAX
Packit Service a2489d
    MVAL (UINT16_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT32_MAX
Packit Service a2489d
    MVAL (UINT32_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
#ifdef UINT64_MAX
Packit Service a2489d
    MVAL (UINT64_MAX),
Packit Service a2489d
#endif
Packit Service a2489d
    NULL
Packit Service a2489d
  };
Packit Service a2489d
]], [[
Packit Service a2489d
  const char **mv;
Packit Service a2489d
  for (mv = macro_values; *mv != NULL; mv++)
Packit Service a2489d
    {
Packit Service a2489d
      const char *value = *mv;
Packit Service a2489d
      /* Test whether it looks like a cast expression.  */
Packit Service a2489d
      if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
Packit Service a2489d
          || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
Packit Service a2489d
          || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
Packit Service a2489d
          || strncmp (value, "((int)"/*)*/, 6) == 0
Packit Service a2489d
          || strncmp (value, "((signed short)"/*)*/, 15) == 0
Packit Service a2489d
          || strncmp (value, "((signed char)"/*)*/, 14) == 0)
Packit Service a2489d
        return mv - macro_values + 1;
Packit Service a2489d
    }
Packit Service a2489d
  return 0;
Packit Service a2489d
]])],
Packit Service a2489d
              [gl_cv_header_working_stdint_h=yes],
Packit Service a2489d
              [],
Packit Service a2489d
              [case "$host_os" in
Packit Service a2489d
                         # Guess yes on native Windows.
Packit Service a2489d
                 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;;
Packit Service a2489d
                         # In general, assume it works.
Packit Service a2489d
                 *)      gl_cv_header_working_stdint_h="guessing yes" ;;
Packit Service a2489d
               esac
Packit Service a2489d
              ])
Packit Service a2489d
         ])
Packit Service a2489d
      ])
Packit Service a2489d
  fi
Packit Service a2489d
Packit Service a2489d
  HAVE_C99_STDINT_H=0
Packit Service a2489d
  HAVE_SYS_BITYPES_H=0
Packit Service a2489d
  HAVE_SYS_INTTYPES_H=0
Packit Service a2489d
  STDINT_H=stdint.h
Packit Service a2489d
  case "$gl_cv_header_working_stdint_h" in
Packit Service a2489d
    *yes)
Packit Service a2489d
      HAVE_C99_STDINT_H=1
Packit Service a2489d
      dnl Now see whether the system <stdint.h> works without
Packit Service a2489d
      dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
Packit Service a2489d
      AC_CACHE_CHECK([whether stdint.h predates C++11],
Packit Service a2489d
        [gl_cv_header_stdint_predates_cxx11_h],
Packit Service a2489d
        [gl_cv_header_stdint_predates_cxx11_h=yes
Packit Service a2489d
         AC_COMPILE_IFELSE([
Packit Service a2489d
           AC_LANG_PROGRAM([[
Packit Service a2489d
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
Packit Service a2489d
#include <stdint.h>
Packit Service a2489d
]
Packit Service a2489d
gl_STDINT_INCLUDES
Packit Service a2489d
[
Packit Service a2489d
intmax_t im = INTMAX_MAX;
Packit Service a2489d
int32_t i32 = INT32_C (0x7fffffff);
Packit Service a2489d
           ]])],
Packit Service a2489d
           [gl_cv_header_stdint_predates_cxx11_h=no])])
Packit Service a2489d
Packit Service a2489d
      if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
Packit Service a2489d
        AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
Packit Service a2489d
                  [Define to 1 if the system <stdint.h> predates C++11.])
Packit Service a2489d
        AC_DEFINE([__STDC_LIMIT_MACROS], [1],
Packit Service a2489d
                  [Define to 1 if the system <stdint.h> predates C++11.])
Packit Service a2489d
      fi
Packit Service a2489d
      AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
Packit Service a2489d
        [gl_cv_header_stdint_width],
Packit Service a2489d
        [gl_cv_header_stdint_width=no
Packit Service a2489d
         AC_COMPILE_IFELSE(
Packit Service a2489d
           [AC_LANG_PROGRAM([[
Packit Service a2489d
              /* Work if build is not clean.  */
Packit Service a2489d
              #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
Packit Service a2489d
              #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
Packit Service a2489d
               #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
Packit Service a2489d
              #endif
Packit Service a2489d
              #include <stdint.h>
Packit Service a2489d
              ]gl_STDINT_INCLUDES[
Packit Service a2489d
              int iw = UINTMAX_WIDTH;
Packit Service a2489d
              ]])],
Packit Service a2489d
           [gl_cv_header_stdint_width=yes])])
Packit Service a2489d
      if test "$gl_cv_header_stdint_width" = yes; then
Packit Service a2489d
        STDINT_H=
Packit Service a2489d
      fi
Packit Service a2489d
      ;;
Packit Service a2489d
    *)
Packit Service a2489d
      dnl Check for <sys/inttypes.h>, and for
Packit Service a2489d
      dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
Packit Service a2489d
      AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
Packit Service a2489d
      if test $ac_cv_header_sys_inttypes_h = yes; then
Packit Service a2489d
        HAVE_SYS_INTTYPES_H=1
Packit Service a2489d
      fi
Packit Service a2489d
      if test $ac_cv_header_sys_bitypes_h = yes; then
Packit Service a2489d
        HAVE_SYS_BITYPES_H=1
Packit Service a2489d
      fi
Packit Service a2489d
      gl_STDINT_TYPE_PROPERTIES
Packit Service a2489d
      ;;
Packit Service a2489d
  esac
Packit Service a2489d
Packit Service a2489d
  dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
Packit Service a2489d
  LIMITS_H=limits.h
Packit Service a2489d
  AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
Packit Service a2489d
Packit Service a2489d
  AC_SUBST([HAVE_C99_STDINT_H])
Packit Service a2489d
  AC_SUBST([HAVE_SYS_BITYPES_H])
Packit Service a2489d
  AC_SUBST([HAVE_SYS_INTTYPES_H])
Packit Service a2489d
  AC_SUBST([STDINT_H])
Packit Service a2489d
  AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
Packit Service a2489d
dnl Determine the size of each of the given types in bits.
Packit Service a2489d
AC_DEFUN([gl_STDINT_BITSIZEOF],
Packit Service a2489d
[
Packit Service a2489d
  dnl Use a shell loop, to avoid bloating configure, and
Packit Service a2489d
  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
Packit Service a2489d
  dnl   config.h.in,
Packit Service a2489d
  dnl - extra AC_SUBST calls, so that the right substitutions are made.
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
Packit Service a2489d
       [Define to the number of bits in type ']gltype['.])])
Packit Service a2489d
  for gltype in $1 ; do
Packit Service a2489d
    AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
Packit Service a2489d
      [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT],
Packit Service a2489d
         [$2
Packit Service a2489d
#include <limits.h>], [result=unknown])
Packit Service a2489d
       eval gl_cv_bitsizeof_${gltype}=\$result
Packit Service a2489d
      ])
Packit Service a2489d
    eval result=\$gl_cv_bitsizeof_${gltype}
Packit Service a2489d
    if test $result = unknown; then
Packit Service a2489d
      dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
Packit Service a2489d
      dnl do a syntax check even on unused #if conditions and give an error
Packit Service a2489d
      dnl on valid C code like this:
Packit Service a2489d
      dnl   #if 0
Packit Service a2489d
      dnl   # if  > 32
Packit Service a2489d
      dnl   # endif
Packit Service a2489d
      dnl   #endif
Packit Service a2489d
      result=0
Packit Service a2489d
    fi
Packit Service a2489d
    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
Packit Service a2489d
    AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
Packit Service a2489d
    eval BITSIZEOF_${GLTYPE}=\$result
Packit Service a2489d
  done
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
Packit Service a2489d
dnl Determine the signedness of each of the given types.
Packit Service a2489d
dnl Define HAVE_SIGNED_TYPE if type is signed.
Packit Service a2489d
AC_DEFUN([gl_CHECK_TYPES_SIGNED],
Packit Service a2489d
[
Packit Service a2489d
  dnl Use a shell loop, to avoid bloating configure, and
Packit Service a2489d
  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
Packit Service a2489d
  dnl   config.h.in,
Packit Service a2489d
  dnl - extra AC_SUBST calls, so that the right substitutions are made.
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
Packit Service a2489d
       [Define to 1 if ']gltype[' is a signed integer type.])])
Packit Service a2489d
  for gltype in $1 ; do
Packit Service a2489d
    AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
Packit Service a2489d
      [AC_COMPILE_IFELSE(
Packit Service a2489d
         [AC_LANG_PROGRAM([$2[
Packit Service a2489d
            int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
Packit Service a2489d
         result=yes, result=no)
Packit Service a2489d
       eval gl_cv_type_${gltype}_signed=\$result
Packit Service a2489d
      ])
Packit Service a2489d
    eval result=\$gl_cv_type_${gltype}_signed
Packit Service a2489d
    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
Packit Service a2489d
    if test "$result" = yes; then
Packit Service a2489d
      AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
Packit Service a2489d
      eval HAVE_SIGNED_${GLTYPE}=1
Packit Service a2489d
    else
Packit Service a2489d
      eval HAVE_SIGNED_${GLTYPE}=0
Packit Service a2489d
    fi
Packit Service a2489d
  done
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
Packit Service a2489d
dnl Determine the suffix to use for integer constants of the given types.
Packit Service a2489d
dnl Define t_SUFFIX for each such type.
Packit Service a2489d
AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
Packit Service a2489d
[
Packit Service a2489d
  dnl Use a shell loop, to avoid bloating configure, and
Packit Service a2489d
  dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
Packit Service a2489d
  dnl   config.h.in,
Packit Service a2489d
  dnl - extra AC_SUBST calls, so that the right substitutions are made.
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
Packit Service a2489d
       [Define to l, ll, u, ul, ull, etc., as suitable for
Packit Service a2489d
        constants of type ']gltype['.])])
Packit Service a2489d
  for gltype in $1 ; do
Packit Service a2489d
    AC_CACHE_CHECK([for $gltype integer literal suffix],
Packit Service a2489d
      [gl_cv_type_${gltype}_suffix],
Packit Service a2489d
      [eval gl_cv_type_${gltype}_suffix=no
Packit Service a2489d
       eval result=\$gl_cv_type_${gltype}_signed
Packit Service a2489d
       if test "$result" = yes; then
Packit Service a2489d
         glsufu=
Packit Service a2489d
       else
Packit Service a2489d
         glsufu=u
Packit Service a2489d
       fi
Packit Service a2489d
       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
Packit Service a2489d
         case $glsuf in
Packit Service a2489d
           '')  gltype1='int';;
Packit Service a2489d
           l)   gltype1='long int';;
Packit Service a2489d
           ll)  gltype1='long long int';;
Packit Service a2489d
           i64) gltype1='__int64';;
Packit Service a2489d
           u)   gltype1='unsigned int';;
Packit Service a2489d
           ul)  gltype1='unsigned long int';;
Packit Service a2489d
           ull) gltype1='unsigned long long int';;
Packit Service a2489d
           ui64)gltype1='unsigned __int64';;
Packit Service a2489d
         esac
Packit Service a2489d
         AC_COMPILE_IFELSE(
Packit Service a2489d
           [AC_LANG_PROGRAM([$2[
Packit Service a2489d
              extern $gltype foo;
Packit Service a2489d
              extern $gltype1 foo;]])],
Packit Service a2489d
           [eval gl_cv_type_${gltype}_suffix=\$glsuf])
Packit Service a2489d
         eval result=\$gl_cv_type_${gltype}_suffix
Packit Service a2489d
         test "$result" != no && break
Packit Service a2489d
       done])
Packit Service a2489d
    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
Packit Service a2489d
    eval result=\$gl_cv_type_${gltype}_suffix
Packit Service a2489d
    test "$result" = no && result=
Packit Service a2489d
    eval ${GLTYPE}_SUFFIX=\$result
Packit Service a2489d
    AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
Packit Service a2489d
  done
Packit Service a2489d
  m4_foreach_w([gltype], [$1],
Packit Service a2489d
    [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl gl_STDINT_INCLUDES
Packit Service a2489d
AC_DEFUN([gl_STDINT_INCLUDES],
Packit Service a2489d
[[
Packit Service a2489d
  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service a2489d
     included before <wchar.h>.  */
Packit Service a2489d
  #include <stddef.h>
Packit Service a2489d
  #include <signal.h>
Packit Service a2489d
  #if HAVE_WCHAR_H
Packit Service a2489d
  # include <stdio.h>
Packit Service a2489d
  # include <time.h>
Packit Service a2489d
  # include <wchar.h>
Packit Service a2489d
  #endif
Packit Service a2489d
]])
Packit Service a2489d
Packit Service a2489d
dnl gl_STDINT_TYPE_PROPERTIES
Packit Service a2489d
dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
Packit Service a2489d
dnl of interest to stdint.in.h.
Packit Service a2489d
AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_MULTIARCH])
Packit Service a2489d
  if test $APPLE_UNIVERSAL_BUILD = 0; then
Packit Service a2489d
    gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
Packit Service a2489d
      [gl_STDINT_INCLUDES])
Packit Service a2489d
  fi
Packit Service a2489d
  gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
Packit Service a2489d
    [gl_STDINT_INCLUDES])
Packit Service a2489d
  gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
Packit Service a2489d
    [gl_STDINT_INCLUDES])
Packit Service a2489d
  gl_cv_type_ptrdiff_t_signed=yes
Packit Service a2489d
  gl_cv_type_size_t_signed=no
Packit Service a2489d
  if test $APPLE_UNIVERSAL_BUILD = 0; then
Packit Service a2489d
    gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
Packit Service a2489d
      [gl_STDINT_INCLUDES])
Packit Service a2489d
  fi
Packit Service a2489d
  gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
Packit Service a2489d
    [gl_STDINT_INCLUDES])
Packit Service a2489d
Packit Service a2489d
  dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
Packit Service a2489d
  dnl requirement that wint_t is "unchanged by default argument promotions".
Packit Service a2489d
  dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
Packit Service a2489d
  dnl Set the variable BITSIZEOF_WINT_T accordingly.
Packit Service a2489d
  if test $GNULIB_OVERRIDES_WINT_T = 1; then
Packit Service a2489d
    BITSIZEOF_WINT_T=32
Packit Service a2489d
  fi
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
Packit Service a2489d
dnl Remove this when we can assume autoconf >= 2.61.
Packit Service a2489d
m4_ifdef([AC_COMPUTE_INT], [], [
Packit Service a2489d
  AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
Packit Service a2489d
])