* lib/math.in.h (log10f): Override if REPLACE_LOG10F is 1.
* lib/log10f.c (log10f): If logf exists, use it and provide just the
workaround.
* m4/log10f.m4 (gl_FUNC_LOG10F_WORKS): New macro.
(gl_FUNC_LOG10F): Invoke it. Set REPLACE_LOG10F.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG10F.
* modules/math (Makefile.am): Substitute REPLACE_LOG10F.
* modules/log10f (configure.ac): Consider REPLACE_LOG10F.
(Depends-on): Update conditions.
* doc/posix-functions/log10f.texi: Mention the OSF/1 5.1 problem.
2012-04-01 Bruno Haible <bruno@clisp.org>
+ log10f: Work around OSF/1 5.1 bug.
+ * lib/math.in.h (log10f): Override if REPLACE_LOG10F is 1.
+ * lib/log10f.c (log10f): If logf exists, use it and provide just the
+ workaround.
+ * m4/log10f.m4 (gl_FUNC_LOG10F_WORKS): New macro.
+ (gl_FUNC_LOG10F): Invoke it. Set REPLACE_LOG10F.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_LOG10F.
+ * modules/math (Makefile.am): Substitute REPLACE_LOG10F.
+ * modules/log10f (configure.ac): Consider REPLACE_LOG10F.
+ (Depends-on): Update conditions.
+ * doc/posix-functions/log10f.texi: Mention the OSF/1 5.1 problem.
+
+2012-04-01 Bruno Haible <bruno@clisp.org>
+
log10: Work around OSF/1 5.1 bug.
* lib/math.in.h (log10): New declaration.
* lib/log10.c: New file.
@item
This function is only defined as a macro with arguments on some platforms:
MSVC 9.
+@item
+This function returns a wrong value for a minus zero argument on some platforms:
+OSF/1 5.1.
@end itemize
Portability problems not fixed by Gnulib:
float
log10f (float x)
+#undef log10f
{
+#if HAVE_LOG10F
+ /* Work around the OSF/1 5.1 bug. */
+ if (x == 0.0f)
+ /* Return -Infinity. */
+ return -1.0f / 0.0f;
+ return log10f (x);
+#else
return (float) log10 ((double) x);
+#endif
}
#if @GNULIB_LOG10F@
-# if !@HAVE_LOG10F@
-# undef log10f
+# if @REPLACE_LOG10F@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef log10f
+# define log10f rpl_log10f
+# endif
+_GL_FUNCDECL_RPL (log10f, float, (float x));
+_GL_CXXALIAS_RPL (log10f, float, (float x));
+# else
+# if !@HAVE_LOG10F@
+# undef log10f
_GL_FUNCDECL_SYS (log10f, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (log10f, float, (float x));
+# endif
_GL_CXXALIASWARN (log10f);
#elif defined GNULIB_POSIXCHECK
# undef log10f
-# log10f.m4 serial 2
+# log10f.m4 serial 3
dnl Copyright (C) 2011-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,
LIBS="$save_LIBS"
if test $ac_cv_func_log10f = yes; then
LOG10F_LIBM="$LOG10_LIBM"
+
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $LOG10F_LIBM"
+ gl_FUNC_LOG10F_WORKS
+ LIBS="$save_LIBS"
+ case "$gl_cv_func_log10f_works" in
+ *yes) ;;
+ *) REPLACE_LOG10F=1 ;;
+ esac
else
HAVE_LOG10F=0
- LOG10F_LIBM="$LOG10_LIBM"
+ fi
+ if test $HAVE_LOG10F = 0 || test $REPLACE_LOG10F = 1; then
+ dnl Find libraries needed to link lib/log10f.c.
+ if test $HAVE_LOG10F = 0; then
+ LOG10F_LIBM="$LOG10_LIBM"
+ fi
fi
AC_SUBST([LOG10F_LIBM])
])
+
+dnl Test whether log10f() works.
+dnl On OSF/1 5.1, log10f(-0.0f) is NaN.
+AC_DEFUN([gl_FUNC_LOG10F_WORKS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether log10f works], [gl_cv_func_log10f_works],
+ [
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#include <math.h>
+volatile float x;
+float y;
+int main ()
+{
+ x = -0.0f;
+ y = log10f (x);
+ if (!(y + y == y))
+ return 1;
+ return 0;
+}
+]])],
+ [gl_cv_func_log10f_works=yes],
+ [gl_cv_func_log10f_works=no],
+ [case "$host_os" in
+ osf*) gl_cv_func_log10f_works="guessing no";;
+ *) gl_cv_func_log10f_works="guessing yes";;
+ esac
+ ])
+ ])
+])
-# math_h.m4 serial 105
+# math_h.m4 serial 106
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,
REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10])
+ REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F])
REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL])
Depends-on:
math
extensions
-log10 [test $HAVE_LOG10F = 0]
+log10 [test $HAVE_LOG10F = 0 || test $REPLACE_LOG10F = 1]
configure.ac:
gl_FUNC_LOG10F
-if test $HAVE_LOG10F = 0; then
+if test $HAVE_LOG10F = 0 || test $REPLACE_LOG10F = 1; then
AC_LIBOBJ([log10f])
fi
gl_MATH_MODULE_INDICATOR([log10f])
-e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \
-e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \
-e 's|@''REPLACE_LOG10''@|$(REPLACE_LOG10)|g' \
+ -e 's|@''REPLACE_LOG10F''@|$(REPLACE_LOG10F)|g' \
-e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \
-e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \
-e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \