1 # strtoimax.m4 serial 12
2 dnl Copyright (C) 2002-2004, 2006, 2009-2012 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([gl_AC_HEADER_STDINT_H])
22 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
23 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
24 AC_CACHE_CHECK([whether strtoimax works], [gl_cv_func_strtoimax],
30 #include <sys/types.h>
31 #if HAVE_STDINT_H_WITH_UINTMAX
34 #if HAVE_INTTYPES_H_WITH_UINTMAX
35 # include <inttypes.h>
39 if (sizeof (intmax_t) > sizeof (int))
41 const char *s = "4294967295";
45 res = strtoimax (s, &p, 10);
46 if (p != s + strlen (s))
50 if (res != (intmax_t) 65535 * (intmax_t) 65537)
55 const char *s = "2147483647";
59 res = strtoimax (s, &p, 10);
60 if (p != s + strlen (s))
64 if (res != 2147483647)
70 [gl_cv_func_strtoimax=yes],
71 [gl_cv_func_strtoimax=no],
74 aix5*) gl_cv_func_strtoimax="guessing no" ;;
75 # Guess yes otherwise.
76 *) gl_cv_func_strtoimax="guessing yes" ;;
80 case "$gl_cv_func_strtoimax" in
81 *no) REPLACE_STRTOIMAX=1 ;;
88 # Prerequisites of lib/strtoimax.c.
89 AC_DEFUN([gl_PREREQ_STRTOIMAX], [
90 AC_CHECK_DECLS([strtoll])
91 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])