2 dnl Closely related to xstrtoimax.m4. Keep these files in sync.
4 # autoconf tests required for use of xstrtoumax.c
6 AC_DEFUN([jm_AC_PREREQ_XSTRTOUMAX],
8 AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
9 AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
10 AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
11 AC_CHECK_DECLS([strtoul, strtoull])
12 AC_CHECK_HEADERS(limits.h stdlib.h)
14 AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
15 jm_cv_func_strtoumax_macro,
16 AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
18 inttypes_h_defines_strtoumax
20 jm_cv_func_strtoumax_macro=yes,
21 jm_cv_func_strtoumax_macro=no))
23 if test "$jm_cv_func_strtoumax_macro" != yes; then
24 AC_REPLACE_FUNCS(strtoumax)
27 dnl We don't need (and can't compile) the replacement strtoull
28 dnl unless the type `unsigned long long' exists.
29 dnl Also, only the replacement strtoumax invokes strtoull,
30 dnl so we need the replacement strtoull only if strtoumax does not exist.
31 case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
33 AC_REPLACE_FUNCS(strtoull)
35 dnl Check for strtol. Mainly as a cue to cause automake to include
36 dnl strtol.c -- that file is included by each of strtoul.c and strtoull.c.
37 AC_REPLACE_FUNCS(strtol)
41 case "$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
43 AC_REPLACE_FUNCS(strtoul)
45 dnl See explanation above.
46 AC_REPLACE_FUNCS(strtol)