striconv, striconveh, unicodeio: Drop workaround for glibc 2.1.
[gnulib.git] / m4 / strtoll.m4
blob03a50dec2f1f413d20adf13f7cc1b4efff6bc1cd
1 # strtoll.m4
2 # serial 12
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],
16       [AC_RUN_IFELSE(
17          [AC_LANG_PROGRAM(
18             [[#include <stdlib.h>]],
19             [[int result = 0;
20               char *term;
21               /* This test fails on Minix and native Windows.  */
22               {
23                 static char const input[2][3] = {"0x", "0b"};
24                 static int const base[] = {0, 2, 10};
25                 int i, j;
26                 for (i = 0; i < 2; i++)
27                   for (j = 0; j < 3; j++)
28                     {
29                       (void) strtoll (input[i], &term, base[j]);
30                       if (term != input[i] + 1)
31                         result |= 1;
32                     }
33               }
34               /* This test fails on pre-C23 platforms.  */
35               {
36                 const char input[] = "0b1";
37                 (void) strtoll (input, &term, 2);
38                 if (term != input + 3)
39                   result |= 2;
40               }
41               return result;
42             ]])
43          ],
44          [gl_cv_func_strtoll_works=yes],
45          [gl_cv_func_strtoll_works=no],
46          [case "$host_os" in
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" ;;
54           esac
55          ])
56     ])
57     case "$gl_cv_func_strtoll_works" in
58       *yes) ;;
59       *)    REPLACE_STRTOLL=1 ;;
60     esac
61   else
62     HAVE_STRTOLL=0
63   fi
66 # Prerequisites of lib/strtoll.c.
67 AC_DEFUN([gl_PREREQ_STRTOLL], [
68   :