3 dnl Copyright (C) 2002, 2006, 2009-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.
9 AC_DEFUN([gl_FUNC_STRTOUL],
11 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_CHECK_FUNCS([strtoul])
14 if test $ac_cv_func_strtoul = yes; then
15 AC_CACHE_CHECK([whether strtoul works],
16 [gl_cv_func_strtoul_works],
19 [[#include <stdlib.h>]],
22 /* This test fails on Minix and native Windows. */
24 const char input[] = "0x";
25 (void) strtoul (input, &term, 16);
26 if (term != input + 1)
29 /* This test fails on pre-C23 platforms. */
31 const char input[] = "0b1";
32 (void) strtoul (input, &term, 2);
33 if (term != input + 3)
39 [gl_cv_func_strtoul_works=yes],
40 [gl_cv_func_strtoul_works=no],
42 # Guess no on native Windows.
43 mingw* | windows*) gl_cv_func_strtoul_works="guessing no" ;;
44 # Guess no on glibc systems.
45 *-gnu* | gnu*) gl_cv_func_strtoul_works="guessing no" ;;
46 # Guess no on musl systems.
47 *-musl* | midipix*) gl_cv_func_strtoul_works="guessing no" ;;
48 *) gl_cv_func_strtoul_works="$gl_cross_guess_normal" ;;
52 case "$gl_cv_func_strtoul_works" in
54 *) REPLACE_STRTOUL=1 ;;