This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran, patch] provide isfinite as a macro


+#define isfinite(x) (((x) == (x)) && ((2 * (x) != (x)) || ((x) == 0)))

Isn't ((x) - (x) == 0) a better definition?

Right. New patch attached, now regtested on i686-cygwin and sparc-solaris2.7. OK for mainline and 4.0?


FX
2005-08-04  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	* libgfortran.h: When isfinite is not provided by the system,
	define it as a macro, so that it can accept any floating point
	type.
Index: libgfortran/libgfortran.h
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/libgfortran.h,v
retrieving revision 1.27
diff -p -u -r1.27 libgfortran.h
--- libgfortran/libgfortran.h   7 Jul 2005 22:07:53 -0000       1.27
+++ libgfortran/libgfortran.h   3 Aug 2005 14:15:49 -0000
@@ -179,17 +179,11 @@ typedef off_t gfc_offset;
    alternatives, or bail out.  */
 #if (!defined(isfinite) || defined(__CYGWIN__))
 #undef isfinite
-static inline int
-isfinite (double x)
-{
 #if defined(fpclassify)
-  return (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE);
-#elif defined(HAVE_FINITE)
-  return finite (x);
+#define isfinite(x) (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
 #else
-#error "libgfortran needs isfinite, fpclassify, or finite"
+#define isfinite(x) ((x) - (x) == 0)
 #endif
-}
 #endif /* !defined(isfinite)  */
 
 /* TODO: find the C99 version of these an move into above ifdef.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]