Share two-way algorithm.
[gnulib.git] / lib / math.in.h
index ef0682a..140b96e 100644 (file)
@@ -2,10 +2,10 @@
 
    Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or modify
+   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 2, or (at your option)
-   any later version.
+   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
@@ -13,8 +13,7 @@
    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, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _GL_MATH_H
 
@@ -39,11 +38,11 @@ extern "C" {
      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
      If x is zero: mantissa = x, exp = 0.
      If x is infinite or NaN: mantissa = x, exp unspecified.
-   Store exp and return mantissa.  */
+   Store exp in *EXPPTR and return mantissa.  */
 #if @GNULIB_FREXP@
 # if @REPLACE_FREXP@
 #  define frexp rpl_frexp
-extern double frexp (double x, int *exp);
+extern double frexp (double x, int *expptr);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef frexp
@@ -91,7 +90,7 @@ extern long double atanl (long double x);
 
 
 #if @GNULIB_CEILF@
-# if !@HAVE_DECL_CEILF@
+# if @REPLACE_CEILF@
 #  define ceilf rpl_ceilf
 extern float ceilf (float x);
 # endif
@@ -103,14 +102,16 @@ extern float ceilf (float x);
      ceilf (x))
 #endif
 
-#if @GNULIB_MATHL@ || !@HAVE_DECL_CEILL@
+#if @GNULIB_CEILL@
+# if @REPLACE_CEILL@
+#  define ceill rpl_ceill
 extern long double ceill (long double x);
-#endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+# endif
+#elif defined GNULIB_POSIXCHECK
 # undef ceill
 # define ceill(x) \
     (GL_LINK_WARNING ("ceill is unportable - " \
-                      "use gnulib module mathl for portability"), \
+                      "use gnulib module ceill for portability"), \
      ceill (x))
 #endif
 
@@ -140,7 +141,7 @@ extern long double expl (long double x);
 
 
 #if @GNULIB_FLOORF@
-# if !@HAVE_DECL_FLOORF@
+# if @REPLACE_FLOORF@
 #  define floorf rpl_floorf
 extern float floorf (float x);
 # endif
@@ -153,7 +154,7 @@ extern float floorf (float x);
 #endif
 
 #if @GNULIB_FLOORL@
-# if !@HAVE_DECL_FLOORL@
+# if @REPLACE_FLOORL@
 #  define floorl rpl_floorl
 extern long double floorl (long double x);
 # endif
@@ -172,12 +173,12 @@ extern long double floorl (long double x);
      If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
      If x is zero: mantissa = x, exp = 0.
      If x is infinite or NaN: mantissa = x, exp unspecified.
-   Store exp and return mantissa.  */
+   Store exp in *EXPPTR and return mantissa.  */
 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
 # define frexpl rpl_frexpl
 #endif
 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
-extern long double frexpl (long double x, int *exp);
+extern long double frexpl (long double x, int *expptr);
 #endif
 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
 # undef frexpl
@@ -216,6 +217,49 @@ extern long double logl (long double x);
 #endif
 
 
+#if @GNULIB_ROUNDF@
+# if @REPLACE_ROUNDF@
+#  undef roundf
+#  define roundf rpl_roundf
+extern float roundf (float x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef roundf
+# define roundf(x) \
+    (GL_LINK_WARNING ("roundf is unportable - " \
+                      "use gnulib module roundf for portability"), \
+     roundf (x))
+#endif
+
+#if @GNULIB_ROUND@
+# if @REPLACE_ROUND@
+#  undef round
+#  define round rpl_round
+extern double round (double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef round
+# define round(x) \
+    (GL_LINK_WARNING ("round is unportable - " \
+                      "use gnulib module round for portability"), \
+     round (x))
+#endif
+
+#if @GNULIB_ROUNDL@
+# if @REPLACE_ROUNDL@
+#  undef roundl
+#  define roundl rpl_roundl
+extern long double roundl (long double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef roundl
+# define roundl(x) \
+    (GL_LINK_WARNING ("roundl is unportable - " \
+                      "use gnulib module roundl for portability"), \
+     roundl (x))
+#endif
+
+
 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
 extern long double sinl (long double x);
 #endif
@@ -292,6 +336,22 @@ extern long double truncl (long double x);
 #endif
 
 
+#if @GNULIB_ISFINITE@
+# if @REPLACE_ISFINITE@
+extern int gl_isfinitef (float x);
+extern int gl_isfinited (double x);
+extern int gl_isfinitel (long double x);
+#  undef isfinite
+#  define isfinite(x) \
+   (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \
+    sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
+    gl_isfinitef (x))
+# endif
+#elif defined GNULIB_POSIXCHECK
+  /* How to override a macro?  */
+#endif
+
+
 #if @GNULIB_SIGNBIT@
 # if @REPLACE_SIGNBIT@
 #  undef signbit