4
0

xstrtoimax.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #serial 1
  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_HEADER_INTTYPES_H])
  8. AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
  9. AC_CHECK_DECLS([strtol, strtoll])
  10. AC_CHECK_HEADERS(limits.h stdlib.h)
  11. AC_CACHE_CHECK([whether <inttypes.h> defines strtoimax as a macro],
  12. jm_cv_func_strtoimax_macro,
  13. AC_EGREP_CPP([inttypes_h_defines_strtoimax], [#include <inttypes.h>
  14. #ifdef strtoimax
  15. inttypes_h_defines_strtoimax
  16. #endif],
  17. jm_cv_func_strtoimax_macro=yes,
  18. jm_cv_func_strtoimax_macro=no))
  19. if test "$jm_cv_func_strtoimax_macro" != yes; then
  20. AC_REPLACE_FUNCS(strtoimax)
  21. fi
  22. dnl We don't need (and can't compile) the replacement strtoll
  23. dnl unless the type `long long' exists.
  24. dnl Also, only the replacement strtoimax invokes strtoll,
  25. dnl so we need the replacement strtoll only if strtoimax does not exist.
  26. case "$ac_cv_type_long_long,$jm_cv_func_strtoimax_macro,$ac_cv_func_strtoimax" in
  27. yes,no,no)
  28. AC_REPLACE_FUNCS(strtoll)
  29. dnl Check for strtol. Mainly as a cue to cause automake to include
  30. dnl strtol.c -- that file is included by each of strtoul.c and strtoull.c.
  31. AC_REPLACE_FUNCS(strtol)
  32. ;;
  33. esac
  34. case "$jm_cv_func_strtoimax_macro,$ac_cv_func_strtoimax" in
  35. no,no)
  36. AC_REPLACE_FUNCS(strtoul)
  37. dnl See explanation above.
  38. AC_REPLACE_FUNCS(strtol)
  39. ;;
  40. esac
  41. ])