intmax_t.m4 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # intmax_t.m4 serial 9
  2. dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 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_DEFINE_UNQUOTED([intmax_t], [long long],
  19. [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
  20. else
  21. AC_DEFINE([HAVE_INTMAX_T], [1],
  22. [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
  23. fi
  24. ])
  25. dnl An alternative would be to explicitly test for 'intmax_t'.
  26. AC_DEFUN([gt_AC_TYPE_INTMAX_T],
  27. [
  28. AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
  29. AC_REQUIRE([gl_AC_HEADER_STDINT_H])
  30. AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
  31. [AC_COMPILE_IFELSE(
  32. [AC_LANG_PROGRAM(
  33. [[
  34. #include <stddef.h>
  35. #include <stdlib.h>
  36. #if HAVE_STDINT_H_WITH_UINTMAX
  37. #include <stdint.h>
  38. #endif
  39. #if HAVE_INTTYPES_H_WITH_UINTMAX
  40. #include <inttypes.h>
  41. #endif
  42. ]],
  43. [[intmax_t x = -1; return !x;]])],
  44. [gt_cv_c_intmax_t=yes],
  45. [gt_cv_c_intmax_t=no])])
  46. if test $gt_cv_c_intmax_t = yes; then
  47. AC_DEFINE([HAVE_INTMAX_T], [1],
  48. [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
  49. else
  50. AC_DEFINE_UNQUOTED([intmax_t], [long long],
  51. [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
  52. fi
  53. ])