changeset 15832:022f031c4bdf

New module 'fmodf'. * lib/math.in.h (fmodf): New declaration. * lib/fmodf.c: New file. * m4/fmodf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether fmodf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_FMODF, HAVE_FMODF. * modules/math (Makefile.am): Substitute GNULIB_FMODF, HAVE_FMODF. * modules/fmodf: New file. * tests/test-math-c++.cc: Check the declaration of fmodf. * doc/posix-functions/fmodf.texi: Mention the new module.
author Bruno Haible <bruno@clisp.org>
date Thu, 06 Oct 2011 01:01:52 +0200
parents a9066d0c1310
children c4907ddd848d
files ChangeLog doc/posix-functions/fmodf.texi lib/fmodf.c lib/math.in.h m4/fmodf.m4 m4/math_h.m4 modules/fmodf modules/math tests/test-math-c++.cc
diffstat 9 files changed, 122 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-05  Bruno Haible  <bruno@clisp.org>
 
+	New module 'fmodf'.
+	* lib/math.in.h (fmodf): New declaration.
+	* lib/fmodf.c: New file.
+	* m4/fmodf.m4: New file.
+	* m4/math_h.m4 (gl_MATH_H): Test whether fmodf is declared.
+	(gl_MATH_H_DEFAULTS): Initialize GNULIB_FMODF, HAVE_FMODF.
+	* modules/math (Makefile.am): Substitute GNULIB_FMODF, HAVE_FMODF.
+	* modules/fmodf: New file.
+	* tests/test-math-c++.cc: Check the declaration of fmodf.
+	* doc/posix-functions/fmodf.texi: Mention the new module.
+
 	fmod: Use a .m4 file.
 	* m4/fmod.m4: New file.
 	* modules/fmod (Files): Add it.
--- a/doc/posix-functions/fmodf.texi
+++ b/doc/posix-functions/fmodf.texi
@@ -8,10 +8,6 @@
 
 Portability problems fixed by Gnulib:
 @itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
 @item
 This function is missing on some platforms:
 Minix 3.1.8, AIX 5.1, Solaris 9.
@@ -19,3 +15,7 @@
 This function is only defined as a macro with arguments on some platforms:
 MSVC 9.
 @end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
new file mode 100644
--- /dev/null
+++ b/lib/fmodf.c
@@ -0,0 +1,26 @@
+/* Remainder.
+   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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+float
+fmodf (float x, float y)
+{
+  return (float) fmod ((double) x, (double) y);
+}
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -358,6 +358,22 @@
 #endif
 
 
+#if @GNULIB_FMODF@
+# if !@HAVE_FMODF@
+#  undef fmodf
+_GL_FUNCDECL_SYS (fmodf, float, (float x, float y));
+# endif
+_GL_CXXALIAS_SYS (fmodf, float, (float x, float y));
+_GL_CXXALIASWARN (fmodf);
+#elif defined GNULIB_POSIXCHECK
+# undef fmodf
+# if HAVE_RAW_DECL_FMODF
+_GL_WARN_ON_USE (fmodf, "fmodf is unportable - "
+                 "use gnulib module fmodf for portability");
+# endif
+#endif
+
+
 /* Write x as
      x = mantissa * 2^exp
    where
new file mode 100644
--- /dev/null
+++ b/m4/fmodf.m4
@@ -0,0 +1,25 @@
+# fmodf.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_FMODF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_FMOD])
+
+  dnl Test whether fmodf() exists. Assume that fmodf(), if it exists, is
+  dnl defined in the same library as fmod().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $FMOD_LIBM"
+  AC_CHECK_FUNCS([fmodf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_fmodf = yes; then
+    FMODF_LIBM="$FMOD_LIBM"
+  else
+    HAVE_FMODF=0
+    FMODF_LIBM="$FMOD_LIBM"
+  fi
+  AC_SUBST([FMODF_LIBM])
+])
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 26
+# math_h.m4 serial 27
 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,
@@ -39,7 +39,7 @@
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
-    [acosl asinl atanl ceilf ceill cosl expl fabsf floorf floorl frexpl
+    [acosl asinl atanl ceilf ceill cosl expl fabsf floorf floorl fmodf frexpl
      ldexpl logb logl round roundf roundl sinl sqrtl tanl trunc truncf truncl])
 ])
 
@@ -66,6 +66,7 @@
   GNULIB_FLOOR=0;    AC_SUBST([GNULIB_FLOOR])
   GNULIB_FLOORF=0;   AC_SUBST([GNULIB_FLOORF])
   GNULIB_FLOORL=0;   AC_SUBST([GNULIB_FLOORL])
+  GNULIB_FMODF=0;    AC_SUBST([GNULIB_FMODF])
   GNULIB_FREXP=0;    AC_SUBST([GNULIB_FREXP])
   GNULIB_FREXPL=0;   AC_SUBST([GNULIB_FREXPL])
   GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
@@ -94,6 +95,7 @@
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
   HAVE_EXPL=1;                 AC_SUBST([HAVE_EXPL])
   HAVE_FABSF=1;                AC_SUBST([HAVE_FABSF])
+  HAVE_FMODF=1;                AC_SUBST([HAVE_FMODF])
   HAVE_ISNANF=1;               AC_SUBST([HAVE_ISNANF])
   HAVE_ISNAND=1;               AC_SUBST([HAVE_ISNAND])
   HAVE_ISNANL=1;               AC_SUBST([HAVE_ISNANL])
new file mode 100644
--- /dev/null
+++ b/modules/fmodf
@@ -0,0 +1,31 @@
+Description:
+fmodf() function: remainder.
+
+Files:
+lib/fmodf.c
+m4/fmodf.m4
+
+Depends-on:
+math
+fmod            [test $HAVE_FMODF = 0]
+
+configure.ac:
+gl_FUNC_FMODF
+if test $HAVE_FMODF = 0; then
+  AC_LIBOBJ([fmodf])
+fi
+gl_MATH_MODULE_INDICATOR([fmodf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(FMODF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/math
+++ b/modules/math
@@ -40,6 +40,7 @@
 	      -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \
 	      -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \
 	      -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \
+	      -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \
 	      -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \
 	      -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \
 	      -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \
@@ -68,6 +69,7 @@
 	      -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
 	      -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
 	      -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
+	      -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
 	      -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
 	      -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
 	      -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -39,6 +39,9 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::fabsf, float, (float));
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::fabs, double, (double));
+#if GNULIB_TEST_FMODF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::fmodf, float, (float, float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::fmod, double, (double, double));
 #if GNULIB_TEST_FREXP
 SIGNATURE_CHECK (GNULIB_NAMESPACE::frexp, double, (double, int *));