3 dnl Copyright (C) 2011-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_RINTL],
11 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
14 dnl Persuade glibc <math.h> to declare rintl().
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 dnl Determine RINTL_LIBM.
18 gl_MATHFUNC([rintl], [long double], [(long double)])
19 if test $gl_cv_func_rintl_no_libm = yes \
20 || test $gl_cv_func_rintl_in_libm = yes; then
21 if test $REPLACE_RINTL = 0; then
22 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
23 AC_CACHE_CHECK([whether rintl works],
24 [gl_cv_func_rintl_works],
27 LIBS="$LIBS $RINTL_LIBM"
36 long double rintl (long double);
37 static long double dummy (long double x) { return 0; }
38 int main (int argc, char *argv[])
40 long double (* volatile my_rintl) (long double) = argc ? rintl : dummy;
42 /* This test fails on NetBSD 9.0. */
44 volatile long double x = -0.3L;
45 long double y = my_rintl (x);
52 [gl_cv_func_rintl_works=yes],
53 [gl_cv_func_rintl_works=no],
55 # Guess yes on glibc systems.
56 *-gnu* | gnu*) gl_cv_func_rintl_works="guessing yes" ;;
57 # Guess yes on musl systems.
58 *-musl* | midipix*) gl_cv_func_rintl_works="guessing yes" ;;
59 # Guess yes on native Windows.
60 mingw* | windows*) gl_cv_func_rintl_works="guessing yes" ;;
61 # If we don't know, obey --enable-cross-guesses.
62 *) gl_cv_func_rintl_works="$gl_cross_guess_normal" ;;
67 case "$gl_cv_func_rintl_works" in
75 if test $HAVE_RINTL = 0 || test $REPLACE_RINTL = 1; then
76 dnl Find libraries needed to link lib/rintl.c.
77 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
78 AC_REQUIRE([gl_FUNC_RINT])
79 RINTL_LIBM="$RINT_LIBM"
84 AC_SUBST([RINTL_LIBM])