xstrtoumax.m4 1.2 KB

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