* lib/math.in.h (remainderh): New declaration.
* lib/remainderl.c: New file.
* m4/remainderl.m4: New file.
* modules/remainderl: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether remainderl is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_REMAINDERL, HAVE_REMAINDERL.
* modules/math (Makefile.am): Substitute GNULIB_REMAINDERL,
HAVE_REMAINDERL.
* doc/posix-functions/remainderl.texi: Mention the new module.
+2012-02-25 Bruno Haible <bruno@clisp.org>
+
+ New module 'remainderl'.
+ * lib/math.in.h (remainderh): New declaration.
+ * lib/remainderl.c: New file.
+ * m4/remainderl.m4: New file.
+ * modules/remainderl: New file.
+ * m4/math_h.m4 (gl_MATH_H): Test whether remainderl is declared.
+ (gl_MATH_H_DEFAULTS): Initialize GNULIB_REMAINDERL, HAVE_REMAINDERL.
+ * modules/math (Makefile.am): Substitute GNULIB_REMAINDERL,
+ HAVE_REMAINDERL.
+ * doc/posix-functions/remainderl.texi: Mention the new module.
+
2012-02-25 Bruno Haible <bruno@clisp.org>
Tests for module 'remainderf'.
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/remainderl.html}
-Gnulib module: ---
+Gnulib module: remainderl
Portability problems 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, OSF/1 4.0, Solaris 9, Cygwin, MSVC 9, Interix 3.5, BeOS.
@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, OSF/1 4.0, Solaris 9, Cygwin, MSVC 9, Interix 3.5, BeOS.
@end itemize
# endif
#endif
+#if @GNULIB_REMAINDERL@
+# if !@HAVE_REMAINDERL@
+_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y));
+# endif
+_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
+_GL_CXXALIASWARN (remainderl);
+#elif defined GNULIB_POSIXCHECK
+# undef remainderl
+# if HAVE_RAW_DECL_REMAINDERL
+_GL_WARN_ON_USE (remainderl, "remainderl is unportable - "
+ "use gnulib module remainderl for portability");
+# endif
+#endif
+
#if @GNULIB_RINTF@
# if !@HAVE_RINTF@
--- /dev/null
+/* Remainder.
+ Copyright (C) 2012 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>
+
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+long double
+remainderl (long double x, long double y)
+{
+ return remainder (x, y);
+}
+
+#else
+
+long double
+remainderl (long double x, long double y)
+{
+ long double i = roundl (x / y);
+ return fmal (- i, y, x);
+}
+
+#endif
-# math_h.m4 serial 61
+# math_h.m4 serial 62
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
ceilf ceill copysign copysignf copysignl cosf cosl coshf
expf expl fabsf fabsl floorf floorl fma fmaf fmal fmodf fmodl frexpf frexpl
ldexpf ldexpl logb logf logl log10f modff modfl powf
- remainder remainderf
+ remainder remainderf remainderl
rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
tanf tanl tanhf trunc truncf truncl])
])
GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER])
GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF])
+ GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL])
GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
HAVE_POWF=1; AC_SUBST([HAVE_POWF])
HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
+ HAVE_REMAINDERL=1; AC_SUBST([HAVE_REMAINDERL])
HAVE_RINT=1; AC_SUBST([HAVE_RINT])
HAVE_RINTF=1; AC_SUBST([HAVE_RINTF])
HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
--- /dev/null
+# remainderl.m4 serial 1
+dnl Copyright (C) 2012 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_REMAINDERL],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+ AC_REQUIRE([gl_FUNC_REMAINDER])
+
+ dnl Test whether remainderl() exists. Assume that remainderl(), if it exists, is
+ dnl defined in the same library as remainder().
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $REMAINDER_LIBM"
+ AC_CACHE_CHECK([for remainderl],
+ [gl_cv_func_remainderl],
+ [
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#ifndef __NO_MATH_INLINES
+ # define __NO_MATH_INLINES 1 /* for glibc */
+ #endif
+ #include <math.h>
+ long double (*funcptr) (long double, long double) = remainderl;
+ long double x;
+ long double y;]],
+ [[return funcptr (x, y) > 1
+ || remainderl (x, y) > 1;]])],
+ [gl_cv_func_remainderl=yes],
+ [gl_cv_func_remainderl=no])
+ ])
+ LIBS="$save_LIBS"
+ if test $gl_cv_func_remainderl = yes; then
+ REMAINDERL_LIBM="$REMAINDER_LIBM"
+ else
+ HAVE_REMAINDERL=0
+ dnl Find libraries needed to link lib/remainderl.c.
+ if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+ REMAINDERL_LIBM="$REMAINDER_LIBM"
+ else
+ AC_REQUIRE([gl_FUNC_ROUNDL])
+ AC_REQUIRE([gl_FUNC_FMAL])
+ REMAINDERL_LIBM=
+ dnl Append $ROUNDL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
+ case " $REMAINDERL_LIBM " in
+ *" $ROUNDL_LIBM "*) ;;
+ *) REMAINDERL_LIBM="$REMAINDERL_LIBM $ROUNDL_LIBM" ;;
+ esac
+ dnl Append $FMAL_LIBM to REMAINDERL_LIBM, avoiding gratuitous duplicates.
+ case " $REMAINDERL_LIBM " in
+ *" $FMAL_LIBM "*) ;;
+ *) REMAINDERL_LIBM="$REMAINDERL_LIBM $FMAL_LIBM" ;;
+ esac
+ fi
+ fi
+ AC_SUBST([REMAINDERL_LIBM])
+])
-e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
-e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \
-e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \
+ -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \
-e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \
-e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \
-e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \
-e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
-e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \
-e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \
+ -e 's|@''HAVE_REMAINDERL''@|$(HAVE_REMAINDERL)|g' \
-e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
-e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \
-e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
--- /dev/null
+Description:
+remainderl() function: floating-point remainder function.
+
+Files:
+lib/remainderl.c
+m4/remainderl.m4
+m4/mathfunc.m4
+
+Depends-on:
+math
+remainder [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+roundl [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+fmal [test $HAVE_REMAINDERL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+
+configure.ac:
+gl_FUNC_REMAINDERL
+if test $HAVE_REMAINDERL = 0; then
+ AC_LIBOBJ([remainderl])
+fi
+gl_MATH_MODULE_INDICATOR([remainderl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(REMAINDERL_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible