Blame m4/intmax_t.m4

Packit Service a2489d
# intmax_t.m4 serial 8
Packit Service a2489d
dnl Copyright (C) 1997-2004, 2006-2007, 2009-2018 Free Software Foundation,
Packit Service a2489d
dnl 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.
Packit Service a2489d
Packit Service a2489d
AC_PREREQ([2.53])
Packit Service a2489d
Packit Service a2489d
# Define intmax_t to 'long' or 'long long'
Packit Service a2489d
# if it is not already defined in <stdint.h> or <inttypes.h>.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_AC_TYPE_INTMAX_T],
Packit Service a2489d
[
Packit Service a2489d
  dnl For simplicity, we assume that a header file defines 'intmax_t' if and
Packit Service a2489d
  dnl only if it defines 'uintmax_t'.
Packit Service a2489d
  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
Packit Service a2489d
  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
Packit Service a2489d
  if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
Packit Service a2489d
    AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
Packit Service a2489d
    test $ac_cv_type_long_long_int = yes \
Packit Service a2489d
      && ac_type='long long' \
Packit Service a2489d
      || ac_type='long'
Packit Service a2489d
    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
Packit Service a2489d
     [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
Packit Service a2489d
  else
Packit Service a2489d
    AC_DEFINE([HAVE_INTMAX_T], [1],
Packit Service a2489d
      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
Packit Service a2489d
  fi
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl An alternative would be to explicitly test for 'intmax_t'.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gt_AC_TYPE_INTMAX_T],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
Packit Service a2489d
  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
Packit Service a2489d
  AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
Packit Service a2489d
    [AC_COMPILE_IFELSE(
Packit Service a2489d
       [AC_LANG_PROGRAM(
Packit Service a2489d
          [[
Packit Service a2489d
#include <stddef.h>
Packit Service a2489d
#include <stdlib.h>
Packit Service a2489d
#if HAVE_STDINT_H_WITH_UINTMAX
Packit Service a2489d
#include <stdint.h>
Packit Service a2489d
#endif
Packit Service a2489d
#if HAVE_INTTYPES_H_WITH_UINTMAX
Packit Service a2489d
#include <inttypes.h>
Packit Service a2489d
#endif
Packit Service a2489d
          ]],
Packit Service a2489d
          [[intmax_t x = -1; return !x;]])],
Packit Service a2489d
       [gt_cv_c_intmax_t=yes],
Packit Service a2489d
       [gt_cv_c_intmax_t=no])])
Packit Service a2489d
  if test $gt_cv_c_intmax_t = yes; then
Packit Service a2489d
    AC_DEFINE([HAVE_INTMAX_T], [1],
Packit Service a2489d
      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
Packit Service a2489d
  else
Packit Service a2489d
    AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
Packit Service a2489d
    test $ac_cv_type_long_long_int = yes \
Packit Service a2489d
      && ac_type='long long' \
Packit Service a2489d
      || ac_type='long'
Packit Service a2489d
    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
Packit Service a2489d
     [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
Packit Service a2489d
  fi
Packit Service a2489d
])