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