2 dnl Copyright (C) 2010-2017 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_ILOGBL],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11 AC_REQUIRE([gl_FUNC_ILOGB])
13 dnl Persuade glibc <math.h> to declare ilogbl().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether ilogbl() exists. Assume that ilogbl(), if it exists, is
17 dnl defined in the same library as ilogb().
19 LIBS="$LIBS $ILOGB_LIBM"
20 AC_CACHE_CHECK([for ilogbl],
25 [[#ifndef __NO_MATH_INLINES
26 # define __NO_MATH_INLINES 1 /* for glibc */
29 int (*funcptr) (long double) = ilogbl;
31 [[return (funcptr (x) % 2) == 0
32 || (ilogbl (x) % 2) == 0;]])],
33 [gl_cv_func_ilogbl=yes],
34 [gl_cv_func_ilogbl=no])
37 if test $gl_cv_func_ilogbl = yes; then
38 ILOGBL_LIBM="$ILOGB_LIBM"
41 dnl Find libraries needed to link lib/ilogbl.c.
42 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
43 ILOGBL_LIBM="$ILOGB_LIBM"
45 AC_REQUIRE([gl_FUNC_FREXPL])
46 AC_REQUIRE([gl_FUNC_ISNANL])
48 dnl Append $FREXPL_LIBM to ILOGBL_LIBM, avoiding gratuitous duplicates.
49 case " $ILOGBL_LIBM " in
50 *" $FREXPL_LIBM "*) ;;
51 *) ILOGBL_LIBM="$ILOGBL_LIBM $FREXPL_LIBM" ;;
53 dnl Append $ISNANL_LIBM to ILOGBL_LIBM, avoiding gratuitous duplicates.
54 case " $ILOGBL_LIBM " in
55 *" $ISNANL_LIBM "*) ;;
56 *) ILOGBL_LIBM="$ILOGBL_LIBM $ISNANL_LIBM" ;;
60 AC_SUBST([ILOGBL_LIBM])