bug-gnulib
[Top][All Lists]
Advanced

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

new module 'modfl'


From: Bruno Haible
Subject: new module 'modfl'
Date: Sat, 25 Feb 2012 15:32:12 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Another 'long double' function: modfl().


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

        New module 'modfl'.
        * lib/math.in.h (modfl): New declaration.
        * lib/modfl.c: New file.
        * m4/modfl.m4: New file.
        * m4/math_h.m4 (gl_MATH_H): Test whether modfl is declared.
        (gl_MATH_H_DEFAULTS): Initialize GNULIB_MODFL, HAVE_MODFL.
        * modules/math (Makefile.am): Substitute GNULIB_MODFL, HAVE_MODFL.
        * modules/modfl: New file.
        * doc/posix-functions/modfl.texi: Mention the new module.

================================= lib/modfl.c =================================
/* Get signed integer and fractional parts of a floating-point number.
   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
modfl (long double x, long double *iptr)
{
  double integer_part;
  double fractional_part = modf (x, &integer_part);
  *iptr = integer_part;
  return fractional_part;
}

#else

long double
modfl (long double x, long double *iptr)
{
  long double integer_part = truncl (x);
  *iptr = integer_part;
  return x - integer_part;
}

#endif
================================= m4/modfl.m4 =================================
# modfl.m4 serial 1
dnl Copyright (C) 2011-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_MODFL],
[
  AC_REQUIRE([gl_MATH_H_DEFAULTS])
  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

  dnl Test whether modfl() exists. We cannot assume that modfl(), if it
  dnl exists, is defined in the same library as modf(). This is not the case
  dnl on FreeBSD, Solaris.
  gl_MATHFUNC([modfl], [long double], [(long double, long double *)])
  if test $gl_cv_func_modfl_no_libm = no \
     && test $gl_cv_func_modfl_in_libm = no; then
    HAVE_MODFL=0
    if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
      AC_REQUIRE([gl_FUNC_MODF])
      MODFL_LIBM="$MODF_LIBM"
    else
      AC_REQUIRE([gl_FUNC_TRUNCL])
      MODFL_LIBM="$TRUNCL_LIBM"
    fi
  fi
  AC_SUBST([MODFL_LIBM])
])
================================ modules/modfl ================================
Description:
modfl() function: get signed integer and fractional parts.

Files:
lib/modfl.c
m4/modfl.m4
m4/mathfunc.m4

Depends-on:
math
modf            [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE 
= 1]
truncl          [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE 
= 0]

configure.ac:
gl_FUNC_MODFL
if test $HAVE_MODFL = 0; then
  AC_LIBOBJ([modfl])
fi
gl_MATH_MODULE_INDICATOR([modfl])

Makefile.am:

Include:
<math.h>

Link:
$(MODFL_LIBM)

License:
LGPL

Maintainer:
Bruno Haible
===============================================================================
--- doc/posix-functions/modfl.texi.orig Sat Feb 25 15:17:49 2012
+++ doc/posix-functions/modfl.texi      Sat Feb 25 13:37:25 2012
@@ -4,14 +4,10 @@
 
 POSIX specification:@* 
@url{http://www.opengroup.org/onlinepubs/9699919799/functions/modfl.html}
 
-Gnulib module: ---
+Gnulib module: modfl
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden itemize
-
-Portability problems not fixed by Gnulib:
address@hidden
 @item
 This function is missing on some platforms:
 FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 
9, Cygwin, Interix 3.5.
@@ -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:
address@hidden
address@hidden itemize
--- lib/math.in.h.orig  Sat Feb 25 15:17:49 2012
+++ lib/math.in.h       Sat Feb 25 13:39:37 2012
@@ -841,6 +841,22 @@
 # endif
 #endif
 
+#if @GNULIB_MODFL@
+# if address@hidden@
+#  undef modfl
+_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr)
+                                      _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
+_GL_CXXALIASWARN (modfl);
+#elif defined GNULIB_POSIXCHECK
+# undef modfl
+# if HAVE_RAW_DECL_MODFL
+_GL_WARN_ON_USE (modfl, "modfl is unportable - "
+                 "use gnulib module modfl for portability");
+# endif
+#endif
+
 
 #if @GNULIB_POWF@
 # if address@hidden@
--- m4/math_h.m4.orig   Sat Feb 25 15:17:50 2012
+++ m4/math_h.m4        Sat Feb 25 13:40:30 2012
@@ -1,4 +1,4 @@
-# math_h.m4 serial 57
+# math_h.m4 serial 58
 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,
@@ -42,7 +42,7 @@
     [acosf acosl asinf asinl atanf atanl
      ceilf ceill copysign copysignf copysignl cosf cosl coshf
      expf expl fabsf fabsl floorf floorl fma fmaf fmal fmodf frexpf frexpl
-     ldexpf ldexpl logb logf logl log10f modff powf
+     ldexpf ldexpl logb logf logl log10f modff modfl powf
      rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
      tanf tanl tanhf trunc truncf truncl])
 ])
@@ -101,6 +101,7 @@
   GNULIB_LOGL=0;      AC_SUBST([GNULIB_LOGL])
   GNULIB_LOG10F=0;    AC_SUBST([GNULIB_LOG10F])
   GNULIB_MODFF=0;     AC_SUBST([GNULIB_MODFF])
+  GNULIB_MODFL=0;     AC_SUBST([GNULIB_MODFL])
   GNULIB_POWF=0;      AC_SUBST([GNULIB_POWF])
   GNULIB_RINT=0;      AC_SUBST([GNULIB_RINT])
   GNULIB_RINTF=0;     AC_SUBST([GNULIB_RINTF])
@@ -151,6 +152,7 @@
   HAVE_LOGL=1;                 AC_SUBST([HAVE_LOGL])
   HAVE_LOG10F=1;               AC_SUBST([HAVE_LOG10F])
   HAVE_MODFF=1;                AC_SUBST([HAVE_MODFF])
+  HAVE_MODFL=1;                AC_SUBST([HAVE_MODFL])
   HAVE_POWF=1;                 AC_SUBST([HAVE_POWF])
   HAVE_RINT=1;                 AC_SUBST([HAVE_RINT])
   HAVE_RINTF=1;                AC_SUBST([HAVE_RINTF])
--- modules/math.orig   Sat Feb 25 15:17:50 2012
+++ modules/math        Sat Feb 25 13:41:08 2012
@@ -71,6 +71,7 @@
              -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \
              -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \
              -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
+             -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \
              -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
              -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \
              -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \
@@ -121,6 +122,7 @@
              -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
              -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \
              -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
+             -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \
              -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
              -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
              -e 's|@''HAVE_RINTF''@|$(HAVE_RINTF)|g' \




reply via email to

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