New module 'rintl'.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 18:35:03 +0000 (20:35 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Oct 2011 18:37:33 +0000 (20:37 +0200)
* lib/math.in.h (rintl): New declaration.
* lib/rintl.c: New file.
* m4/rintl.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether rintl is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_RINTL, HAVE_RINTL.
* modules/math (Makefile.am): Substitute GNULIB_RINTL, HAVE_RINTL.
* modules/rintl: New file.
* tests/test-math-c++.cc: Check the declaration of rintl.
* modules/math-c++-tests (Makefile.am): Link test-math-c++ against
$(RINTL_LIBM). Needed on IRIX 6.5 with cc.
* doc/posix-functions/rintl.texi: Mention the new module.

ChangeLog
doc/posix-functions/rintl.texi
lib/math.in.h
lib/rintl.c [new file with mode: 0644]
m4/math_h.m4
m4/rintl.m4 [new file with mode: 0644]
modules/math
modules/math-c++-tests
modules/rintl [new file with mode: 0644]
tests/test-math-c++.cc

index 062a7bd..7894c5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2011-10-09  Bruno Haible  <bruno@clisp.org>
 
+       New module 'rintl'.
+       * lib/math.in.h (rintl): New declaration.
+       * lib/rintl.c: New file.
+       * m4/rintl.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether rintl is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_RINTL, HAVE_RINTL.
+       * modules/math (Makefile.am): Substitute GNULIB_RINTL, HAVE_RINTL.
+       * modules/rintl: New file.
+       * tests/test-math-c++.cc: Check the declaration of rintl.
+       * modules/math-c++-tests (Makefile.am): Link test-math-c++ against
+       $(RINTL_LIBM). Needed on IRIX 6.5 with cc.
+       * doc/posix-functions/rintl.texi: Mention the new module.
+
+2011-10-09  Bruno Haible  <bruno@clisp.org>
+
        Tests for module 'rintf'.
        * modules/rintf-tests: New file.
        * tests/test-rintf.c: New file.
index cdc0c09..17736d7 100644 (file)
@@ -4,16 +4,16 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/rintl.html}
 
-Gnulib module: ---
+Gnulib module: rintl
 
 Portability problems fixed by Gnulib:
 @itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
 @item
 This function is missing on some platforms:
 FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5,
 Solaris 9, Cygwin 1.5.x, MSVC 9, Interix 3.5, BeOS.
 @end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
index 7113d44..d3b4839 100644 (file)
@@ -740,6 +740,20 @@ _GL_WARN_ON_USE (rint, "rint is unportable - "
 # endif
 #endif
 
+#if @GNULIB_RINTL@
+# if !@HAVE_RINTL@
+_GL_FUNCDECL_SYS (rintl, long double, (long double x));
+# endif
+_GL_CXXALIAS_SYS (rintl, long double, (long double x));
+_GL_CXXALIASWARN (rintl);
+#elif defined GNULIB_POSIXCHECK
+# undef rintl
+# if HAVE_RAW_DECL_RINTL
+_GL_WARN_ON_USE (rintl, "rintl is unportable - "
+                 "use gnulib module rintl for portability");
+# endif
+#endif
+
 
 #if @GNULIB_ROUNDF@
 # if @REPLACE_ROUNDF@
diff --git a/lib/rintl.c b/lib/rintl.c
new file mode 100644 (file)
index 0000000..6c0e999
--- /dev/null
@@ -0,0 +1,19 @@
+/* Round according to the current rounding mode.
+   Copyright (C) 2011 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.  */
+
+#define USE_LONG_DOUBLE
+#include "rint.c"
index f496e01..e5a2892 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 52
+# math_h.m4 serial 53
 dnl Copyright (C) 2007-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,
@@ -43,7 +43,7 @@ AC_DEFUN([gl_MATH_H],
      ceilf ceill copysign copysignf copysignl cosf cosl coshf
      expf expl fabsf floorf floorl fmodf frexpf frexpl
      ldexpf ldexpl logb logf logl log10f modff powf
-     rint rintf round roundf roundl sinf sinl sinhf sqrtf sqrtl
+     rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
      tanf tanl tanhf trunc truncf truncl])
 ])
 
@@ -100,6 +100,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_POWF=0;      AC_SUBST([GNULIB_POWF])
   GNULIB_RINT=0;      AC_SUBST([GNULIB_RINT])
   GNULIB_RINTF=0;     AC_SUBST([GNULIB_RINTF])
+  GNULIB_RINTL=0;     AC_SUBST([GNULIB_RINTL])
   GNULIB_ROUND=0;     AC_SUBST([GNULIB_ROUND])
   GNULIB_ROUNDF=0;    AC_SUBST([GNULIB_ROUNDF])
   GNULIB_ROUNDL=0;    AC_SUBST([GNULIB_ROUNDL])
@@ -145,6 +146,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_POWF=1;                 AC_SUBST([HAVE_POWF])
   HAVE_RINT=1;                 AC_SUBST([HAVE_RINT])
   HAVE_RINTF=1;                AC_SUBST([HAVE_RINTF])
+  HAVE_RINTL=1;                AC_SUBST([HAVE_RINTL])
   HAVE_SINF=1;                 AC_SUBST([HAVE_SINF])
   HAVE_SINL=1;                 AC_SUBST([HAVE_SINL])
   HAVE_SINHF=1;                AC_SUBST([HAVE_SINHF])
diff --git a/m4/rintl.m4 b/m4/rintl.m4
new file mode 100644 (file)
index 0000000..d04e5a0
--- /dev/null
@@ -0,0 +1,17 @@
+# rintl.m4 serial 1
+dnl Copyright (C) 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_RINTL],
+[
+  dnl Determine RINTL_LIBM.
+  gl_MATHFUNC([rintl], [long double], [(long double)])
+  if test $gl_cv_func_rintl_no_libm = no \
+     && test $gl_cv_func_rintl_in_libm = no; then
+    HAVE_RINTL=0
+    RINTL_LIBM=
+  fi
+  AC_SUBST([RINTL_LIBM])
+])
index 933507b..d3b14de 100644 (file)
@@ -70,6 +70,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
              -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \
              -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \
+             -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \
              -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \
              -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \
              -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \
@@ -115,6 +116,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
              -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
              -e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
+             -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
              -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \
              -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
              -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \
index 35f37b8..796e3d1 100644 (file)
@@ -17,5 +17,5 @@ TESTS += test-math-c++
 check_PROGRAMS += test-math-c++
 test_math_c___SOURCES = test-math-c++.cc test-math-c++2.cc
 # These link dependencies are needed on IRIX 6.5 with cc.
-test_math_c___LDADD = $(LDADD) $(COPYSIGNL_LIBM) $(RINT_LIBM)
+test_math_c___LDADD = $(LDADD) $(COPYSIGNL_LIBM) $(RINT_LIBM) $(RINTL_LIBM)
 endif
diff --git a/modules/rintl b/modules/rintl
new file mode 100644 (file)
index 0000000..80a0f52
--- /dev/null
@@ -0,0 +1,32 @@
+Description:
+rintl() function: round according to the current rounding mode.
+
+Files:
+lib/rintl.c
+lib/rint.c
+m4/rintl.m4
+m4/mathfunc.m4
+
+Depends-on:
+math
+
+configure.ac:
+gl_FUNC_RINTL
+if test $HAVE_RINTL = 0; then
+  AC_LIBOBJ([rintl])
+fi
+gl_MATH_MODULE_INDICATOR([rintl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(RINTL_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 0b9a48d..0a22fdd 100644 (file)
@@ -195,6 +195,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexpl, long double, (long double, int));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::logl, long double, (long double));
 #endif
 
+#if GNULIB_TEST_RINTL
+SIGNATURE_CHECK (GNULIB_NAMESPACE::rintl, long double, (long double));
+#endif
+
 #if GNULIB_TEST_ROUNDF
 SIGNATURE_CHECK (GNULIB_NAMESPACE::roundf, float, (float));
 #endif