Blame m4/stdint.m4

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