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