summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--doc/functions/floorl.texi8
-rw-r--r--lib/floorl.c35
-rw-r--r--lib/math.in.h10
-rw-r--r--m4/floorl.m448
-rw-r--r--m4/math_h.m41
-rw-r--r--modules/floorl31
-rw-r--r--modules/math1
-rw-r--r--modules/mathl2
9 files changed, 109 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d97b77a1c..d7033bf1a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2007-10-04 Bruno Haible <bruno@clisp.org>
+ * modules/floorl: New file.
+ * lib/floorl.c: Replace entire file.
+ * m4/floorl.m4: New file.
+ * lib/math.in.h (floorl): Replace declaration.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_FLOORL.
+ * modules/math (Makefile.am): Substitute also GNULIB_FLOORL.
+ * doc/functions/floorl.texi: Mention the 'floorl' module.
+ * modules/mathl (Files): Remove lib/floorl.c.
+ (Depends-on): Add floorl.
+
+2007-10-04 Bruno Haible <bruno@clisp.org>
+
* modules/floorf-tests: New file.
* tests/test-floorf.c: New file.
diff --git a/doc/functions/floorl.texi b/doc/functions/floorl.texi
index 90ea9d1402..63508006ec 100644
--- a/doc/functions/floorl.texi
+++ b/doc/functions/floorl.texi
@@ -4,15 +4,15 @@
POSIX specification: @url{http://www.opengroup.org/susv3xsh/floorl.html}
-Gnulib module: ---
+Gnulib module: floorl
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on some platforms:
-FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS.
@end itemize
diff --git a/lib/floorl.c b/lib/floorl.c
index 84b212e9e1..71d6b4f5b8 100644
--- a/lib/floorl.c
+++ b/lib/floorl.c
@@ -1,9 +1,5 @@
-/* Emulation for floorl.
- Contributed by Paolo Bonzini
-
- Copyright 2002, 2003, 2007 Free Software Foundation, Inc.
-
- This file is part of gnulib.
+/* Round towards negative infinity.
+ Copyright (C) 2007 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
@@ -19,28 +15,7 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#include <config.h>
-
-/* Specification. */
-#include <math.h>
-
-#include <float.h>
-
-/* To compute the integer part of X, sum a big enough
- integer so that the precision of the floating point
- number is exactly 1. */
-
-long double
-floorl(long double x)
-{
- long double y;
- if (x < 0.0L)
- y = -(1.0L / LDBL_EPSILON - x - 1.0 / LDBL_EPSILON);
- else
- y = 1.0L / LDBL_EPSILON + x - 1.0 / LDBL_EPSILON;
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
- if (y > x)
- return y - 1.0L;
- else
- return y;
-}
+#define USE_LONG_DOUBLE
+#include "floor.c"
diff --git a/lib/math.in.h b/lib/math.in.h
index 179e0c5426..490524276d 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -139,14 +139,16 @@ extern float floorf (float x);
floorf (x))
#endif
-#if @GNULIB_MATHL@ || !@HAVE_DECL_FLOORL@
+#if @GNULIB_FLOORL@
+# if !@HAVE_DECL_FLOORL@
+# define floorl rpl_floorl
extern long double floorl (long double x);
-#endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+# endif
+#elif defined GNULIB_POSIXCHECK
# undef floorl
# define floorl(x) \
(GL_LINK_WARNING ("floorl is unportable - " \
- "use gnulib module mathl for portability"), \
+ "use gnulib module floorl for portability"), \
floorl (x))
#endif
diff --git a/m4/floorl.m4 b/m4/floorl.m4
new file mode 100644
index 0000000000..0a5ecb76a2
--- /dev/null
+++ b/m4/floorl.m4
@@ -0,0 +1,48 @@
+# floorl.m4 serial 1
+dnl Copyright (C) 2007 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_FLOORL],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ dnl Persuade glibc <math.h> to declare floorl().
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ dnl Test whether floorl() is declared.
+ AC_CHECK_DECLS([floorl], , , [#include <math.h>])
+ if test "$ac_cv_have_decl_floorl" = yes; then
+ dnl Test whether floorl() can be used without libm.
+ FLOORL_LIBM=?
+ AC_TRY_LINK([
+ #ifndef __NO_MATH_INLINES
+ # define __NO_MATH_INLINES 1 /* for glibc */
+ #endif
+ #include <math.h>
+ long double x;],
+ [x = floorl(x);],
+ [FLOORL_LIBM=])
+ if test "$FLOORL_LIBM" = "?"; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS -lm"
+ AC_TRY_LINK([
+ #ifndef __NO_MATH_INLINES
+ # define __NO_MATH_INLINES 1 /* for glibc */
+ #endif
+ #include <math.h>
+ long double x;],
+ [x = floorl(x);],
+ [FLOORL_LIBM="-lm"])
+ LIBS="$save_LIBS"
+ fi
+ if test "$FLOORL_LIBM" = "?"; then
+ FLOORL_LIBM=
+ fi
+ else
+ HAVE_DECL_FLOORL=0
+ AC_LIBOBJ([floorl])
+ FLOORL_LIBM=
+ fi
+ AC_SUBST([HAVE_DECL_FLOORL])
+ AC_SUBST([FLOORL_LIBM])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index d5ef0b6827..3d12eb3be3 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -20,6 +20,7 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR],
AC_DEFUN([gl_MATH_H_DEFAULTS],
[
GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
+ GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
diff --git a/modules/floorl b/modules/floorl
new file mode 100644
index 0000000000..66c13621ad
--- /dev/null
+++ b/modules/floorl
@@ -0,0 +1,31 @@
+Description:
+floorl() function: round towards negative infinity.
+
+Files:
+lib/floorl.c
+lib/floor.c
+m4/floorl.m4
+
+Depends-on:
+math
+extensions
+float
+
+configure.ac:
+gl_FUNC_FLOORL
+gl_MATH_MODULE_INDICATOR([floorl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(FLOORL_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
diff --git a/modules/math b/modules/math
index a5ae2795cd..a892db3010 100644
--- a/modules/math
+++ b/modules/math
@@ -23,6 +23,7 @@ math.h: math.in.h
sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
-e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \
-e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \
+ -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \
-e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
-e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \
-e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
diff --git a/modules/mathl b/modules/mathl
index 892eea4417..1008cba64a 100644
--- a/modules/mathl
+++ b/modules/mathl
@@ -8,7 +8,6 @@ lib/atanl.c
lib/ceill.c
lib/cosl.c
lib/expl.c
-lib/floorl.c
lib/logl.c
lib/sincosl.c
lib/sinl.c
@@ -24,6 +23,7 @@ math
frexpl
isnanl
ldexpl
+floorl
configure.ac:
gl_FUNC_LONG_DOUBLE_MATH