4
0

xstrtoumax.m4 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #serial 4
  2. # autoconf tests required for use of xstrtoumax.c
  3. AC_DEFUN([jm_AC_PREREQ_XSTRTOUMAX],
  4. [
  5. AC_REQUIRE([jm_AC_TYPE_INTMAX_T])
  6. AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
  7. AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
  8. AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
  9. AC_CHECK_DECLS([strtol, strtoul, strtoull, strtoimax, strtoumax])
  10. AC_CHECK_HEADERS(limits.h stdlib.h inttypes.h)
  11. AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
  12. jm_cv_func_strtoumax_macro,
  13. AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
  14. #ifdef strtoumax
  15. inttypes_h_defines_strtoumax
  16. #endif],
  17. jm_cv_func_strtoumax_macro=yes,
  18. jm_cv_func_strtoumax_macro=no))
  19. if test "$jm_cv_func_strtoumax_macro" != yes; then
  20. AC_REPLACE_FUNCS(strtoumax)
  21. fi
  22. dnl Only the replacement strtoumax invokes strtoul and strtoull,
  23. dnl so we need the replacements only if strtoumax does not exist.
  24. case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
  25. no,no)
  26. AC_REPLACE_FUNCS(strtoul)
  27. dnl We don't need (and can't compile) the replacement strtoull
  28. dnl unless the type `unsigned long long' exists.
  29. if test "$ac_cv_type_unsigned_long_long" = yes; then
  30. AC_REPLACE_FUNCS(strtoull)
  31. fi
  32. ;;
  33. esac
  34. ])