guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-15-114-gb


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-15-114-gb81eb64
Date: Tue, 15 Feb 2011 10:32:35 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=b81eb64633817927eb488b0d54a9a4a371694229

The branch, master has been updated
       via  b81eb64633817927eb488b0d54a9a4a371694229 (commit)
      from  d9f464726d6eb1b53dc317de47490e12e8e9abc1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b81eb64633817927eb488b0d54a9a4a371694229
Author: Ludovic Courtès <address@hidden>
Date:   Tue Feb 15 11:28:10 2011 +0100

    Import Gnulib's `log1p' and `round' modules.
    
    From Gnulib v0.0-4889-ge375fe3.
    
    * m4/gnulib-cache.m4: Add `log1p' and `round', requested by
      Mark H Weaver <address@hidden>.
      Use `malloc-gnu' instead of `malloc', the latter being obsolete.

-----------------------------------------------------------------------

Summary of changes:
 .gitignore               |    1 +
 lib/Makefile.am          |   23 ++++++-
 lib/{trunc.c => floor.c} |   32 ++-------
 lib/round.c              |  168 ++++++++++++++++++++++++++++++++++++++++++++++
 m4/ceil.m4               |   88 ++++++++++++++++++++++++
 m4/floor.m4              |   88 ++++++++++++++++++++++++
 m4/gnulib-cache.m4       |    6 +-
 m4/gnulib-comp.m4        |   17 +++++
 m4/mathfunc.m4           |  122 +++++++++++++++++++++++++++++++++
 m4/round.m4              |  111 ++++++++++++++++++++++++++++++
 10 files changed, 629 insertions(+), 27 deletions(-)
 copy lib/{trunc.c => floor.c} (83%)
 create mode 100644 lib/round.c
 create mode 100644 m4/ceil.m4
 create mode 100644 m4/floor.m4
 create mode 100644 m4/mathfunc.m4
 create mode 100644 m4/round.m4

diff --git a/.gitignore b/.gitignore
index f7f3258..f24e589 100644
--- a/.gitignore
+++ b/.gitignore
@@ -138,3 +138,4 @@ INSTALL
 /lib/c++defs.h
 /.sc-start-*
 /lib/math.h
+/lib/sys/time.h
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6d59b8b..2e5b7db 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 
--libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt 
announce-gen autobuild bind byteswap canonicalize-lgpl close connect duplocale 
environ extensions flock fpieee full-read full-write func gendocs getaddrinfo 
getpeername getsockname getsockopt git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring listen locale 
maintainer-makefile malloc malloca nproc putenv recv recvfrom send sendto 
setsockopt shutdown socket sockets stat-time stdlib strcase strftime striconveh 
string sys_stat trunc verify version-etc-fsf vsnprintf warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 
--libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt 
announce-gen autobuild bind byteswap canonicalize-lgpl close connect duplocale 
environ extensions flock fpieee full-read full-write func gendocs getaddrinfo 
getpeername getsockname getsockopt git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring listen locale 
log1p maintainer-makefile malloc malloca nproc putenv recv recvfrom round send 
sendto setsockopt shutdown socket sockets stat-time stdlib strcase strftime 
striconveh string sys_stat trunc verify version-etc-fsf vsnprintf warnings
 
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
 
@@ -37,6 +37,7 @@ libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
 EXTRA_libgnu_la_SOURCES =
 libgnu_la_LDFLAGS = $(AM_LDFLAGS)
 libgnu_la_LDFLAGS += -no-undefined
+libgnu_la_LDFLAGS += $(FLOOR_LIBM)
 libgnu_la_LDFLAGS += $(GETADDRINFO_LIB)
 libgnu_la_LDFLAGS += $(HOSTENT_LIB)
 libgnu_la_LDFLAGS += $(INET_NTOP_LIB)
@@ -45,9 +46,11 @@ libgnu_la_LDFLAGS += $(ISNAND_LIBM)
 libgnu_la_LDFLAGS += $(ISNANF_LIBM)
 libgnu_la_LDFLAGS += $(ISNANL_LIBM)
 libgnu_la_LDFLAGS += $(LIBSOCKET)
+libgnu_la_LDFLAGS += $(LOG1P_LIBM)
 libgnu_la_LDFLAGS += $(LTLIBICONV)
 libgnu_la_LDFLAGS += $(LTLIBINTL)
 libgnu_la_LDFLAGS += $(LTLIBUNISTRING)
+libgnu_la_LDFLAGS += $(ROUND_LIBM)
 libgnu_la_LDFLAGS += $(SERVENT_LIB)
 libgnu_la_LDFLAGS += $(TRUNC_LIBM)
 
@@ -331,6 +334,15 @@ EXTRA_libgnu_la_SOURCES += flock.c
 
 ## end   gnulib module flock
 
+## begin gnulib module floor
+
+
+EXTRA_DIST += floor.c
+
+EXTRA_libgnu_la_SOURCES += floor.c
+
+## end   gnulib module floor
+
 ## begin gnulib module full-read
 
 libgnu_la_SOURCES += full-read.h full-read.c
@@ -892,6 +904,15 @@ EXTRA_libgnu_la_SOURCES += recvfrom.c
 
 ## end   gnulib module recvfrom
 
+## begin gnulib module round
+
+
+EXTRA_DIST += round.c
+
+EXTRA_libgnu_la_SOURCES += round.c
+
+## end   gnulib module round
+
 ## begin gnulib module safe-read
 
 
diff --git a/lib/trunc.c b/lib/floor.c
similarity index 83%
copy from lib/trunc.c
copy to lib/floor.c
index f213b26..12d0194 100644
--- a/lib/trunc.c
+++ b/lib/floor.c
@@ -1,4 +1,4 @@
-/* Round towards zero.
+/* Round towards negative infinity.
    Copyright (C) 2007, 2010-2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -23,35 +23,23 @@
 
 #include <float.h>
 
-#undef MIN
-
 #ifdef USE_LONG_DOUBLE
-# define FUNC truncl
+# define FUNC floorl
 # define DOUBLE long double
 # define MANT_DIG LDBL_MANT_DIG
-# define MIN LDBL_MIN
 # define L_(literal) literal##L
 #elif ! defined USE_FLOAT
-# define FUNC trunc
+# define FUNC floor
 # define DOUBLE double
 # define MANT_DIG DBL_MANT_DIG
-# define MIN DBL_MIN
 # define L_(literal) literal
 #else /* defined USE_FLOAT */
-# define FUNC truncf
+# define FUNC floorf
 # define DOUBLE float
 # define MANT_DIG FLT_MANT_DIG
-# define MIN FLT_MIN
 # define L_(literal) literal##f
 #endif
 
-/* -0.0.  See minus-zero.h.  */
-#if defined __hpux || defined __sgi || defined __ICC
-# define MINUS_ZERO (-MIN * MIN)
-#else
-# define MINUS_ZERO L_(-0.0)
-#endif
-
 /* 2^(MANT_DIG-1).  */
 static const DOUBLE TWO_MANT_DIG =
   /* Assume MANT_DIG <= 5 * 31.
@@ -94,19 +82,15 @@ FUNC (DOUBLE x)
     }
   else if (z < L_(0.0))
     {
-      /* For -1 < x < 0, return -0.0 regardless of the current rounding
-         mode.  */
-      if (z > L_(-1.0))
-        z = MINUS_ZERO;
       /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1.  */
-      else if (z > - TWO_MANT_DIG)
+      if (z > - TWO_MANT_DIG)
         {
           /* Round to the next integer (nearest or up or down, doesn't 
matter).  */
           z -= TWO_MANT_DIG;
           z += TWO_MANT_DIG;
-          /* Enforce rounding up.  */
-          if (z < y)
-            z += L_(1.0);
+          /* Enforce rounding down.  */
+          if (z > y)
+            z -= L_(1.0);
         }
     }
   return z;
diff --git a/lib/round.c b/lib/round.c
new file mode 100644
index 0000000..1630a6d
--- /dev/null
+++ b/lib/round.c
@@ -0,0 +1,168 @@
+/* Round toward nearest, breaking ties away from zero.
+   Copyright (C) 2007, 2010-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser 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 Ben Pfaff <address@hidden>, 2007.
+   Based heavily on code by Bruno Haible. */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+#include <float.h>
+
+#undef MIN
+
+#ifdef USE_LONG_DOUBLE
+# define ROUND roundl
+# define FLOOR floorl
+# define CEIL ceill
+# define DOUBLE long double
+# define MANT_DIG LDBL_MANT_DIG
+# define MIN LDBL_MIN
+# define L_(literal) literal##L
+# define HAVE_FLOOR_AND_CEIL HAVE_FLOORL_AND_CEILL
+#elif ! defined USE_FLOAT
+# define ROUND round
+# define FLOOR floor
+# define CEIL ceil
+# define DOUBLE double
+# define MANT_DIG DBL_MANT_DIG
+# define MIN DBL_MIN
+# define L_(literal) literal
+# define HAVE_FLOOR_AND_CEIL 1
+#else /* defined USE_FLOAT */
+# define ROUND roundf
+# define FLOOR floorf
+# define CEIL ceilf
+# define DOUBLE float
+# define MANT_DIG FLT_MANT_DIG
+# define MIN FLT_MIN
+# define L_(literal) literal##f
+# define HAVE_FLOOR_AND_CEIL HAVE_FLOORF_AND_CEILF
+#endif
+
+/* -0.0.  See minus-zero.h.  */
+#if defined __hpux || defined __sgi || defined __ICC
+# define MINUS_ZERO (-MIN * MIN)
+#else
+# define MINUS_ZERO L_(-0.0)
+#endif
+
+/* If we're being included from test-round2[f].c, it already defined names for
+   our round implementations.  Otherwise, pick the preferred implementation for
+   this machine. */
+#if !defined FLOOR_BASED_ROUND && !defined FLOOR_FREE_ROUND
+# if HAVE_FLOOR_AND_CEIL
+#  define FLOOR_BASED_ROUND ROUND
+# else
+#  define FLOOR_FREE_ROUND ROUND
+# endif
+#endif
+
+#ifdef FLOOR_BASED_ROUND
+/* An implementation of the C99 round function based on floor and ceil.  We use
+   this when floor and ceil are available, on the assumption that they are
+   faster than the open-coded versions below. */
+DOUBLE
+FLOOR_BASED_ROUND (DOUBLE x)
+{
+  if (x >= L_(0.0))
+    {
+      DOUBLE y = FLOOR (x);
+      if (x - y >= L_(0.5))
+        y += L_(1.0);
+      return y;
+    }
+  else
+    {
+      DOUBLE y = CEIL (x);
+      if (y - x >= L_(0.5))
+        y -= L_(1.0);
+      return y;
+    }
+}
+#endif /* FLOOR_BASED_ROUND */
+
+#ifdef FLOOR_FREE_ROUND
+/* An implementation of the C99 round function without floor or ceil.
+   We use this when floor or ceil is missing. */
+DOUBLE
+FLOOR_FREE_ROUND (DOUBLE x)
+{
+  /* 2^(MANT_DIG-1).  */
+  static const DOUBLE TWO_MANT_DIG =
+    /* Assume MANT_DIG <= 5 * 31.
+       Use the identity
+       n = floor(n/5) + floor((n+1)/5) + ... + floor((n+4)/5).  */
+    (DOUBLE) (1U << ((MANT_DIG - 1) / 5))
+    * (DOUBLE) (1U << ((MANT_DIG - 1 + 1) / 5))
+    * (DOUBLE) (1U << ((MANT_DIG - 1 + 2) / 5))
+    * (DOUBLE) (1U << ((MANT_DIG - 1 + 3) / 5))
+    * (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
+
+  /* The use of 'volatile' guarantees that excess precision bits are dropped at
+     each addition step and before the following comparison at the caller's
+     site.  It is necessary on x86 systems where double-floats are not IEEE
+     compliant by default, to avoid that the results become platform and
+     compiler option dependent.  'volatile' is a portable alternative to gcc's
+     -ffloat-store option.  */
+  volatile DOUBLE y = x;
+  volatile DOUBLE z = y;
+
+  if (z > L_(0.0))
+    {
+      /* Avoid rounding error for x = 0.5 - 2^(-MANT_DIG-1).  */
+      if (z < L_(0.5))
+        z = L_(0.0);
+      /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1.  */
+      else if (z < TWO_MANT_DIG)
+        {
+          /* Add 0.5 to the absolute value.  */
+          y = z += L_(0.5);
+          /* Round to the next integer (nearest or up or down, doesn't
+             matter).  */
+          z += TWO_MANT_DIG;
+          z -= TWO_MANT_DIG;
+          /* Enforce rounding down.  */
+          if (z > y)
+            z -= L_(1.0);
+        }
+    }
+  else if (z < L_(0.0))
+    {
+      /* Avoid rounding error for x = -(0.5 - 2^(-MANT_DIG-1)).  */
+      if (z > - L_(0.5))
+        z = MINUS_ZERO;
+      /* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1.  */
+      else if (z > -TWO_MANT_DIG)
+        {
+          /* Add 0.5 to the absolute value.  */
+          y = z -= L_(0.5);
+          /* Round to the next integer (nearest or up or down, doesn't
+             matter).  */
+          z -= TWO_MANT_DIG;
+          z += TWO_MANT_DIG;
+          /* Enforce rounding up.  */
+          if (z < y)
+            z += L_(1.0);
+        }
+    }
+  return z;
+}
+#endif /* FLOOR_FREE_ROUND */
+
diff --git a/m4/ceil.m4 b/m4/ceil.m4
new file mode 100644
index 0000000..21d04b4
--- /dev/null
+++ b/m4/ceil.m4
@@ -0,0 +1,88 @@
+# ceil.m4 serial 5
+dnl Copyright (C) 2007, 2009-2011 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_CEIL],
+[
+  m4_divert_text([DEFAULTS], [gl_ceil_required=plain])
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  dnl Test whether ceil() can be used without libm.
+  gl_FUNC_CEIL_LIBS
+  if test "$CEIL_LIBM" = "?"; then
+    CEIL_LIBM=
+  fi
+  m4_ifdef([gl_FUNC_CEIL_IEEE], [
+    if test $gl_ceil_required = ieee && test $REPLACE_CEIL = 0; then
+      AC_CACHE_CHECK([whether ceil works according to ISO C 99 with IEC 60559],
+        [gl_cv_func_ceil_ieee],
+        [
+          save_LIBS="$LIBS"
+          LIBS="$LIBS $CEIL_LIBM"
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_DOUBLE_MINUS_ZERO_CODE[
+]gl_DOUBLE_SIGNBIT_CODE[
+int main()
+{
+  /* Test whether ceil (-0.0) is -0.0.  */
+  if (signbitd (minus_zerod) && !signbitd (ceil (minus_zerod)))
+    return 1;
+  return 0;
+}
+            ]])],
+            [gl_cv_func_ceil_ieee=yes],
+            [gl_cv_func_ceil_ieee=no],
+            [gl_cv_func_ceil_ieee="guessing no"])
+          LIBS="$save_LIBS"
+        ])
+      case "$gl_cv_func_ceil_ieee" in
+        *yes) ;;
+        *) REPLACE_CEIL=1 ;;
+      esac
+    fi
+  ])
+  if test $REPLACE_CEIL = 1; then
+    AC_LIBOBJ([ceil])
+    CEIL_LIBM=
+  fi
+  AC_SUBST([CEIL_LIBM])
+])
+
+# Determines the libraries needed to get the ceil() function.
+# Sets CEIL_LIBM.
+AC_DEFUN([gl_FUNC_CEIL_LIBS],
+[
+  gl_CACHE_VAL_SILENT([gl_cv_func_ceil_libm], [
+    gl_cv_func_ceil_libm=?
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#ifndef __NO_MATH_INLINES
+           # define __NO_MATH_INLINES 1 /* for glibc */
+           #endif
+           #include <math.h>
+           double x;]],
+         [[x = ceil(x);]])],
+      [gl_cv_func_ceil_libm=])
+    if test "$gl_cv_func_ceil_libm" = "?"; then
+      save_LIBS="$LIBS"
+      LIBS="$LIBS -lm"
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#ifndef __NO_MATH_INLINES
+             # define __NO_MATH_INLINES 1 /* for glibc */
+             #endif
+             #include <math.h>
+             double x;]],
+           [[x = ceil(x);]])],
+        [gl_cv_func_ceil_libm="-lm"])
+      LIBS="$save_LIBS"
+    fi
+  ])
+  CEIL_LIBM="$gl_cv_func_ceil_libm"
+])
diff --git a/m4/floor.m4 b/m4/floor.m4
new file mode 100644
index 0000000..5683107
--- /dev/null
+++ b/m4/floor.m4
@@ -0,0 +1,88 @@
+# floor.m4 serial 5
+dnl Copyright (C) 2007, 2009-2011 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_FLOOR],
+[
+  m4_divert_text([DEFAULTS], [gl_floor_required=plain])
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  dnl Test whether floor() can be used without libm.
+  gl_FUNC_FLOOR_LIBS
+  if test "$FLOOR_LIBM" = "?"; then
+    FLOOR_LIBM=
+  fi
+  m4_ifdef([gl_FUNC_FLOOR_IEEE], [
+    if test $gl_floor_required = ieee && test $REPLACE_FLOOR = 0; then
+      AC_CACHE_CHECK([whether floor works according to ISO C 99 with IEC 
60559],
+        [gl_cv_func_floor_ieee],
+        [
+          save_LIBS="$LIBS"
+          LIBS="$LIBS $FLOOR_LIBM"
+          AC_RUN_IFELSE(
+            [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_DOUBLE_MINUS_ZERO_CODE[
+]gl_DOUBLE_SIGNBIT_CODE[
+int main()
+{
+  /* Test whether floor (-0.0) is -0.0.  */
+  if (signbitd (minus_zerod) && !signbitd (floor (minus_zerod)))
+    return 1;
+  return 0;
+}
+            ]])],
+            [gl_cv_func_floor_ieee=yes],
+            [gl_cv_func_floor_ieee=no],
+            [gl_cv_func_floor_ieee="guessing no"])
+          LIBS="$save_LIBS"
+        ])
+      case "$gl_cv_func_floor_ieee" in
+        *yes) ;;
+        *) REPLACE_FLOOR=1 ;;
+      esac
+    fi
+  ])
+  if test $REPLACE_FLOOR = 1; then
+    AC_LIBOBJ([floor])
+    FLOOR_LIBM=
+  fi
+  AC_SUBST([FLOOR_LIBM])
+])
+
+# Determines the libraries needed to get the floor() function.
+# Sets FLOOR_LIBM.
+AC_DEFUN([gl_FUNC_FLOOR_LIBS],
+[
+  gl_CACHE_VAL_SILENT([gl_cv_func_floor_libm], [
+    gl_cv_func_floor_libm=?
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#ifndef __NO_MATH_INLINES
+           # define __NO_MATH_INLINES 1 /* for glibc */
+           #endif
+           #include <math.h>
+           double x;]],
+         [[x = floor(x);]])],
+      [gl_cv_func_floor_libm=])
+    if test "$gl_cv_func_floor_libm" = "?"; then
+      save_LIBS="$LIBS"
+      LIBS="$LIBS -lm"
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#ifndef __NO_MATH_INLINES
+             # define __NO_MATH_INLINES 1 /* for glibc */
+             #endif
+             #include <math.h>
+             double x;]],
+           [[x = floor(x);]])],
+        [gl_cv_func_floor_libm="-lm"])
+      LIBS="$save_LIBS"
+    fi
+  ])
+  FLOOR_LIBM="$gl_cv_func_floor_libm"
+])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index eabea40..2db76c1 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 
--doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool 
--macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen 
autobuild bind byteswap canonicalize-lgpl close connect duplocale environ 
extensions flock fpieee full-read full-write func gendocs getaddrinfo 
getpeername getsockname getsockopt git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring listen locale 
maintainer-makefile malloc malloca nproc putenv recv recvfrom send sendto 
setsockopt shutdown socket sockets stat-time stdlib strcase strftime striconveh 
string sys_stat trunc verify version-etc-fsf vsnprintf warnings
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 
--doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool 
--macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen 
autobuild bind byteswap canonicalize-lgpl close connect duplocale environ 
extensions flock fpieee full-read full-write func gendocs getaddrinfo 
getpeername getsockname getsockopt git-version-gen gitlog-to-changelog 
gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf 
isnan lib-symbol-versions lib-symbol-visibility libunistring listen locale 
log1p maintainer-makefile malloc malloca nproc putenv recv recvfrom round send 
sendto setsockopt shutdown socket sockets stat-time stdlib strcase strftime 
striconveh string sys_stat trunc verify version-etc-fsf vsnprintf warnings
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
@@ -58,13 +58,15 @@ gl_MODULES([
   libunistring
   listen
   locale
+  log1p
   maintainer-makefile
-  malloc
+  malloc-gnu
   malloca
   nproc
   putenv
   recv
   recvfrom
+  round
   send
   sendto
   setsockopt
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index bb700f7..b9abec1 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -53,6 +53,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module fclose:
   # Code from module float:
   # Code from module flock:
+  # Code from module floor:
   # Code from module fpieee:
   AC_REQUIRE([gl_FP_IEEE])
   # Code from module full-read:
@@ -90,6 +91,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module libunistring:
   # Code from module listen:
   # Code from module locale:
+  # Code from module log1p:
   # Code from module lstat:
   # Code from module maintainer-makefile:
   # Code from module malloc:
@@ -107,6 +109,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module readlink:
   # Code from module recv:
   # Code from module recvfrom:
+  # Code from module round:
   # Code from module safe-read:
   # Code from module safe-write:
   # Code from module send:
@@ -242,6 +245,9 @@ AC_DEFUN([gl_INIT],
   # Code from module flock:
   gl_FUNC_FLOCK
   gl_HEADER_SYS_FILE_MODULE_INDICATOR([flock])
+  # Code from module floor:
+  gl_FUNC_FLOOR
+  gl_MATH_MODULE_INDICATOR([floor])
   # Code from module fpieee:
   # Code from module full-read:
   # Code from module full-write:
@@ -339,6 +345,8 @@ AC_DEFUN([gl_INIT],
   gl_SYS_SOCKET_MODULE_INDICATOR([listen])
   # Code from module locale:
   gl_LOCALE_H
+  # Code from module log1p:
+  gl_COMMON_DOUBLE_MATHFUNC([log1p])
   # Code from module lstat:
   gl_FUNC_LSTAT
   gl_SYS_STAT_MODULE_INDICATOR([lstat])
@@ -388,6 +396,9 @@ AC_DEFUN([gl_INIT],
     AC_LIBOBJ([recvfrom])
   fi
   gl_SYS_SOCKET_MODULE_INDICATOR([recvfrom])
+  # Code from module round:
+  gl_FUNC_ROUND
+  gl_MATH_MODULE_INDICATOR([round])
   # Code from module safe-read:
   gl_SAFE_READ
   # Code from module safe-write:
@@ -714,6 +725,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/float+.h
   lib/float.in.h
   lib/flock.c
+  lib/floor.c
   lib/full-read.c
   lib/full-read.h
   lib/full-write.c
@@ -765,6 +777,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/readlink.c
   lib/recv.c
   lib/recvfrom.c
+  lib/round.c
   lib/safe-read.c
   lib/safe-read.h
   lib/safe-write.c
@@ -832,6 +845,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/autobuild.m4
   m4/byteswap.m4
   m4/canonicalize.m4
+  m4/ceil.m4
   m4/check-math-lib.m4
   m4/close.m4
   m4/dos.m4
@@ -847,6 +861,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/fclose.m4
   m4/float_h.m4
   m4/flock.m4
+  m4/floor.m4
   m4/fpieee.m4
   m4/func.m4
   m4/getaddrinfo.m4
@@ -878,6 +893,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/malloc.m4
   m4/malloca.m4
   m4/math_h.m4
+  m4/mathfunc.m4
   m4/memchr.m4
   m4/mmap-anon.m4
   m4/multiarch.m4
@@ -888,6 +904,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/printf.m4
   m4/putenv.m4
   m4/readlink.m4
+  m4/round.m4
   m4/safe-read.m4
   m4/safe-write.m4
   m4/servent.m4
diff --git a/m4/mathfunc.m4 b/m4/mathfunc.m4
new file mode 100644
index 0000000..40a27b4
--- /dev/null
+++ b/m4/mathfunc.m4
@@ -0,0 +1,122 @@
+# mathfunc.m4 serial 6
+dnl Copyright (C) 2010-2011 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.
+
+# gl_MATHFUNC(FUNC, RETTYPE, PARAMTYPES)
+# --------------------------------------------------
+# tests whether the function FUNC is available in libc or libm.
+# RETTYPE is the return type. PARAMTYPES is a parameter list, with parentheses.
+# It sets FUNC_LIBM to empty or "-lm" accordingly.
+
+AC_DEFUN([gl_MATHFUNC],
+[
+  dnl We need the RETTYPE and PARAMTYPES in order to force linking with the
+  dnl function. With gcc >= 4.3 on glibc/x86_64, calls to the 'fabs' function
+  dnl are inlined by the compiler, therefore linking of these calls does not
+  dnl require -lm, but taking the function pointer of 'fabs' does.
+  m4_pushdef([func], [$1])
+  m4_pushdef([FUNC], [m4_translit([$1],[abcdefghijklmnopqrstuvwxyz],
+                                       [ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
+  FUNC[]_LIBM=
+  AC_CACHE_CHECK([whether func() can be used without linking with libm],
+    [gl_cv_func_]func[_no_libm],
+    [
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#ifndef __NO_MATH_INLINES
+             # define __NO_MATH_INLINES 1 /* for glibc */
+             #endif
+             #include <math.h>
+             $2 (*funcptr) $3 = ]func[;
+             double d_ret;]],
+           [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], 
[int], [2])], [double \*], [&d_ret])], [double], [1.6180339887])[;
+             return y < 0.3 || y > 1.7;
+           ]])],
+        [gl_cv_func_]func[_no_libm=yes],
+        [gl_cv_func_]func[_no_libm=no])
+    ])
+  if test $gl_cv_func_[]func[]_no_libm = no; then
+    AC_CACHE_CHECK([whether func() can be used with libm],
+      [gl_cv_func_]func[_in_libm],
+      [
+        save_LIBS="$LIBS"
+        LIBS="$LIBS -lm"
+        AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[#ifndef __NO_MATH_INLINES
+               # define __NO_MATH_INLINES 1 /* for glibc */
+               #endif
+               #include <math.h>
+               $2 (*funcptr) $3 = ]func[;
+               double d_ret;]],
+             [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], 
[int], [2])], [double \*], [&d_ret])], [double], [1.6180339887])[;
+               return y < 0.3 || y > 1.7;
+             ]])],
+          [gl_cv_func_]func[_in_libm=yes],
+          [gl_cv_func_]func[_in_libm=no])
+        LIBS="$save_LIBS"
+      ])
+    if test $gl_cv_func_[]func[]_in_libm = yes; then
+      FUNC[]_LIBM=-lm
+    fi
+  fi
+  AC_SUBST(FUNC[_LIBM])
+  m4_popdef([FUNC])
+  m4_popdef([func])
+])
+
+# gl_COMMON_DOUBLE_MATHFUNC(FUNC)
+# -------------------------------
+# tests whether the function FUNC is available in libc or libm.
+# It sets FUNC_LIBM to empty or "-lm" accordingly.
+# FUNC must be one of the following functions, that are present on all systems
+# and provided by libm on all systems except MacOS X, BeOS, Haiku:
+#   acos asin atan atan2 cbrt cos cosh erf erfc exp fmod hypot j0 j1 jn lgamma
+#   log log10 log1p pow remainder sin sinh sqrt tan tanh y0 y1 yn
+
+AC_DEFUN([gl_COMMON_DOUBLE_MATHFUNC],
+[
+  AC_REQUIRE([gl_COMMON_DOUBLE_MATHFUNC_TEST])
+  m4_pushdef([FUNC], [m4_translit([$1],[abcdefghijklmnopqrstuvwxyz],
+                                       [ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
+  FUNC[]_LIBM="$POW_LIBM"
+  AC_SUBST(FUNC[_LIBM])
+  m4_popdef([FUNC])
+])
+
+AC_DEFUN([gl_COMMON_DOUBLE_MATHFUNC_TEST],
+[
+  dnl We could use any of the following:
+  dnl gl_MATHFUNC([acos], [double], [(double)])
+  dnl gl_MATHFUNC([asin], [double], [(double)])
+  dnl gl_MATHFUNC([atan], [double], [(double)])
+  dnl gl_MATHFUNC([atan2], [double], [(double, double)])
+  dnl gl_MATHFUNC([cbrt], [double], [(double)])
+  dnl gl_MATHFUNC([cos], [double], [(double)])
+  dnl gl_MATHFUNC([cosh], [double], [(double)])
+  dnl gl_MATHFUNC([erf], [double], [(double)])
+  dnl gl_MATHFUNC([erfc], [double], [(double)])
+  dnl gl_MATHFUNC([exp], [double], [(double)])
+  dnl gl_MATHFUNC([fmod], [double], [(double, double)])
+  dnl gl_MATHFUNC([hypot], [double], [(double, double)])
+  dnl gl_MATHFUNC([j0], [double], [(double)])
+  dnl gl_MATHFUNC([j1], [double], [(double)])
+  dnl gl_MATHFUNC([jn], [double], [(int, double)])
+  dnl gl_MATHFUNC([lgamma], [double], [(double)])
+  dnl gl_MATHFUNC([log], [double], [(double)])
+  dnl gl_MATHFUNC([log10], [double], [(double)])
+  dnl gl_MATHFUNC([log1p], [double], [(double)])
+  dnl gl_MATHFUNC([pow], [double], [(double, double)])
+  dnl gl_MATHFUNC([remainder], [double], [(double, double)])
+  dnl gl_MATHFUNC([sin], [double], [(double)])
+  dnl gl_MATHFUNC([sinh], [double], [(double)])
+  dnl gl_MATHFUNC([sqrt], [double], [(double)])
+  dnl gl_MATHFUNC([tan], [double], [(double)])
+  dnl gl_MATHFUNC([tanh], [double], [(double)])
+  dnl gl_MATHFUNC([y0], [double], [(double)])
+  dnl gl_MATHFUNC([y1], [double], [(double)])
+  dnl gl_MATHFUNC([yn], [double], [(int, double)])
+  gl_MATHFUNC([pow], [double], [(double, double)])
+])
diff --git a/m4/round.m4 b/m4/round.m4
new file mode 100644
index 0000000..a95d905
--- /dev/null
+++ b/m4/round.m4
@@ -0,0 +1,111 @@
+# round.m4 serial 10
+dnl Copyright (C) 2007, 2009-2011 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_ROUND],
+[
+  m4_divert_text([DEFAULTS], [gl_round_required=plain])
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  dnl Persuade glibc <math.h> to declare round().
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_DECLS([round], , , [#include <math.h>])
+  if test "$ac_cv_have_decl_round" = yes; then
+    gl_CHECK_MATH_LIB([ROUND_LIBM], [x = round (x);])
+    if test "$ROUND_LIBM" != missing; then
+      dnl Test whether round() produces correct results. On NetBSD 3.0, for
+      dnl x = 1/2 - 2^-54, the system's round() returns a wrong result.
+      AC_REQUIRE([AC_PROG_CC])
+      AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+      AC_CACHE_CHECK([whether round works], [gl_cv_func_round_works],
+        [
+          save_LIBS="$LIBS"
+          LIBS="$LIBS $ROUND_LIBM"
+          AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <float.h>
+#include <math.h>
+int main()
+{
+  /* 2^DBL_MANT_DIG.  */
+  static const double TWO_MANT_DIG =
+    /* Assume DBL_MANT_DIG <= 5 * 31.
+       Use the identity
+       n = floor(n/5) + floor((n+1)/5) + ... + floor((n+4)/5).  */
+    (double) (1U << (DBL_MANT_DIG / 5))
+    * (double) (1U << ((DBL_MANT_DIG + 1) / 5))
+    * (double) (1U << ((DBL_MANT_DIG + 2) / 5))
+    * (double) (1U << ((DBL_MANT_DIG + 3) / 5))
+    * (double) (1U << ((DBL_MANT_DIG + 4) / 5));
+  volatile double x = 0.5 - 0.5 / TWO_MANT_DIG;
+  exit (x < 0.5 && round (x) != 0.0);
+}]])], [gl_cv_func_round_works=yes], [gl_cv_func_round_works=no],
+          [case "$host_os" in
+             netbsd* | aix*) gl_cv_func_round_works="guessing no";;
+             *)              gl_cv_func_round_works="guessing yes";;
+           esac
+          ])
+          LIBS="$save_LIBS"
+        ])
+      case "$gl_cv_func_round_works" in
+        *no) ROUND_LIBM=missing ;;
+      esac
+    fi
+    if test "$ROUND_LIBM" = missing; then
+      REPLACE_ROUND=1
+    fi
+    m4_ifdef([gl_FUNC_ROUND_IEEE], [
+      if test $gl_round_required = ieee && test $REPLACE_ROUND = 0; then
+        AC_CACHE_CHECK([whether round works according to ISO C 99 with IEC 
60559],
+          [gl_cv_func_round_ieee],
+          [
+            save_LIBS="$LIBS"
+            LIBS="$LIBS $ROUND_LIBM"
+            AC_RUN_IFELSE(
+              [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+]gl_DOUBLE_MINUS_ZERO_CODE[
+]gl_DOUBLE_SIGNBIT_CODE[
+int main()
+{
+  /* Test whether round (-0.0) is -0.0.  */
+  if (signbitd (minus_zerod) && !signbitd (round (minus_zerod)))
+    return 1;
+  return 0;
+}
+              ]])],
+              [gl_cv_func_round_ieee=yes],
+              [gl_cv_func_round_ieee=no],
+              [gl_cv_func_round_ieee="guessing no"])
+            LIBS="$save_LIBS"
+          ])
+        case "$gl_cv_func_round_ieee" in
+          *yes) ;;
+          *) REPLACE_ROUND=1 ;;
+        esac
+      fi
+    ])
+  else
+    HAVE_DECL_ROUND=0
+  fi
+  if test $HAVE_DECL_ROUND = 0 || test $REPLACE_ROUND = 1; then
+    AC_LIBOBJ([round])
+    gl_FUNC_FLOOR_LIBS
+    gl_FUNC_CEIL_LIBS
+    ROUND_LIBM=
+    dnl Append $FLOOR_LIBM to ROUND_LIBM, avoiding gratuitous duplicates.
+    case " $ROUND_LIBM " in
+      *" $FLOOR_LIBM "*) ;;
+      *) ROUND_LIBM="$ROUND_LIBM $FLOOR_LIBM" ;;
+    esac
+    dnl Append $CEIL_LIBM to ROUND_LIBM, avoiding gratuitous duplicates.
+    case " $ROUND_LIBM " in
+      *" $CEIL_LIBM "*) ;;
+      *) ROUND_LIBM="$ROUND_LIBM $CEIL_LIBM" ;;
+    esac
+  fi
+  AC_SUBST([ROUND_LIBM])
+])


hooks/post-receive
-- 
GNU Guile



reply via email to

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