summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-04-03 04:44:59 +0200
committerBruno Haible <bruno@clisp.org>2012-04-03 14:01:40 +0200
commit6c8149d7e17e4cbc70c3a777b746ac42fb3f8d5c (patch)
tree5c89c9003ee5e6f92a3e6e1366d6b8089c122a38 /m4
parent36d2768bd34a963cf2b4604e3f54d904ed9f17dd (diff)
downloadgnulib-6c8149d7e17e4cbc70c3a777b746ac42fb3f8d5c.tar.gz
New module 'logbf'.
* lib/math.in.h (logbf): New declaration. * lib/logbf.c: New file. * m4/logbf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether logbf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOGBF, HAVE_LOGBF, REPLACE_LOGBF. * modules/math (Makefile.am): Substitute GNULIB_LOGBF, HAVE_LOGBF, REPLACE_LOGBF. * modules/logbf: New file. * tests/test-math-c++.cc: Check the declaration of logbf. * doc/posix-functions/logbf.texi: Mention the new module.
Diffstat (limited to 'm4')
-rw-r--r--m4/logbf.m481
-rw-r--r--m4/math_h.m47
2 files changed, 86 insertions, 2 deletions
diff --git a/m4/logbf.m4 b/m4/logbf.m4
new file mode 100644
index 0000000000..5937c96a23
--- /dev/null
+++ b/m4/logbf.m4
@@ -0,0 +1,81 @@
+# logbf.m4 serial 1
+dnl Copyright (C) 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_LOGBF],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+
+ dnl Persuade glibc <math.h> to declare logbf().
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ dnl Determine LOGBF_LIBM.
+ gl_MATHFUNC([logbf], [float], [(float)])
+ if test $gl_cv_func_logbf_no_libm = yes \
+ || test $gl_cv_func_logbf_in_libm = yes; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $LOGBF_LIBM"
+ gl_FUNC_LOGBF_WORKS
+ LIBS="$save_LIBS"
+ case "$gl_cv_func_logbf_works" in
+ *yes) ;;
+ *) REPLACE_LOGBF=1 ;;
+ esac
+ else
+ HAVE_LOGBF=0
+ fi
+ if test $HAVE_LOGBF = 0 || test $REPLACE_LOGBF = 1; then
+ dnl Find libraries needed to link lib/logbf.c.
+ AC_REQUIRE([gl_FUNC_FREXPF])
+ AC_REQUIRE([gl_FUNC_ISNANF])
+ LOGBF_LIBM=
+ dnl Append $FREXPF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates.
+ case " $LOGBF_LIBM " in
+ *" $FREXPF_LIBM "*) ;;
+ *) LOGBF_LIBM="$LOGBF_LIBM $FREXPF_LIBM" ;;
+ esac
+ dnl Append $ISNANF_LIBM to LOGBF_LIBM, avoiding gratuitous duplicates.
+ case " $LOGBF_LIBM " in
+ *" $ISNANF_LIBM "*) ;;
+ *) LOGBF_LIBM="$LOGBF_LIBM $ISNANF_LIBM" ;;
+ esac
+ fi
+ AC_SUBST([LOGBF_LIBM])
+])
+
+dnl Test whether logbf() works.
+dnl On glibc 2.11/ppc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 10/SPARC,
+dnl the return value for subnormal (denormalized) arguments is too large.
+AC_DEFUN([gl_FUNC_LOGBF_WORKS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether logbf works], [gl_cv_func_logbf_works],
+ [
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#include <float.h>
+#include <math.h>
+volatile float x;
+int main ()
+{
+ int i;
+ for (i = 1, x = 1.0f; i >= FLT_MIN_EXP; i--, x *= 0.5f)
+ ;
+ /* Here i = FLT_MIN_EXP - 1. Either x = 2^(i-1) is subnormal or x = 0.0. */
+ if (x > 0.0f && !(logbf (x) == (float)(i - 1)))
+ return 1;
+ return 0;
+}
+]])],
+ [gl_cv_func_logbf_works=yes],
+ [gl_cv_func_logbf_works=no],
+ [case "$host_os" in
+ *gnu* | solaris*) gl_cv_func_logbf_works="guessing no";;
+ *) gl_cv_func_logbf_works="guessing yes";;
+ esac
+ ])
+ ])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index fe0cd0efaa..6f606651f3 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 108
+# math_h.m4 serial 109
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,
@@ -46,7 +46,7 @@ AC_DEFUN([gl_MATH_H],
fmod fmodf fmodl frexpf frexpl hypotf hypotl
ldexpf ldexpl
log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l
- logb
+ logb logbf
modf modff modfl powf
remainder remainderf remainderl
rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
@@ -129,6 +129,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F])
GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L])
GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
+ GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF])
GNULIB_MODF=0; AC_SUBST([GNULIB_MODF])
GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL])
@@ -195,6 +196,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
+ HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
HAVE_POWF=1; AC_SUBST([HAVE_POWF])
@@ -289,6 +291,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F])
REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L])
REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB])
+ REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF])
REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])