Mercurial > hg > octave-lyh > gnulib-hg
changeset 9293:b4e0b96fc4ba
New module 'floorl'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 05 Oct 2007 03:33:31 +0200 |
parents | 7ad74ca8acb4 |
children | 868479cd3505 |
files | ChangeLog doc/functions/floorl.texi lib/floorl.c lib/math.in.h m4/floorl.m4 m4/math_h.m4 modules/floorl modules/math modules/mathl |
diffstat | 9 files changed, 110 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +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.
--- 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
--- 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. */ +/* Written by Bruno Haible <bruno@clisp.org>, 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"
--- 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
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 <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]) +])
--- 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])
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: +<math.h> + +Link: +$(FLOORL_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible +
--- 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' \