xstrtoumax.m4 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_HEADER_INTTYPES_H])
  7. AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
  8. AC_CHECK_DECLS([strtoul, strtoull])
  9. AC_CHECK_HEADERS(limits.h stdlib.h)
  10. AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
  11. jm_cv_func_strtoumax_macro,
  12. AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
  13. #ifdef strtoumax
  14. inttypes_h_defines_strtoumax
  15. #endif],
  16. jm_cv_func_strtoumax_macro=yes,
  17. jm_cv_func_strtoumax_macro=no))
  18. if test "$jm_cv_func_strtoumax_macro" != yes; then
  19. AC_REPLACE_FUNCS(strtoumax)
  20. fi
  21. dnl We don't need (and can't compile) the replacement strtoull
  22. dnl unless the type `unsigned long long' exists.
  23. dnl Also, only the replacement strtoumax invokes strtoull,
  24. dnl so we need the replacement strtoull only if strtoumax does not exist.
  25. case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
  26. yes,no,no)
  27. AC_REPLACE_FUNCS(strtoull strtol)
  28. ;;
  29. esac
  30. case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
  31. no,no)
  32. AC_REPLACE_FUNCS(strtoul strtol)
  33. ;;
  34. esac
  35. ])