* m4/exp2l-ieee.m4: New file.
* m4/exp2l.m4 (gl_FUNC_EXP2L): If gl_FUNC_EXP2L_IEEE is present,
test whether exp2l works with a NaN argument and with a negative
infinity argument. Replace it if not.
* lib/math.in.h (exp2l): Override if REPLACE_EXP2L is 1.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXP2L.
* modules/math (Makefile.am): Substitute REPLACE_EXP2L.
* modules/exp2l (configure.ac): Consider REPLACE_EXP2L.
(Depends-on): Update conditions.
* modules/exp2l-ieee (Files): Add m4/exp2l-ieee.m4.
(configure.ac): Invoke gl_FUNC_EXP2L_IEEE.
* doc/posix-functions/exp2l.texi: Mention the exp2l-ieee module.
2012-03-08 Bruno Haible <bruno@clisp.org>
+ exp2l-ieee: Work around test failure on OpenBSD 4.9 and IRIX 6.5.
+ * m4/exp2l-ieee.m4: New file.
+ * m4/exp2l.m4 (gl_FUNC_EXP2L): If gl_FUNC_EXP2L_IEEE is present,
+ test whether exp2l works with a NaN argument and with a negative
+ infinity argument. Replace it if not.
+ * lib/math.in.h (exp2l): Override if REPLACE_EXP2L is 1.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_EXP2L.
+ * modules/math (Makefile.am): Substitute REPLACE_EXP2L.
+ * modules/exp2l (configure.ac): Consider REPLACE_EXP2L.
+ (Depends-on): Update conditions.
+ * modules/exp2l-ieee (Files): Add m4/exp2l-ieee.m4.
+ (configure.ac): Invoke gl_FUNC_EXP2L_IEEE.
+ * doc/posix-functions/exp2l.texi: Mention the exp2l-ieee module.
+
Tests for module 'exp2l-ieee'.
* modules/exp2l-ieee-tests: New file.
* tests/test-exp2l-ieee.c: New file.
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/exp2l.html}
-Gnulib module: exp2l
+Gnulib module: exp2l or exp2l-ieee
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{exp2l} or @code{exp2l-ieee}:
@itemize
@item
This function is missing on some platforms:
IRIX 6.5.
@end itemize
+Portability problems fixed by Gnulib module @code{exp2l-ieee}:
+@itemize
+@item
+This function returns a wrong value for a NaN argument on some platforms:
+OpenBSD 4.9.
+@item
+This function returns a wrong value for a negative infinity argument on some platforms:
+IRIX 6.5.
+@end itemize
+
Portability problems not fixed by Gnulib:
@itemize
@end itemize
#endif
#if @GNULIB_EXP2L@
-# if !@HAVE_DECL_EXP2L@
-# undef exp2l
+# if @REPLACE_EXP2L@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef exp2l
+# define exp2l rpl_exp2l
+# endif
+_GL_FUNCDECL_RPL (exp2l, long double, (long double x));
+_GL_CXXALIAS_RPL (exp2l, long double, (long double x));
+# else
+# if !@HAVE_DECL_EXP2L@
+# undef exp2l
_GL_FUNCDECL_SYS (exp2l, long double, (long double x));
-# endif
+# endif
_GL_CXXALIAS_SYS (exp2l, long double, (long double x));
+# endif
_GL_CXXALIASWARN (exp2l);
#elif defined GNULIB_POSIXCHECK
# undef exp2l
--- /dev/null
+# exp2l-ieee.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.
+
+dnl This macro is in a separate file (not in exp2l.m4 and not inlined in the
+dnl module description), so that gl_FUNC_EXP2L can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_EXP2L_IEEE],
+[
+ m4_divert_text([INIT_PREPARE], [gl_exp2l_required=ieee])
+ AC_REQUIRE([gl_FUNC_EXP2L])
+])
-# exp2l.m4 serial 1
+# exp2l.m4 serial 2
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,
AC_DEFUN([gl_FUNC_EXP2L],
[
+ m4_divert_text([DEFAULTS], [gl_exp2l_required=plain])
AC_REQUIRE([gl_MATH_H_DEFAULTS])
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
AC_REQUIRE([gl_FUNC_EXP2])
dnl Also check whether it's declared.
dnl IRIX 6.5 has exp2l() in libm but doesn't declare it in <math.h>.
AC_CHECK_DECL([exp2l], , [HAVE_DECL_EXP2L=0], [[#include <math.h>]])
+ m4_ifdef([gl_FUNC_EXP2L_IEEE], [
+ if test $gl_exp2l_required = ieee && test $REPLACE_EXP2L = 0; then
+ AC_CACHE_CHECK([whether exp2l works according to ISO C 99 with IEC 60559],
+ [gl_cv_func_exp2l_ieee],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $EXP2L_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+#undef exp2l
+extern
+#ifdef __cplusplus
+"C"
+#endif
+long double exp2l (long double);
+static long double dummy (long double x) { return 0; }
+static long double zero;
+int main (int argc, char *argv[])
+{
+ long double (*my_exp2l) (long double) = argc ? exp2l : dummy;
+ int result = 0;
+ /* This test fails on OpenBSD 4.9, where exp2l(NaN) = 0.0. */
+ if (exp2l (zero / zero) == 0.0L)
+ result |= 1;
+ /* This test fails on IRIX 6.5, where exp2l(-Inf) = 1.0. */
+ if (!(exp2l (-1.0L / zero) == 0.0L))
+ result |= 2;
+ return result;
+}
+ ]])],
+ [gl_cv_func_exp2l_ieee=yes],
+ [gl_cv_func_exp2l_ieee=no],
+ [gl_cv_func_exp2l_ieee="guessing no"])
+ LIBS="$save_LIBS"
+ ])
+ case "$gl_cv_func_exp2l_ieee" in
+ *yes) ;;
+ *) REPLACE_EXP2L=1 ;;
+ esac
+ fi
+ ])
else
HAVE_EXP2L=0
HAVE_DECL_EXP2L=0
+ fi
+ if test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; then
dnl Find libraries needed to link lib/exp2l.c.
if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
EXP2L_LIBM="$EXP2_LIBM"
-# math_h.m4 serial 91
+# math_h.m4 serial 92
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_EXPM1=0; AC_SUBST([REPLACE_EXPM1])
REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F])
REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2])
+ REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L])
REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL])
REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
Depends-on:
math
extensions
-exp2 [test $HAVE_EXP2L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
-float [test $HAVE_EXP2L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
-isnanl [test $HAVE_EXP2L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
-roundl [test $HAVE_EXP2L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
-ldexpl [test $HAVE_EXP2L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+exp2 [{ test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+float [{ test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+isnanl [{ test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+roundl [{ test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+ldexpl [{ test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
configure.ac:
gl_FUNC_EXP2L
-if test $HAVE_EXP2L = 0; then
+if test $HAVE_EXP2L = 0 || test $REPLACE_EXP2L = 1; then
AC_LIBOBJ([exp2l])
AC_LIBOBJ([expl-table])
fi
exp2l() function according to ISO C 99 with IEC 60559.
Files:
+m4/exp2l-ieee.m4
Depends-on:
exp2l
fpieee
configure.ac:
+gl_FUNC_EXP2L_IEEE
Makefile.am:
-e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
-e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
-e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \
+ -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \
-e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \
-e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \
-e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \