Blame m4/inttypes.m4

Packit Service fdd496
# inttypes.m4 serial 26
Packit Service fdd496
dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
Packit Service fdd496
dnl This file is free software; the Free Software Foundation
Packit Service fdd496
dnl gives unlimited permission to copy and/or distribute it,
Packit Service fdd496
dnl with or without modifications, as long as this notice is preserved.
Packit Service fdd496
Packit Service fdd496
dnl From Derek Price, Bruno Haible.
Packit Service fdd496
dnl Test whether <inttypes.h> is supported or must be substituted.
Packit Service fdd496
Packit Service fdd496
AC_DEFUN([gl_INTTYPES_H],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gl_INTTYPES_INCOMPLETE])
Packit Service fdd496
  gl_INTTYPES_PRI_SCN
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gl_STDINT_H])
Packit Service fdd496
  AC_CHECK_HEADERS_ONCE([inttypes.h])
Packit Service fdd496
Packit Service fdd496
  dnl Override <inttypes.h> always, so that the portability warnings work.
Packit Service fdd496
  AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
Packit Service fdd496
  gl_CHECK_NEXT_HEADERS([inttypes.h])
Packit Service fdd496
Packit Service fdd496
  AC_REQUIRE([gl_MULTIARCH])
Packit Service fdd496
Packit Service fdd496
  dnl Check for declarations of anything we want to poison if the
Packit Service fdd496
  dnl corresponding gnulib module is not in use.
Packit Service fdd496
  gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
Packit Service fdd496
    ]], [imaxabs imaxdiv strtoimax strtoumax])
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
# Ensure that the PRI* and SCN* macros are defined appropriately.
Packit Service fdd496
AC_DEFUN([gl_INTTYPES_PRI_SCN],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gt_INTTYPES_PRI])
Packit Service fdd496
Packit Service fdd496
  PRIPTR_PREFIX=
Packit Service fdd496
  if test -n "$STDINT_H"; then
Packit Service fdd496
    dnl Using the gnulib <stdint.h>. It always defines intptr_t to 'long'.
Packit Service fdd496
    PRIPTR_PREFIX='"l"'
Packit Service fdd496
  else
Packit Service fdd496
    dnl Using the system's <stdint.h>.
Packit Service fdd496
    for glpfx in '' l ll I64; do
Packit Service fdd496
      case $glpfx in
Packit Service fdd496
        '')  gltype1='int';;
Packit Service fdd496
        l)   gltype1='long int';;
Packit Service fdd496
        ll)  gltype1='long long int';;
Packit Service fdd496
        I64) gltype1='__int64';;
Packit Service fdd496
      esac
Packit Service fdd496
      AC_COMPILE_IFELSE(
Packit Service fdd496
        [AC_LANG_PROGRAM([[#include <stdint.h>
Packit Service fdd496
           extern intptr_t foo;
Packit Service fdd496
           extern $gltype1 foo;]])],
Packit Service fdd496
        [PRIPTR_PREFIX='"'$glpfx'"'])
Packit Service fdd496
      test -n "$PRIPTR_PREFIX" && break
Packit Service fdd496
    done
Packit Service fdd496
  fi
Packit Service fdd496
  AC_SUBST([PRIPTR_PREFIX])
Packit Service fdd496
Packit Service fdd496
  gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
Packit Service fdd496
    [INT32_MAX_LT_INTMAX_MAX],
Packit Service fdd496
    [defined INT32_MAX && defined INTMAX_MAX],
Packit Service fdd496
    [INT32_MAX < INTMAX_MAX],
Packit Service fdd496
    [sizeof (int) < sizeof (long long int)])
Packit Service fdd496
  if test $APPLE_UNIVERSAL_BUILD = 0; then
Packit Service fdd496
    gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
Packit Service fdd496
      [INT64_MAX_EQ_LONG_MAX],
Packit Service fdd496
      [defined INT64_MAX],
Packit Service fdd496
      [INT64_MAX == LONG_MAX],
Packit Service fdd496
      [sizeof (long long int) == sizeof (long int)])
Packit Service fdd496
  else
Packit Service fdd496
    INT64_MAX_EQ_LONG_MAX=-1
Packit Service fdd496
  fi
Packit Service fdd496
  gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
Packit Service fdd496
    [UINT32_MAX_LT_UINTMAX_MAX],
Packit Service fdd496
    [defined UINT32_MAX && defined UINTMAX_MAX],
Packit Service fdd496
    [UINT32_MAX < UINTMAX_MAX],
Packit Service fdd496
    [sizeof (unsigned int) < sizeof (unsigned long long int)])
Packit Service fdd496
  if test $APPLE_UNIVERSAL_BUILD = 0; then
Packit Service fdd496
    gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
Packit Service fdd496
      [UINT64_MAX_EQ_ULONG_MAX],
Packit Service fdd496
      [defined UINT64_MAX],
Packit Service fdd496
      [UINT64_MAX == ULONG_MAX],
Packit Service fdd496
      [sizeof (unsigned long long int) == sizeof (unsigned long int)])
Packit Service fdd496
  else
Packit Service fdd496
    UINT64_MAX_EQ_ULONG_MAX=-1
Packit Service fdd496
  fi
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
# Define the symbol $1 to be 1 if the condition is true, 0 otherwise.
Packit Service fdd496
# If $2 is true, the condition is $3; otherwise if long long int is supported
Packit Service fdd496
# approximate the condition with $4; otherwise, assume the condition is false.
Packit Service fdd496
# The condition should work on all C99 platforms; the approximations should be
Packit Service fdd496
# good enough to work on all practical pre-C99 platforms.
Packit Service fdd496
# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants.
Packit Service fdd496
AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION],
Packit Service fdd496
[
Packit Service fdd496
  AC_CACHE_CHECK([whether $3],
Packit Service fdd496
    [gl_cv_test_$1],
Packit Service fdd496
    [AC_COMPILE_IFELSE(
Packit Service fdd496
       [AC_LANG_PROGRAM(
Packit Service fdd496
          [[/* Work also in C++ mode.  */
Packit Service fdd496
            #define __STDC_LIMIT_MACROS 1
Packit Service fdd496
Packit Service fdd496
            /* Work if build is not clean.  */
Packit Service fdd496
            #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H
Packit Service fdd496
Packit Service fdd496
            #include <limits.h>
Packit Service fdd496
            #if HAVE_STDINT_H
Packit Service fdd496
             #include <stdint.h>
Packit Service fdd496
            #endif
Packit Service fdd496
Packit Service fdd496
            #if $2
Packit Service fdd496
             #define CONDITION ($3)
Packit Service fdd496
            #elif HAVE_LONG_LONG_INT
Packit Service fdd496
             #define CONDITION ($4)
Packit Service fdd496
            #else
Packit Service fdd496
             #define CONDITION 0
Packit Service fdd496
            #endif
Packit Service fdd496
            int test[CONDITION ? 1 : -1];]])],
Packit Service fdd496
       [gl_cv_test_$1=yes],
Packit Service fdd496
       [gl_cv_test_$1=no])])
Packit Service fdd496
  if test $gl_cv_test_$1 = yes; then
Packit Service fdd496
    $1=1;
Packit Service fdd496
  else
Packit Service fdd496
    $1=0;
Packit Service fdd496
  fi
Packit Service fdd496
  AC_SUBST([$1])
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
Packit Service fdd496
[
Packit Service fdd496
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit Service fdd496
  AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
Packit Service fdd496
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
Packit Service fdd496
[
Packit Service fdd496
  GNULIB_IMAXABS=0;      AC_SUBST([GNULIB_IMAXABS])
Packit Service fdd496
  GNULIB_IMAXDIV=0;      AC_SUBST([GNULIB_IMAXDIV])
Packit Service fdd496
  GNULIB_STRTOIMAX=0;    AC_SUBST([GNULIB_STRTOIMAX])
Packit Service fdd496
  GNULIB_STRTOUMAX=0;    AC_SUBST([GNULIB_STRTOUMAX])
Packit Service fdd496
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit Service fdd496
  HAVE_DECL_IMAXABS=1;   AC_SUBST([HAVE_DECL_IMAXABS])
Packit Service fdd496
  HAVE_DECL_IMAXDIV=1;   AC_SUBST([HAVE_DECL_IMAXDIV])
Packit Service fdd496
  HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
Packit Service fdd496
  HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
Packit Service fdd496
  REPLACE_STRTOIMAX=0;   AC_SUBST([REPLACE_STRTOIMAX])
Packit Service fdd496
  REPLACE_STRTOUMAX=0;   AC_SUBST([REPLACE_STRTOUMAX])
Packit Service fdd496
  INT32_MAX_LT_INTMAX_MAX=1;  AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
Packit Service fdd496
  INT64_MAX_EQ_LONG_MAX='defined _LP64';  AC_SUBST([INT64_MAX_EQ_LONG_MAX])
Packit Service fdd496
  PRI_MACROS_BROKEN=0;   AC_SUBST([PRI_MACROS_BROKEN])
Packit Service fdd496
  PRIPTR_PREFIX=__PRIPTR_PREFIX;  AC_SUBST([PRIPTR_PREFIX])
Packit Service fdd496
  UINT32_MAX_LT_UINTMAX_MAX=1;  AC_SUBST([UINT32_MAX_LT_UINTMAX_MAX])
Packit Service fdd496
  UINT64_MAX_EQ_ULONG_MAX='defined _LP64';  AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
Packit Service fdd496
])