# HG changeset patch # User Bruno Haible # Date 1191548011 -7200 # Node ID b4e0b96fc4ba09e33e67903d6e41338a1a14c305 # Parent 7ad74ca8acb4595b9d6980f717e29226a71d94d7 New module 'floorl'. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-10-04 Bruno Haible + + * 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 * modules/floorf-tests: New file. diff --git a/doc/functions/floorl.texi b/doc/functions/floorl.texi --- 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 -@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 + +Portability problems not fixed by Gnulib: +@itemize +@end itemize diff --git a/lib/floorl.c b/lib/floorl.c --- 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 - -/* Specification. */ -#include - -#include - -/* To compute the integer part of X, sum a big enough - integer so that the precision of the floating point - number is exactly 1. */ +/* Written by Bruno Haible , 2007. */ -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; - - 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 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -139,14 +139,16 @@ 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 --- /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 to declare floorl(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + dnl Test whether floorl() is declared. + AC_CHECK_DECLS([floorl], , , [#include ]) + 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 + 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 + 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 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -20,6 +20,7 @@ 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 --- /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: + + +Link: +$(FLOORL_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible + diff --git a/modules/math b/modules/math --- a/modules/math +++ b/modules/math @@ -23,6 +23,7 @@ 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 --- a/modules/mathl +++ b/modules/mathl @@ -8,7 +8,6 @@ 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 @@ frexpl isnanl ldexpl +floorl configure.ac: gl_FUNC_LONG_DOUBLE_MATH