summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-04-03 21:58:52 +0200
committerBruno Haible <bruno@clisp.org>2012-04-03 21:58:52 +0200
commit811b6ef05c574d054648a2f41bc5a2efc92f5371 (patch)
tree8a403fc81665acffa95698c3cd76c76d4eba3205 /m4
parentafecf4a0bde14016fb4ab2a18395d82cfbc0fe28 (diff)
downloadgnulib-811b6ef05c574d054648a2f41bc5a2efc92f5371.tar.gz
New module 'ilogbl'.
* lib/math.in.h (ilogbl): New declaration. * lib/ilogbl.c: New file. * m4/ilogbl.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether ilogbl is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_ILOGBL, HAVE_ILOGBL. * modules/math (Makefile.am): Substitute GNULIB_ILOGBL, HAVE_ILOGBL. Split sed invocation, to avoid the limit of 100 substitutions of HP-UX 'sed'. * modules/ilogbl: New file. * tests/test-math-c++.cc: Check the declaration of ilogbl. * doc/posix-functions/ilogbl.texi: Mention the new module.
Diffstat (limited to 'm4')
-rw-r--r--m4/ilogbl.m461
-rw-r--r--m4/math_h.m46
2 files changed, 65 insertions, 2 deletions
diff --git a/m4/ilogbl.m4 b/m4/ilogbl.m4
new file mode 100644
index 0000000000..e7f871f87f
--- /dev/null
+++ b/m4/ilogbl.m4
@@ -0,0 +1,61 @@
+# ilogbl.m4 serial 1
+dnl Copyright (C) 2010-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_ILOGBL],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+ AC_REQUIRE([gl_FUNC_ILOGB])
+
+ dnl Persuade glibc <math.h> to declare ilogbl().
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ dnl Test whether ilogbl() exists. Assume that ilogbl(), if it exists, is
+ dnl defined in the same library as ilogb().
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $ILOGB_LIBM"
+ AC_CACHE_CHECK([for ilogbl],
+ [gl_cv_func_ilogbl],
+ [
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#ifndef __NO_MATH_INLINES
+ # define __NO_MATH_INLINES 1 /* for glibc */
+ #endif
+ #include <math.h>
+ int (*funcptr) (long double) = ilogbl;
+ long double x;]],
+ [[return (funcptr (x) % 2) == 0
+ || (ilogbl (x) % 2) == 0;]])],
+ [gl_cv_func_ilogbl=yes],
+ [gl_cv_func_ilogbl=no])
+ ])
+ LIBS="$save_LIBS"
+ if test $gl_cv_func_ilogbl = yes; then
+ ILOGBL_LIBM="$ILOGB_LIBM"
+ else
+ HAVE_ILOGBL=0
+ dnl Find libraries needed to link lib/ilogbl.c.
+ if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+ ILOGBL_LIBM="$ILOGB_LIBM"
+ else
+ AC_REQUIRE([gl_FUNC_FREXPL])
+ AC_REQUIRE([gl_FUNC_ISNANL])
+ ILOGBL_LIBM=
+ dnl Append $FREXPL_LIBM to ILOGBL_LIBM, avoiding gratuitous duplicates.
+ case " $ILOGBL_LIBM " in
+ *" $FREXPL_LIBM "*) ;;
+ *) ILOGBL_LIBM="$ILOGBL_LIBM $FREXPL_LIBM" ;;
+ esac
+ dnl Append $ISNANL_LIBM to ILOGBL_LIBM, avoiding gratuitous duplicates.
+ case " $ILOGBL_LIBM " in
+ *" $ISNANL_LIBM "*) ;;
+ *) ILOGBL_LIBM="$ILOGBL_LIBM $ISNANL_LIBM" ;;
+ esac
+ fi
+ fi
+ AC_SUBST([ILOGBL_LIBM])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index c00c415d4a..90d248aecc 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 112
+# math_h.m4 serial 113
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -44,7 +44,7 @@ AC_DEFUN([gl_MATH_H],
expf expl exp2 exp2f exp2l expm1 expm1f expm1l
fabsf fabsl floorf floorl fma fmaf fmal
fmod fmodf fmodl frexpf frexpl hypotf hypotl
- ilogb ilogbf
+ ilogb ilogbf ilogbl
ldexpf ldexpl
log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l
logb logbf logbl
@@ -111,6 +111,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL])
GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB])
GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF])
+ GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL])
GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
@@ -191,6 +192,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF])
+ HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL])
HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])