intmax_t.m4 2.1 KB

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