bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new module 'remainderl'


From: Bruno Haible
Subject: new module 'remainderl'
Date: Sat, 25 Feb 2012 20:41:02 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

The remainderl() function is also missing on a number of platforms. Here's
the workaround module.


2012-02-25  Bruno Haible  <address@hidden>

        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.

============================== lib/remainderl.c ==============================
/* 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
============================== m4/remainderl.m4 ==============================
# 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])
])
============================= modules/remainderl =============================
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
==============================================================================
--- doc/posix-functions/remainderl.texi.orig    Sat Feb 25 20:35:09 2012
+++ doc/posix-functions/remainderl.texi Sat Feb 25 19:43:32 2012
@@ -4,15 +4,15 @@
 
 POSIX specification:@* 
@url{http://www.opengroup.org/onlinepubs/9699919799/functions/remainderl.html}
 
-Gnulib module: ---
+Gnulib module: remainderl
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden
+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
address@hidden
-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
--- lib/math.in.h.orig  Sat Feb 25 20:35:09 2012
+++ lib/math.in.h       Sat Feb 25 19:44:37 2012
@@ -926,6 +926,20 @@
 # endif
 #endif
 
+#if @GNULIB_REMAINDERL@
+# if address@hidden@
+_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 address@hidden@
--- m4/math_h.m4.orig   Sat Feb 25 20:35:09 2012
+++ m4/math_h.m4        Sat Feb 25 19:47:05 2012
@@ -1,4 +1,4 @@
-# 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,
@@ -43,7 +43,7 @@
      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])
 ])
@@ -107,6 +107,7 @@
   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])
@@ -161,6 +162,7 @@
   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])
--- modules/math.orig   Sat Feb 25 20:35:09 2012
+++ modules/math        Sat Feb 25 20:07:07 2012
@@ -76,6 +76,7 @@
              -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' \
@@ -130,6 +131,7 @@
              -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' \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]