* modules/floorf-ieee: New file.
* m4/floorf.m4 (gl_FUNC_FLOORF): If gl_FUNC_FLOORF_IEEE is also used,
test whether floorf works according to ISO C 99 with IEC 60559.
* m4/floorf-ieee.m4: New file.
* modules/floorf-ieee-tests: New file.
* tests/test-floorf-ieee.c: New file, based on tests/test-floorf1.c.
* tests/test-floorf1.c (main): Remove signbit tests.
* modules/floorf-tests (Depends-on): Remove 'signbit'.
* doc/posix-functions/floorf.texi: Mention the new module.
+2010-12-21 Bruno Haible <bruno@clisp.org>
+
+ New module 'floorf-ieee'.
+ * modules/floorf-ieee: New file.
+ * m4/floorf.m4 (gl_FUNC_FLOORF): If gl_FUNC_FLOORF_IEEE is also used,
+ test whether floorf works according to ISO C 99 with IEC 60559.
+ * m4/floorf-ieee.m4: New file.
+ * modules/floorf-ieee-tests: New file.
+ * tests/test-floorf-ieee.c: New file, based on tests/test-floorf1.c.
+ * tests/test-floorf1.c (main): Remove signbit tests.
+ * modules/floorf-tests (Depends-on): Remove 'signbit'.
+ * doc/posix-functions/floorf.texi: Mention the new module.
+
2010-12-21 Bruno Haible <bruno@clisp.org>
Support for minus zero in autoconf macros.
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/floorf.html}
-Gnulib module: floorf
+Gnulib module: floorf or floorf-ieee
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{floorf} or @code{floorf-ieee}:
@itemize
@item
This function is missing on some platforms:
AIX 5.1, HP-UX 11, Solaris 9.
@end itemize
+Portability problems fixed by Gnulib module @code{floorf-ieee}:
+@itemize
+@item
+This function returns a positive zero for a minus zero argument
+on some platforms:
+OSF/1 5.1.
+@end itemize
+
Portability problems not fixed by Gnulib:
@itemize
@end itemize
--- /dev/null
+# floorf-ieee.m4 serial 1
+dnl Copyright (C) 2010 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 floorf.m4 and not inlined in the
+dnl module description), so that gl_FUNC_FLOORF can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_FLOORF_IEEE],
+[
+ m4_divert_text([INIT_PREPARE], [gl_floorf_required=ieee])
+ AC_REQUIRE([gl_FUNC_FLOORF])
+])
-# floorf.m4 serial 7
+# floorf.m4 serial 8
dnl Copyright (C) 2007, 2009-2010 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_FLOORF],
[
+ m4_divert_text([DEFAULTS], [gl_floorf_required=plain])
AC_REQUIRE([gl_MATH_H_DEFAULTS])
dnl Persuade glibc <math.h> to declare floorf().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
dnl libm.so, but not in the libm.so that the compiler uses.
REPLACE_FLOORF=1
fi
+ m4_ifdef([gl_FUNC_FLOORF_IEEE], [
+ if test $gl_floorf_required = ieee && test $REPLACE_FLOORF = 0; then
+ AC_CACHE_CHECK([whether floorf works according to ISO C 99 with IEC 60559],
+ [gl_cv_func_floorf_ieee],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $FLOORF_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_FLOAT_MINUS_ZERO_CODE[
+]gl_FLOAT_SIGNBIT_CODE[
+int main()
+{
+ /* Test whether floorf (-0.0f) is -0.0f. */
+ if (signbitf (minus_zerof) && !signbitf (floorf (minus_zerof)))
+ return 1;
+ return 0;
+}
+ ]])],
+ [gl_cv_func_floorf_ieee=yes],
+ [gl_cv_func_floorf_ieee=no],
+ [gl_cv_func_floorf_ieee="guessing no"])
+ LIBS="$save_LIBS"
+ ])
+ case "$gl_cv_func_floorf_ieee" in
+ *yes) ;;
+ *) REPLACE_FLOORF=1 ;;
+ esac
+ fi
+ ])
else
HAVE_DECL_FLOORF=0
fi
--- /dev/null
+Description:
+floorf() function according to ISO C 99 with IEC 60559.
+
+Files:
+m4/floorf-ieee.m4
+m4/minus-zero.m4
+m4/signbit.m4
+
+Depends-on:
+floorf
+
+configure.ac:
+gl_FUNC_FLOORF_IEEE
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(FLOORF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- /dev/null
+Files:
+tests/test-floorf-ieee.c
+tests/minus-zero.h
+tests/macros.h
+
+Depends-on:
+float
+signbit
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-floorf-ieee
+check_PROGRAMS += test-floorf-ieee
+test_floorf_ieee_LDADD = $(LDADD) @FLOORF_LIBM@
Depends-on:
float
isnanf-nolibm
-signbit
stdbool
stdint
--- /dev/null
+/* Test of rounding towards negative infinity.
+ Copyright (C) 2010 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <math.h>
+
+#include "minus-zero.h"
+#include "macros.h"
+
+/* If IEEE compliance was not requested, the ICC compiler inlines its
+ own floorf assembly that turns -0.0f to 0.0f; but that is a correct
+ result when IEEE is not enforced. To avoid spurious failure, we
+ have to provide this dummy function in order to outsmart ICC's
+ inlining, and call our floorf through a function pointer. */
+static float
+dummy (float f)
+{
+ return 0;
+}
+
+int
+main (int argc, char **argv _GL_UNUSED)
+{
+ float (*my_floorf) (float) = argc ? floorf : dummy;
+
+ /* Zero. */
+ ASSERT (!signbit (my_floorf (0.0f)));
+ ASSERT (!!signbit (my_floorf (minus_zerof)) == !!signbit (minus_zerof));
+
+ return 0;
+}
/* Zero. */
ASSERT (my_floorf (0.0f) == 0.0f);
- ASSERT (!signbit (my_floorf (0.0f)));
ASSERT (my_floorf (minus_zerof) == 0.0f);
- ASSERT (!!signbit (minus_zerof) == !!signbit (my_floorf (minus_zerof)));
/* Positive numbers. */
ASSERT (my_floorf (0.3f) == 0.0f);
ASSERT (my_floorf (0.7f) == 0.0f);