bug-gnulib
[Top][All Lists]
Advanced

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

new module 'truncl'


From: Bruno Haible
Subject: new module 'truncl'
Date: Fri, 5 Oct 2007 01:39:29 +0200
User-agent: KMail/1.5.4

The module for the truncl() function is as easy as the one for truncf().
Only in the test suite, one must be careful to use the fpucw module, for
the sake of NetBSD.

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

        * modules/truncl: New file.
        * lib/truncl.c: New file.
        * m4/truncl.m4: New file.
        * lib/math.in.h (truncl): New declaration.
        * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_TRUNCL and
        HAVE_DECL_TRUNCL.
        * modules/math (Makefile.am): Substitute also GNULIB_TRUNCL and
        HAVE_DECL_TRUNCL.
        * doc/functions/truncl.texi: Mention the 'truncl' module.

*** doc/functions/truncl.texi.orig      2007-10-05 01:12:23.000000000 +0200
--- doc/functions/truncl.texi   2007-10-04 12:38:22.000000000 +0200
***************
*** 4,18 ****
  
  POSIX specification: @url{http://www.opengroup.org/susv3xsh/truncl.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, AIX 5.1, 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/truncl.html}
  
! Gnulib module: truncl
  
  Portability problems fixed by Gnulib:
  @itemize
+ @item
+ This function is missing on some platforms:
+ FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, 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/math.in.h.orig  2007-10-05 01:12:23.000000000 +0200
--- lib/math.in.h       2007-10-05 01:11:43.000000000 +0200
***************
*** 250,255 ****
--- 250,268 ----
       trunc (x))
  #endif
  
+ #if @GNULIB_TRUNCL@
+ # if address@hidden@
+ #  define truncl rpl_truncl
+ extern long double truncl (long double x);
+ # endif
+ #elif defined GNULIB_POSIXCHECK
+ # undef truncl
+ # define truncl(x) \
+     (GL_LINK_WARNING ("truncl is unportable - " \
+                       "use gnulib module truncl for portability"), \
+      truncl (x))
+ #endif
+ 
  
  #if @GNULIB_SIGNBIT@
  # if @REPLACE_SIGNBIT@
Changing permissions from . to 100644
*** lib/truncl.c.orig   2003-09-23 19:59:22.000000000 +0200
--- lib/truncl.c        2007-10-04 12:27:06.000000000 +0200
***************
*** 0 ****
--- 1,21 ----
+ /* Round towards zero.
+    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
+    the Free Software Foundation; either version 2, 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, 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 "trunc.c"
*** m4/math_h.m4.orig   2007-10-05 01:12:23.000000000 +0200
--- m4/math_h.m4        2007-10-05 01:10:50.000000000 +0200
***************
*** 26,31 ****
--- 26,32 ----
    GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
    GNULIB_TRUNC=0;   AC_SUBST([GNULIB_TRUNC])
    GNULIB_TRUNCF=0;  AC_SUBST([GNULIB_TRUNCF])
+   GNULIB_TRUNCL=0;  AC_SUBST([GNULIB_TRUNCL])
    dnl Assume proper GNU behavior unless another module says otherwise.
    HAVE_DECL_ACOSL=1;  AC_SUBST([HAVE_DECL_ACOSL])
    HAVE_DECL_ASINL=1;  AC_SUBST([HAVE_DECL_ASINL])
***************
*** 42,47 ****
--- 43,49 ----
    HAVE_DECL_TANL=1;   AC_SUBST([HAVE_DECL_TANL])
    HAVE_DECL_TRUNC=1;  AC_SUBST([HAVE_DECL_TRUNC])
    HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
+   HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
    REPLACE_FREXP=0;    AC_SUBST([REPLACE_FREXP])
    REPLACE_FREXPL=0;   AC_SUBST([REPLACE_FREXPL])
    REPLACE_LDEXPL=0;   AC_SUBST([REPLACE_LDEXPL])
Changing permissions from . to 100644
*** m4/truncl.m4.orig   2003-09-23 19:59:22.000000000 +0200
--- m4/truncl.m4        2007-10-05 00:56:34.000000000 +0200
***************
*** 0 ****
--- 1,48 ----
+ # truncl.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_TRUNCL],
+ [
+   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+   dnl Persuade glibc <math.h> to declare truncl().
+   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+   dnl Test whether truncl() is declared.
+   AC_CHECK_DECLS([truncl], , , [#include <math.h>])
+   if test "$ac_cv_have_decl_truncl" = yes; then
+     dnl Test whether truncl() can be used without libm.
+     TRUNCL_LIBM=?
+     AC_TRY_LINK([
+        #ifndef __NO_MATH_INLINES
+        # define __NO_MATH_INLINES 1 /* for glibc */
+        #endif
+        #include <math.h>
+        long double x;],
+       [x = truncl(x);],
+       [TRUNCL_LIBM=])
+     if test "$TRUNCL_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 = truncl(x);],
+         [TRUNCL_LIBM="-lm"])
+       LIBS="$save_LIBS"
+     fi
+     if test "$TRUNCL_LIBM" = "?"; then
+       TRUNCL_LIBM=
+     fi
+   else
+     HAVE_DECL_TRUNCL=0
+     AC_LIBOBJ([truncl])
+     TRUNCL_LIBM=
+   fi
+   AC_SUBST([HAVE_DECL_TRUNCL])
+   AC_SUBST([TRUNCL_LIBM])
+ ])
*** modules/math.orig   2007-10-05 01:12:23.000000000 +0200
--- modules/math        2007-10-05 01:10:30.000000000 +0200
***************
*** 29,34 ****
--- 29,35 ----
              -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \
              -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \
              -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \
+             -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \
              -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
              -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
              -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
***************
*** 44,49 ****
--- 45,51 ----
              -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
              -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
              -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
+             -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
              -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
              -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
              -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
Changing permissions from . to 100644
*** modules/truncl.orig 2003-09-23 19:59:22.000000000 +0200
--- modules/truncl      2007-10-05 00:55:10.000000000 +0200
***************
*** 0 ****
--- 1,31 ----
+ Description:
+ truncl() function: round towards zero.
+ 
+ Files:
+ lib/truncl.c
+ lib/trunc.c
+ m4/truncl.m4
+ 
+ Depends-on:
+ math
+ extensions
+ float
+ 
+ configure.ac:
+ gl_FUNC_TRUNCL
+ gl_MATH_MODULE_INDICATOR([truncl])
+ 
+ Makefile.am:
+ 
+ Include:
+ <math.h>
+ 
+ Link:
+ $(TRUNCL_LIBM)
+ 
+ License:
+ LGPL
+ 
+ Maintainer:
+ Bruno Haible
+ 





reply via email to

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