1 # strtoimax.m4 serial 14
2 dnl Copyright (C) 2002-2004, 2006, 2009-2015 Free Software Foundation,
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_STRTOIMAX],
10 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
12 dnl On OSF/1 5.1 with cc, this function is declared but not defined.
13 AC_CHECK_FUNCS_ONCE([strtoimax])
14 AC_CHECK_DECLS_ONCE([strtoimax])
15 if test "$ac_cv_have_decl_strtoimax" != yes; then
19 if test "$ac_cv_func_strtoimax" = yes; then
21 dnl On AIX 5.1, strtoimax() fails for values outside the 'int' range.
22 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
23 AC_CACHE_CHECK([whether strtoimax works], [gl_cv_func_strtoimax],
31 if (sizeof (intmax_t) > sizeof (int))
33 const char *s = "4294967295";
37 res = strtoimax (s, &p, 10);
38 if (p != s + strlen (s))
42 if (res != (intmax_t) 65535 * (intmax_t) 65537)
47 const char *s = "2147483647";
51 res = strtoimax (s, &p, 10);
52 if (p != s + strlen (s))
56 if (res != 2147483647)
62 [gl_cv_func_strtoimax=yes],
63 [gl_cv_func_strtoimax=no],
66 aix5*) gl_cv_func_strtoimax="guessing no" ;;
67 # Guess yes otherwise.
68 *) gl_cv_func_strtoimax="guessing yes" ;;
72 case "$gl_cv_func_strtoimax" in
73 *no) REPLACE_STRTOIMAX=1 ;;
76 if test "$ac_cv_have_decl_strtoimax" = yes; then
77 # HP-UX 11.11 has "#define strtoimax(...) ..." but no function.
84 # Prerequisites of lib/strtoimax.c.
85 AC_DEFUN([gl_PREREQ_STRTOIMAX], [
86 AC_CHECK_DECLS([strtoll])
87 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])