Blame gnulib/m4/intmax_t.m4

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