Blame m4/intmax_t.m4

Packit Service 4684c1
# intmax_t.m4 serial 9
Packit Service 4684c1
dnl Copyright (C) 1997-2004, 2006-2007, 2009-2020 Free Software Foundation,
Packit Service 4684c1
dnl Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
dnl From Paul Eggert.
Packit Service 4684c1
Packit Service 4684c1
AC_PREREQ([2.53])
Packit Service 4684c1
Packit Service 4684c1
# Define intmax_t to 'long' or 'long long'
Packit Service 4684c1
# if it is not already defined in <stdint.h> or <inttypes.h>.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_AC_TYPE_INTMAX_T],
Packit Service 4684c1
[
Packit Service 4684c1
  dnl For simplicity, we assume that a header file defines 'intmax_t' if and
Packit Service 4684c1
  dnl only if it defines 'uintmax_t'.
Packit Service 4684c1
  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
Packit Service 4684c1
  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
Packit Service 4684c1
  if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
Packit Service 4684c1
    AC_DEFINE_UNQUOTED([intmax_t], [long long],
Packit Service 4684c1
     [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
Packit Service 4684c1
  else
Packit Service 4684c1
    AC_DEFINE([HAVE_INTMAX_T], [1],
Packit Service 4684c1
      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
Packit Service 4684c1
  fi
Packit Service 4684c1
])
Packit Service 4684c1
Packit Service 4684c1
dnl An alternative would be to explicitly test for 'intmax_t'.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gt_AC_TYPE_INTMAX_T],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
Packit Service 4684c1
  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
Packit Service 4684c1
  AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
Packit Service 4684c1
    [AC_COMPILE_IFELSE(
Packit Service 4684c1
       [AC_LANG_PROGRAM(
Packit Service 4684c1
          [[
Packit Service 4684c1
#include <stddef.h>
Packit Service 4684c1
#include <stdlib.h>
Packit Service 4684c1
#if HAVE_STDINT_H_WITH_UINTMAX
Packit Service 4684c1
#include <stdint.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
#if HAVE_INTTYPES_H_WITH_UINTMAX
Packit Service 4684c1
#include <inttypes.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
          ]],
Packit Service 4684c1
          [[intmax_t x = -1; return !x;]])],
Packit Service 4684c1
       [gt_cv_c_intmax_t=yes],
Packit Service 4684c1
       [gt_cv_c_intmax_t=no])])
Packit Service 4684c1
  if test $gt_cv_c_intmax_t = yes; then
Packit Service 4684c1
    AC_DEFINE([HAVE_INTMAX_T], [1],
Packit Service 4684c1
      [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
Packit Service 4684c1
  else
Packit Service 4684c1
    AC_DEFINE_UNQUOTED([intmax_t], [long long],
Packit Service 4684c1
     [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
Packit Service 4684c1
  fi
Packit Service 4684c1
])