3 dnl Copyright (C) 2002, 2004, 2006, 2008-2024 Free Software Foundation, Inc.
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_STRTOLL],
10 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_CHECK_FUNCS([strtoll])
13 if test $ac_cv_func_strtoll = yes; then
14 AC_CACHE_CHECK([whether strtoll works],
15 [gl_cv_func_strtoll_works],
18 [[#include <stdlib.h>]],
21 /* This test fails on Minix and native Windows. */
23 static char const input[2][3] = {"0x", "0b"};
24 static int const base[] = {0, 2, 10};
26 for (i = 0; i < 2; i++)
27 for (j = 0; j < 3; j++)
29 (void) strtoll (input[i], &term, base[j]);
30 if (term != input[i] + 1)
34 /* This test fails on pre-C23 platforms. */
36 const char input[] = "0b1";
37 (void) strtoll (input, &term, 2);
38 if (term != input + 3)
44 [gl_cv_func_strtoll_works=yes],
45 [gl_cv_func_strtoll_works=no],
47 # Guess no on native Windows.
48 mingw* | windows*) gl_cv_func_strtoll_works="guessing no" ;;
49 # Guess no on glibc systems.
50 *-gnu* | gnu*) gl_cv_func_strtoll_works="guessing no" ;;
51 # Guess no on musl systems.
52 *-musl* | midipix*) gl_cv_func_strtoll_works="guessing no" ;;
53 *) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;;
57 case "$gl_cv_func_strtoll_works" in
59 *) REPLACE_STRTOLL=1 ;;
66 # Prerequisites of lib/strtoll.c.
67 AC_DEFUN([gl_PREREQ_STRTOLL], [