xstrtoimax.m4 1.3 KB

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