1 # strtoimax.m4 serial 13
2 dnl Copyright (C) 2002-2004, 2006, 2009-2013 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 otherwise.
67 *) gl_cv_func_strtoimax="guessing yes" ;;
71 case "$gl_cv_func_strtoimax" in
72 *no) REPLACE_STRTOIMAX=1 ;;
79 # Prerequisites of lib/strtoimax.c.
80 AC_DEFUN([gl_PREREQ_STRTOIMAX], [
81 AC_CHECK_DECLS([strtoll])
82 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])