octave-maintainers
[Top][All Lists]
Advanced

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

MSVC compiler support [patch 8]: isnan, finite and copysign


From: John W. Eaton
Subject: MSVC compiler support [patch 8]: isnan, finite and copysign
Date: Tue, 17 Oct 2006 22:59:46 -0400

On 17-Oct-2006, Michael Goffioul wrote:

| isnan, finite and copysign are underscored under MSVC.
| 
| Index: configure.in
| ===================================================================
| RCS file: /cvs/octave/configure.in,v
| retrieving revision 1.526
| diff -p -c -r1.526 configure.in
| *** configure.in      13 Oct 2006 18:11:26 -0000      1.526
| --- configure.in      17 Oct 2006 11:07:41 -0000
| *************** case "$canonical_host_type" in
| *** 1450,1455 ****
| --- 1542,1550 ----
|       AC_MSG_NOTICE([forcing HAVE_ISNAN for SCO])
|       AC_DEFINE(HAVE_ISNAN, 1, [Define if you have isnan().])
|     ;;
| +   *-*-msdos)
| +     AC_CHECK_FUNCS(_finite _isnan _copysign)
| +   ;;
|     *)
|       AC_CHECK_FUNCS(finite isnan isinf copysign signbit)
|       AC_CHECK_DECLS(signbit, , , [#include <math.h>])
| Index: liboctave/lo-cieee.c
| ===================================================================
| RCS file: /cvs/octave/liboctave/lo-cieee.c,v
| retrieving revision 1.9
| diff -p -c -r1.9 lo-cieee.c
| *** liboctave/lo-cieee.c      15 Jun 2005 03:45:48 -0000      1.9
| --- liboctave/lo-cieee.c      17 Oct 2006 11:07:42 -0000
| *************** lo_ieee_isnan (double x)
| *** 86,91 ****
| --- 86,93 ----
|   {
|   #if defined (HAVE_ISNAN)
|     return isnan (x);
| + #elif defined(HAVE__ISNAN)
| +   return _isnan (x);
|   #else
|     return 0;
|   #endif
| *************** lo_ieee_finite (double x)
| *** 96,101 ****
| --- 98,105 ----
|   {
|   #if defined (HAVE_FINITE)
|     return finite (x) != 0 && ! lo_ieee_isnan (x);
| + #elif defined (HAVE__FINITE)
| +   return _finite (x) != 0 && ! lo_ieee_isnan (x);
|   #elif defined (HAVE_ISINF)
|     return (! isinf (x) && ! lo_ieee_isnan (x));
|   #else
| *************** lo_ieee_isinf (double x)
| *** 110,115 ****
| --- 114,121 ----
|     return isinf (x);
|   #elif defined (HAVE_FINITE)
|     return (! (finite (x) || lo_ieee_isnan (x)));
| + #elif defined (HAVE__FINITE)
| +   return (! (_finite (x) || lo_ieee_isnan (x)));
|   #else
|     return 0;
|   #endif
| *************** lo_ieee_is_NA (double x)
| *** 122,127 ****
| --- 128,137 ----
|     lo_ieee_double t;
|     t.value = x;
|     return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0;
| + #elif defined HAVE__ISNAN
| +   lo_ieee_double t;
| +   t.value = x;
| +   return (_isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0;
|   #else
|     return 0;
|   #endif
| *************** lo_ieee_signbit (double x)
| *** 170,175 ****
| --- 180,187 ----
|     return (copysign (1.0, x) < 0);
|   #elif defined (HAVE_COPYSIGN)
|     return (x < 0 || copysign (1.0, x) < 0);
| + #elif defined (HAVE__COPYSIGN)
| +   return (x < 0 || _copysign (1.0, x) < 0);
|   #else
|     return x < 0;
|   #endif

Will the following patch work instead?  I'd prefer to avoid
duplicating lines of code just to use a "_x" in place of "x".  Also,
is there no _isinf or _signbit?

jwe


ChangeLog

2006-10-17  John W. Eaton  <address@hidden>

        * configure.in: Check for _isnan, _finite, and _copysign.


liboctave/ChangeLog:

2006-10-17  John W. Eaton  <address@hidden>

        * lo-cieee.c: If isnan is not available but _isnan is, then define
        isnan to be _isnan, and define HAVE_ISNAN.  Likewise for _finite
        and _copysign.
 

Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.527
diff -u -u -r1.527 configure.in
--- configure.in        17 Oct 2006 19:39:14 -0000      1.527
+++ configure.in        18 Oct 2006 02:57:49 -0000
@@ -1452,6 +1452,7 @@
   ;;
   *)
     AC_CHECK_FUNCS(finite isnan isinf copysign signbit)
+    AC_CHECK_FUNCS(_finite _isnan _copysign)
     AC_CHECK_DECLS(signbit, , , [#include <math.h>])
   ;;
 esac
Index: liboctave/lo-cieee.c
===================================================================
RCS file: /cvs/octave/liboctave/lo-cieee.c,v
retrieving revision 1.9
diff -u -u -r1.9 lo-cieee.c
--- liboctave/lo-cieee.c        15 Jun 2005 03:45:48 -0000      1.9
+++ liboctave/lo-cieee.c        18 Oct 2006 02:54:51 -0000
@@ -48,6 +48,21 @@
 
 #include "lo-ieee.h"
 
+#if ! defined (HAVE_ISNAN) && defined (HAVE__ISNAN)
+#define isnan _isnan
+#define HAVE_ISNAN 1
+#endif
+
+#if ! defined (HAVE_FINITE) && defined (HAVE__FINITE)
+#define finite _finite
+#define HAVE_FINITE 1
+#endif
+
+#if ! defined (HAVE_COPYSIGN) && defined (HAVE__COPYSIGN)
+#define copysign _copysign
+#define HAVE_COPYSIGN 1
+#endif
+
 #if defined (_AIX) && defined (__GNUG__)
 #undef finite
 #define finite(x) ((x) < DBL_MAX && (x) > -DBL_MAX)


reply via email to

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