summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-09 19:05:54 +0200
committerBruno Haible <bruno@clisp.org>2011-10-09 20:37:33 +0200
commit20f0673b1b22f84e39b3bacae027cdc21be2ed39 (patch)
tree4ef41ef005b1a93f0a1d5edc980bd6dcf5a65537
parent624e3c286e69a92e1610b28020c966c84f61b531 (diff)
downloadgnulib-20f0673b1b22f84e39b3bacae027cdc21be2ed39.tar.gz
New module 'rintf'.
* lib/math.in.h (rintf): New declaration. * lib/rintf.c: New file. * m4/rintf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether rintf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_RINTF, HAVE_RINTF. * modules/math (Makefile.am): Substitute GNULIB_RINTF, HAVE_RINTF. * modules/rintf: New file. * tests/test-math-c++.cc: Check the declaration of rintf. * doc/posix-functions/rintf.texi: Mention the new module.
-rw-r--r--ChangeLog13
-rw-r--r--doc/posix-functions/rintf.texi8
-rw-r--r--lib/math.in.h14
-rw-r--r--lib/rintf.c19
-rw-r--r--m4/math_h.m46
-rw-r--r--m4/rintf.m417
-rw-r--r--modules/math2
-rw-r--r--modules/rintf32
-rw-r--r--tests/test-math-c++.cc3
9 files changed, 108 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 449994988f..ed9e157a74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2011-10-09 Bruno Haible <bruno@clisp.org>
+ New module 'rintf'.
+ * lib/math.in.h (rintf): New declaration.
+ * lib/rintf.c: New file.
+ * m4/rintf.m4: New file.
+ * m4/math_h.m4 (gl_MATH_H): Test whether rintf is declared.
+ (gl_MATH_H_DEFAULTS): Initialize GNULIB_RINTF, HAVE_RINTF.
+ * modules/math (Makefile.am): Substitute GNULIB_RINTF, HAVE_RINTF.
+ * modules/rintf: New file.
+ * tests/test-math-c++.cc: Check the declaration of rintf.
+ * doc/posix-functions/rintf.texi: Mention the new module.
+
+2011-10-09 Bruno Haible <bruno@clisp.org>
+
rint: Support for MSVC.
* lib/math.in.h (rint): New declaration.
* lib/rint.c: New file.
diff --git a/doc/posix-functions/rintf.texi b/doc/posix-functions/rintf.texi
index ad507fac11..a67497af28 100644
--- a/doc/posix-functions/rintf.texi
+++ b/doc/posix-functions/rintf.texi
@@ -4,15 +4,15 @@
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/rintf.html}
-Gnulib module: ---
+Gnulib module: rintf
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on some platforms:
+Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on some platforms:
-Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, MSVC 9.
@end itemize
diff --git a/lib/math.in.h b/lib/math.in.h
index 7269345b7f..7113d44b14 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -712,6 +712,20 @@ _GL_WARN_ON_USE (powf, "powf is unportable - "
#endif
+#if @GNULIB_RINTF@
+# if !@HAVE_RINTF@
+_GL_FUNCDECL_SYS (rintf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (rintf, float, (float x));
+_GL_CXXALIASWARN (rintf);
+#elif defined GNULIB_POSIXCHECK
+# undef rintf
+# if HAVE_RAW_DECL_RINTF
+_GL_WARN_ON_USE (rintf, "rintf is unportable - "
+ "use gnulib module rintf for portability");
+# endif
+#endif
+
#if @GNULIB_RINT@
# if !@HAVE_RINT@
_GL_FUNCDECL_SYS (rint, double, (double x));
diff --git a/lib/rintf.c b/lib/rintf.c
new file mode 100644
index 0000000000..948b679536
--- /dev/null
+++ b/lib/rintf.c
@@ -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_FLOAT
+#include "rint.c"
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index c3a27e0a7b..f496e019fb 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 51
+# math_h.m4 serial 52
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 round roundf roundl sinf sinl sinhf sqrtf sqrtl
+ rint rintf round roundf roundl sinf sinl sinhf sqrtf sqrtl
tanf tanl tanhf trunc truncf truncl])
])
@@ -99,6 +99,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
+ GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
@@ -143,6 +144,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
HAVE_POWF=1; AC_SUBST([HAVE_POWF])
HAVE_RINT=1; AC_SUBST([HAVE_RINT])
+ HAVE_RINTF=1; AC_SUBST([HAVE_RINTF])
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/rintf.m4 b/m4/rintf.m4
new file mode 100644
index 0000000000..2b5b81b128
--- /dev/null
+++ b/m4/rintf.m4
@@ -0,0 +1,17 @@
+# rintf.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_RINTF],
+[
+ dnl Determine RINTF_LIBM.
+ gl_MATHFUNC([rintf], [float], [(float)])
+ if test $gl_cv_func_rintf_no_libm = no \
+ && test $gl_cv_func_rintf_in_libm = no; then
+ HAVE_RINTF=0
+ RINTF_LIBM=
+ fi
+ AC_SUBST([RINTF_LIBM])
+])
diff --git a/modules/math b/modules/math
index 57d5798860..933507b694 100644
--- a/modules/math
+++ b/modules/math
@@ -69,6 +69,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
-e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
-e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \
+ -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \
-e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \
-e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \
-e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \
@@ -113,6 +114,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
-e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
-e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
+ -e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
-e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \
-e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
-e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \
diff --git a/modules/rintf b/modules/rintf
new file mode 100644
index 0000000000..92b93a399a
--- /dev/null
+++ b/modules/rintf
@@ -0,0 +1,32 @@
+Description:
+rintf() function: round according to the current rounding mode.
+
+Files:
+lib/rintf.c
+lib/rint.c
+m4/rintf.m4
+m4/mathfunc.m4
+
+Depends-on:
+math
+
+configure.ac:
+gl_FUNC_RINTF
+if test $HAVE_RINTF = 0; then
+ AC_LIBOBJ([rintf])
+fi
+gl_MATH_MODULE_INDICATOR([rintf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(RINTF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc
index 95be24f605..0b9a48db1d 100644
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -104,6 +104,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::powf, float, (float, float));
#endif
//SIGNATURE_CHECK (GNULIB_NAMESPACE::pow, double, (double, double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::remainder, double, (double, double));
+#if GNULIB_TEST_RINTF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::rintf, float, (float));
+#endif
#if GNULIB_TEST_RINT
SIGNATURE_CHECK (GNULIB_NAMESPACE::rint, double, (double));
#endif