inttypes.m4 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #serial 6
  2. dnl From Paul Eggert.
  3. AC_PREREQ(2.13)
  4. # Define HAVE_INTTYPES_H if <inttypes.h> exists,
  5. # doesn't clash with <sys/types.h>, and declares intmax_t and uintmax_t.
  6. AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
  7. [
  8. AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
  9. [AC_TRY_COMPILE(
  10. [#include <sys/types.h>
  11. #include <inttypes.h>],
  12. [intmax_t i = (intmax_t) -1; uintmax_t ui = (uintmax_t) -1;],
  13. jm_ac_cv_header_inttypes_h=yes,
  14. jm_ac_cv_header_inttypes_h=no)])
  15. if test $jm_ac_cv_header_inttypes_h = yes; then
  16. AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
  17. [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
  18. and declares intmax_t and uintmax_t.])
  19. fi
  20. ])
  21. # Define intmax_t to long or long long if <inttypes.h> doesn't define.
  22. AC_DEFUN([jm_AC_TYPE_INTMAX_T],
  23. [
  24. AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
  25. if test $jm_ac_cv_header_inttypes_h = no; then
  26. AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
  27. test $ac_cv_type_long_long = yes \
  28. && ac_type='long long' \
  29. || ac_type='long'
  30. AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
  31. [Define to long or long long if <inttypes.h> doesn't define.])
  32. fi
  33. ])
  34. # Define uintmax_t to unsigned long or unsigned long long
  35. # if <inttypes.h> doesn't define.
  36. AC_DEFUN([jm_AC_TYPE_UINTMAX_T],
  37. [
  38. AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
  39. if test $jm_ac_cv_header_inttypes_h = no; then
  40. AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
  41. test $ac_cv_type_unsigned_long_long = yes \
  42. && ac_type='unsigned long long' \
  43. || ac_type='unsigned long'
  44. AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
  45. [Define to unsigned long or unsigned long long
  46. if <inttypes.h> doesn't define.])
  47. fi
  48. ])