2 dnl Copyright (C) 2010-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_LOG2L],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11 AC_REQUIRE([gl_FUNC_LOG2])
13 dnl Persuade glibc <math.h> to declare log2l().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether log2l() exists. Assume that log2l(), if it exists, is
17 dnl defined in the same library as log2().
19 LIBS="$LIBS $LOG2_LIBM"
20 AC_CHECK_FUNCS([log2l])
22 if test $ac_cv_func_log2l = yes; then
23 LOG2L_LIBM="$LOG2_LIBM"
25 dnl Also check whether it's declared.
26 dnl IRIX 6.5 has log2l() in libm but doesn't declare it in <math.h>.
27 AC_CHECK_DECL([log2l], , [HAVE_DECL_LOG2L=0], [[#include <math.h>]])
30 LIBS="$LIBS $LOG2L_LIBM"
33 case "$gl_cv_func_log2l_works" in
41 if test $HAVE_LOG2L = 0 || test $REPLACE_LOG2L = 1; then
42 dnl Find libraries needed to link lib/log2l.c.
43 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
44 LOG2L_LIBM="$LOG2_LIBM"
46 AC_REQUIRE([gl_FUNC_ISNANL])
47 AC_REQUIRE([gl_FUNC_FREXPL])
48 AC_REQUIRE([gl_FUNC_LOGL])
50 dnl Append $ISNANL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
51 case " $LOG2L_LIBM " in
52 *" $ISNANL_LIBM "*) ;;
53 *) LOG2L_LIBM="$LOG2L_LIBM $ISNANL_LIBM" ;;
55 dnl Append $FREXPL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
56 case " $LOG2L_LIBM " in
57 *" $FREXPL_LIBM "*) ;;
58 *) LOG2L_LIBM="$LOG2L_LIBM $FREXPL_LIBM" ;;
60 dnl Append $LOGL_LIBM to LOG2L_LIBM, avoiding gratuitous duplicates.
61 case " $LOG2L_LIBM " in
63 *) LOG2L_LIBM="$LOG2L_LIBM $LOGL_LIBM" ;;
67 AC_SUBST([LOG2L_LIBM])
70 dnl Test whether log2l() works.
71 dnl On OSF/1 5.1, log2l(-0.0) is NaN.
72 AC_DEFUN([gl_FUNC_LOG2L_WORKS],
74 AC_REQUIRE([AC_PROG_CC])
75 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
76 AC_CACHE_CHECK([whether log2l works], [gl_cv_func_log2l_works],
81 #ifndef log2l /* for AIX */
86 long double log2l (long double);
88 volatile long double x;
89 volatile long double y;
92 /* This test fails on OSF/1 5.1. */
100 [gl_cv_func_log2l_works=yes],
101 [gl_cv_func_log2l_works=no],
103 osf*) gl_cv_func_log2l_works="guessing no" ;;
104 # Guess yes on native Windows.
105 mingw*) gl_cv_func_log2l_works="guessing yes" ;;
106 *) gl_cv_func_log2l_works="guessing yes" ;;