bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'ceill'


From: Bruno Haible
Subject: new module 'ceill'
Date: Fri, 5 Oct 2007 03:54:33 +0200
User-agent: KMail/1.5.4

Here the ceill() function replacement; like truncl().
The same comments as for floorl() apply.

2007-10-04  Bruno Haible  <address@hidden>

        * modules/ceill: New file.
        * lib/ceill.c: Replace entire file.
        * m4/ceill.m4: New file.
        * lib/math.in.h (ceill): Replace declaration.
        * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_CEILL.
        * modules/math (Makefile.am): Substitute also GNULIB_CEILL.
        * doc/functions/ceill.texi: Mention the 'ceill' module.
        * modules/mathl (Files): Remove lib/ceill.c.
        (Depends-on): Add ceill.

*** doc/functions/ceill.texi.orig       2007-10-05 03:52:29.000000000 +0200
--- doc/functions/ceill.texi    2007-10-05 03:07:21.000000000 +0200
***************
*** 4,18 ****
  
  POSIX specification: @url{http://www.opengroup.org/susv3xsh/ceill.html}
  
! Gnulib module: ---
  
  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
--- 4,18 ----
  
  POSIX specification: @url{http://www.opengroup.org/susv3xsh/ceill.html}
  
! Gnulib module: ceill
  
  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
  @end itemize
*** lib/ceill.c.orig    2007-10-05 03:52:29.000000000 +0200
--- lib/ceill.c 2007-10-05 03:08:38.000000000 +0200
***************
*** 1,9 ****
! /* Emulation for ceill.
!    Contributed by Paolo Bonzini
! 
!    Copyright 2002, 2003, 2007 Free Software Foundation, Inc.
! 
!    This file is part of gnulib.
  
     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
--- 1,5 ----
! /* Round towards positive 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,46 ****
     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
! ceill(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;
! }
--- 15,21 ----
     with this program; if not, write to the Free Software Foundation,
     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
  
! /* Written by Bruno Haible <address@hidden>, 2007.  */
  
! #define USE_LONG_DOUBLE
! #include "ceil.c"
*** lib/math.in.h.orig  2007-10-05 03:52:29.000000000 +0200
--- lib/math.in.h       2007-10-05 03:47:37.000000000 +0200
***************
*** 103,116 ****
       ceilf (x))
  #endif
  
! #if @GNULIB_MATHL@ || address@hidden@
  extern long double ceill (long double x);
! #endif
! #if address@hidden@ && defined GNULIB_POSIXCHECK
  # undef ceill
  # define ceill(x) \
      (GL_LINK_WARNING ("ceill is unportable - " \
!                       "use gnulib module mathl for portability"), \
       ceill (x))
  #endif
  
--- 103,118 ----
       ceilf (x))
  #endif
  
! #if @GNULIB_CEILL@
! # if address@hidden@
! #  define ceill rpl_ceill
  extern long double ceill (long double x);
! # endif
! #elif defined GNULIB_POSIXCHECK
  # undef ceill
  # define ceill(x) \
      (GL_LINK_WARNING ("ceill is unportable - " \
!                       "use gnulib module ceill for portability"), \
       ceill (x))
  #endif
  
Changing permissions from . to 100644
*** m4/ceill.m4.orig    2003-09-23 19:59:22.000000000 +0200
--- m4/ceill.m4 2007-10-05 03:52:29.000000000 +0200
***************
*** 0 ****
--- 1,48 ----
+ # ceill.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_CEILL],
+ [
+   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+   dnl Persuade glibc <math.h> to declare ceill().
+   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+   dnl Test whether ceill() is declared.
+   AC_CHECK_DECLS([ceill], , , [#include <math.h>])
+   if test "$ac_cv_have_decl_ceill" = yes; then
+     dnl Test whether ceill() can be used without libm.
+     CEILL_LIBM=?
+     AC_TRY_LINK([
+        #ifndef __NO_MATH_INLINES
+        # define __NO_MATH_INLINES 1 /* for glibc */
+        #endif
+        #include <math.h>
+        long double x;],
+       [x = ceill(x);],
+       [CEILL_LIBM=])
+     if test "$CEILL_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 = ceill(x);],
+         [CEILL_LIBM="-lm"])
+       LIBS="$save_LIBS"
+     fi
+     if test "$CEILL_LIBM" = "?"; then
+       CEILL_LIBM=
+     fi
+   else
+     HAVE_DECL_CEILL=0
+     AC_LIBOBJ([ceill])
+     CEILL_LIBM=
+   fi
+   AC_SUBST([HAVE_DECL_CEILL])
+   AC_SUBST([CEILL_LIBM])
+ ])
*** m4/math_h.m4.orig   2007-10-05 03:52:29.000000000 +0200
--- m4/math_h.m4        2007-10-05 03:46:28.000000000 +0200
***************
*** 20,25 ****
--- 20,26 ----
  AC_DEFUN([gl_MATH_H_DEFAULTS],
  [
    GNULIB_CEILF=0;   AC_SUBST([GNULIB_CEILF])
+   GNULIB_CEILL=0;   AC_SUBST([GNULIB_CEILL])
    GNULIB_FLOORF=0;  AC_SUBST([GNULIB_FLOORF])
    GNULIB_FLOORL=0;  AC_SUBST([GNULIB_FLOORL])
    GNULIB_FREXP=0;   AC_SUBST([GNULIB_FREXP])
Changing permissions from . to 100644
*** modules/ceill.orig  2003-09-23 19:59:22.000000000 +0200
--- modules/ceill       2007-10-05 03:11:41.000000000 +0200
***************
*** 0 ****
--- 1,31 ----
+ Description:
+ ceill() function: round towards positive infinity.
+ 
+ Files:
+ lib/ceill.c
+ lib/ceil.c
+ m4/ceill.m4
+ 
+ Depends-on:
+ math
+ extensions
+ float
+ 
+ configure.ac:
+ gl_FUNC_CEILL
+ gl_MATH_MODULE_INDICATOR([ceill])
+ 
+ Makefile.am:
+ 
+ Include:
+ <math.h>
+ 
+ Link:
+ $(CEILL_LIBM)
+ 
+ License:
+ LGPL
+ 
+ Maintainer:
+ Bruno Haible
+ 
*** modules/math.orig   2007-10-05 03:52:29.000000000 +0200
--- modules/math        2007-10-05 03:46:14.000000000 +0200
***************
*** 23,28 ****
--- 23,29 ----
          sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
              -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \
              -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \
+             -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \
              -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \
              -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \
              -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
*** modules/mathl.orig  2007-10-05 03:52:29.000000000 +0200
--- modules/mathl       2007-10-05 03:45:23.000000000 +0200
***************
*** 5,11 ****
  lib/acosl.c
  lib/asinl.c
  lib/atanl.c
- lib/ceill.c
  lib/cosl.c
  lib/expl.c
  lib/logl.c
--- 5,10 ----
***************
*** 24,29 ****
--- 23,29 ----
  isnanl
  ldexpl
  floorl
+ ceill
  
  configure.ac:
  gl_FUNC_LONG_DOUBLE_MATH





reply via email to

[Prev in Thread] Current Thread [Next in Thread]