Blame m4/intmax_t.m4

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