| 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. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_STRTOLL], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) |
| 12 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 13 |
AC_CHECK_FUNCS([strtoll]) |
| 14 |
if test $ac_cv_func_strtoll = yes; then |
| 15 |
AC_CACHE_CHECK([whether strtoll works], |
| 16 |
[gl_cv_func_strtoll_works], |
| 17 |
[AC_RUN_IFELSE( |
| 18 |
[AC_LANG_PROGRAM( |
| 19 |
[[#include <stdlib.h>]], |
| 20 |
[[int result = 0; |
| 21 |
char *term; |
| 22 |
/* This test fails on Minix and native Windows. */ |
| 23 |
{ |
| 24 |
static char const input[2][3] = {"0x", "0b"}; |
| 25 |
static int const base[] = {0, 2, 10}; |
| 26 |
int i, j; |
| 27 |
for (i = 0; i < 2; i++) |
| 28 |
for (j = 0; j < 3; j++) |
| 29 |
{ |
| 30 |
(void) strtoll (input[i], &term, base[j]); |
| 31 |
if (term != input[i] + 1) |
| 32 |
result |= 1; |
| 33 |
} |
| 34 |
} |
| 35 |
/* This test fails on pre-C23 platforms. */ |
| 36 |
{ |
| 37 |
const char input[] = "0b1"; |
| 38 |
(void) strtoll (input, &term, 2); |
| 39 |
if (term != input + 3) |
| 40 |
result |= 2; |
| 41 |
} |
| 42 |
return result; |
| 43 |
]]) |
| 44 |
], |
| 45 |
[gl_cv_func_strtoll_works=yes], |
| 46 |
[gl_cv_func_strtoll_works=no], |
| 47 |
[case "$host_os" in |
| 48 |
# Guess no on native Windows. |
| 49 |
mingw* | windows*) gl_cv_func_strtoll_works="guessing no" ;; |
| 50 |
# Guess no on glibc systems. |
| 51 |
*-gnu* | gnu*) gl_cv_func_strtoll_works="guessing no" ;; |
| 52 |
# Guess no on musl systems. |
| 53 |
*-musl* | midipix*) gl_cv_func_strtoll_works="guessing no" ;; |
| 54 |
*) gl_cv_func_strtoll_works="$gl_cross_guess_normal" ;; |
| 55 |
esac |
| 56 |
]) |
| 57 |
]) |
| 58 |
case "$gl_cv_func_strtoll_works" in |
| 59 |
*yes) ;; |
| 60 |
*) REPLACE_STRTOLL=1 ;; |
| 61 |
esac |
| 62 |
else |
| 63 |
HAVE_STRTOLL=0 |
| 64 |
fi |
| 65 |
]) |
| 66 |
|
| 67 |
# Prerequisites of lib/strtoll.c. |
| 68 |
AC_DEFUN([gl_PREREQ_STRTOLL], [ |
| 69 |
: |
| 70 |
]) |