2 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_RINTL],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12 dnl Persuade glibc <math.h> to declare rintl().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 dnl Determine RINTL_LIBM.
16 gl_MATHFUNC([rintl], [long double], [(long double)])
17 if test $gl_cv_func_rintl_no_libm = yes \
18 || test $gl_cv_func_rintl_in_libm = yes; then
19 if test $REPLACE_RINTL = 0; then
20 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CACHE_CHECK([whether rintl works],
22 [gl_cv_func_rintl_works],
25 LIBS="$LIBS $RINTL_LIBM"
34 long double rintl (long double);
35 static long double dummy (long double x) { return 0; }
36 int main (int argc, char *argv[])
38 long double (* volatile my_rintl) (long double) = argc ? rintl : dummy;
40 /* This test fails on NetBSD 9.0. */
42 volatile long double x = -0.3L;
43 long double y = my_rintl (x);
50 [gl_cv_func_rintl_works=yes],
51 [gl_cv_func_rintl_works=no],
53 # Guess yes on glibc systems.
54 *-gnu* | gnu*) gl_cv_func_rintl_works="guessing yes" ;;
55 # Guess yes on musl systems.
56 *-musl*) gl_cv_func_rintl_works="guessing yes" ;;
57 # Guess yes on native Windows.
58 mingw*) gl_cv_func_rintl_works="guessing yes" ;;
59 # If we don't know, obey --enable-cross-guesses.
60 *) gl_cv_func_rintl_works="$gl_cross_guess_normal" ;;
65 case "$gl_cv_func_rintl_works" in
73 if test $HAVE_RINTL = 0 || test $REPLACE_RINTL = 1; then
74 dnl Find libraries needed to link lib/rintl.c.
75 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
76 AC_REQUIRE([gl_FUNC_RINT])
77 RINTL_LIBM="$RINT_LIBM"
82 AC_SUBST([RINTL_LIBM])