immutable: Add tests.
[gnulib.git] / m4 / c-strtod.m4
blob8e3a76a87b834b79f4be503a5939594fbcfd3397
1 # c-strtod.m4 serial 18
3 # Copyright (C) 2004-2006, 2009-2021 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 # Written by Paul Eggert.
10 dnl Prerequisites of lib/c-strtod.c.
11 AC_DEFUN([gl_C_STRTOD],
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14   AC_REQUIRE([gt_FUNC_USELOCALE])
16   AC_CHECK_HEADERS_ONCE([xlocale.h])
17   dnl We can't use AC_CHECK_FUNC here, because strtod_l() is defined as a
18   dnl static inline function when compiling for Android 7.1 or older.
19   AC_CACHE_CHECK([for strtod_l], [gl_cv_func_strtod_l],
20     [AC_LINK_IFELSE(
21        [AC_LANG_PROGRAM(
22           [[#include <stdlib.h>
23             #include <locale.h>
24             #if HAVE_XLOCALE_H
25             # include <xlocale.h>
26             #endif
27             locale_t loc;
28           ]],
29           [[char *end;
30             return strtod_l("0",&end,loc) < 0.0;
31           ]])
32        ],
33        [gl_cv_func_strtod_l=yes],
34        [gl_cv_func_strtod_l=no])
35     ])
36   if test $gl_cv_func_strtod_l = yes; then
37     HAVE_STRTOD_L=1
38   else
39     HAVE_STRTOD_L=0
40   fi
41   AC_DEFINE_UNQUOTED([HAVE_STRTOD_L], [$HAVE_STRTOD_L],
42     [Define to 1 if the system has the 'strtod_l' function.])
45 dnl Prerequisites of lib/c-strtold.c.
46 AC_DEFUN([gl_C_STRTOLD],
48   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
49   AC_REQUIRE([gt_FUNC_USELOCALE])
50   AC_CHECK_FUNCS([strtold_l])