1 # strtoimax.m4 serial 15
2 dnl Copyright (C) 2002-2004, 2006, 2009-2017 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_STRTOIMAX],
9 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
11 dnl On OSF/1 5.1 with cc, this function is declared but not defined.
12 AC_CHECK_FUNCS_ONCE([strtoimax])
13 AC_CHECK_DECLS_ONCE([strtoimax])
14 if test "$ac_cv_have_decl_strtoimax" != yes; then
18 if test "$ac_cv_func_strtoimax" = yes; then
20 dnl On AIX 5.1, strtoimax() fails for values outside the 'int' range.
21 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
22 AC_CACHE_CHECK([whether strtoimax works], [gl_cv_func_strtoimax],
30 if (sizeof (intmax_t) > sizeof (int))
32 const char *s = "4294967295";
36 res = strtoimax (s, &p, 10);
37 if (p != s + strlen (s))
41 if (res != (intmax_t) 65535 * (intmax_t) 65537)
46 const char *s = "2147483647";
50 res = strtoimax (s, &p, 10);
51 if (p != s + strlen (s))
55 if (res != 2147483647)
61 [gl_cv_func_strtoimax=yes],
62 [gl_cv_func_strtoimax=no],
65 aix5*) gl_cv_func_strtoimax="guessing no" ;;
66 # Guess yes on native Windows.
67 mingw*) gl_cv_func_strtoimax="guessing yes" ;;
68 # Guess yes otherwise.
69 *) gl_cv_func_strtoimax="guessing yes" ;;
73 case "$gl_cv_func_strtoimax" in
74 *no) REPLACE_STRTOIMAX=1 ;;
77 if test "$ac_cv_have_decl_strtoimax" = yes; then
78 # HP-UX 11.11 has "#define strtoimax(...) ..." but no function.
85 # Prerequisites of lib/strtoimax.c.
86 AC_DEFUN([gl_PREREQ_STRTOIMAX], [
87 AC_CHECK_DECLS([strtoll])
88 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])