intmax_t.m4 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # intmax_t.m4 serial 5
  2. dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Paul Eggert.
  7. AC_PREREQ(2.13)
  8. # Define intmax_t to 'long' or 'long long'
  9. # if it is not already defined in <stdint.h> or <inttypes.h>.
  10. AC_DEFUN([gl_AC_TYPE_INTMAX_T],
  11. [
  12. dnl For simplicity, we assume that a header file defines 'intmax_t' if and
  13. dnl only if it defines 'uintmax_t'.
  14. AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
  15. AC_REQUIRE([gl_AC_HEADER_STDINT_H])
  16. if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
  17. AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
  18. test $ac_cv_type_long_long = yes \
  19. && ac_type='long long' \
  20. || ac_type='long'
  21. AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
  22. [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
  23. else
  24. AC_DEFINE(HAVE_INTMAX_T, 1,
  25. [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
  26. fi
  27. ])
  28. dnl An alternative would be to explicitly test for 'intmax_t'.
  29. AC_DEFUN([gt_AC_TYPE_INTMAX_T],
  30. [
  31. AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
  32. AC_REQUIRE([gl_AC_HEADER_STDINT_H])
  33. AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
  34. [AC_TRY_COMPILE([
  35. #include <stddef.h>
  36. #include <stdlib.h>
  37. #if HAVE_STDINT_H_WITH_UINTMAX
  38. #include <stdint.h>
  39. #endif
  40. #if HAVE_INTTYPES_H_WITH_UINTMAX
  41. #include <inttypes.h>
  42. #endif
  43. ], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
  44. if test $gt_cv_c_intmax_t = yes; then
  45. AC_DEFINE(HAVE_INTMAX_T, 1,
  46. [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
  47. else
  48. AC_REQUIRE([gl_AC_TYPE_LONG_LONG])
  49. test $ac_cv_type_long_long = yes \
  50. && ac_type='long long' \
  51. || ac_type='long'
  52. AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
  53. [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
  54. fi
  55. ])