New module 'fmodf'.
authorBruno Haible <bruno@clisp.org>
Wed, 5 Oct 2011 23:01:52 +0000 (01:01 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 5 Oct 2011 23:01:52 +0000 (01:01 +0200)
* 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.

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

index 7500a88..a3c8e72 100644 (file)
--- 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.
index 3863029..eb2614e 100644 (file)
@@ -8,10 +8,6 @@ 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:
 Minix 3.1.8, AIX 5.1, Solaris 9.
@@ -19,3 +15,7 @@ Minix 3.1.8, AIX 5.1, Solaris 9.
 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
diff --git a/lib/fmodf.c b/lib/fmodf.c
new file mode 100644 (file)
index 0000000..35a8a23
--- /dev/null
@@ -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);
+}
index 73ad15d..110a1e6 100644 (file)
@@ -358,6 +358,22 @@ _GL_WARN_ON_USE (floorl, "floorl is unportable - "
 #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
diff --git a/m4/fmodf.m4 b/m4/fmodf.m4
new file mode 100644 (file)
index 0000000..2666d78
--- /dev/null
@@ -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])
+])
index 4aee605..4d4b443 100644 (file)
@@ -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 @@ AC_DEFUN([gl_MATH_H],
   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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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])
diff --git a/modules/fmodf b/modules/fmodf
new file mode 100644 (file)
index 0000000..6d9276d
--- /dev/null
@@ -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
index 73833ef..6875218 100644 (file)
@@ -40,6 +40,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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' \
index 183b37c..b6141e1 100644 (file)
@@ -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 *));