Change 27576 by [EMAIL PROTECTED] on 2006/03/23 09:58:22
Subject: RE: [PATCH, no, really!] Re: [perl #38779] NAN's on Win32
From: "Jan Dubois" <[EMAIL PROTECTED]>
Date: Wed, 22 Mar 2006 22:49:11 -0800
Message-ID: <[EMAIL PROTECTED]>
Also, back out change #27567.
Affected files ...
... //depot/perl/README.win32#87 edit
... //depot/perl/pp.c#530 edit
... //depot/perl/pp_hot.c#460 edit
... //depot/perl/sv.c#1201 edit
... //depot/perl/win32/win32.h#115 edit
Differences ...
==== //depot/perl/README.win32#87 (text) ====
Index: perl/README.win32
--- perl/README.win32#86~27567~ 2006-03-22 06:27:21.000000000 -0800
+++ perl/README.win32 2006-03-23 01:58:22.000000000 -0800
@@ -859,12 +859,6 @@
variable in the handler. Using signals under this port should
currently be considered unsupported.
-Numeric comparisons involving "Not a Number" (NaN, an IEEE floating point
-feature) will give incorrect results if you build with Visual C++ Version 6
-or earlier -- see I<Floating-Point Comparison> in
-L<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndeepc/html/deep05282002.asp>
-for details. If possible, you should build using a later version of VC++.
-
Please send detailed descriptions of any problems and solutions that
you may find to E<lt>F<[EMAIL PROTECTED]>E<gt>, along with the output
produced by C<perl -V>.
@@ -915,6 +909,6 @@
Support for 64-bit Windows added in 5.8 (ActiveState Corp).
-Last updated: 22 March 2006
+Last updated: 30 September 2005
=cut
==== //depot/perl/pp.c#530 (text) ====
Index: perl/pp.c
--- perl/pp.c#529~27548~ 2006-03-20 02:13:38.000000000 -0800
+++ perl/pp.c 2006-03-23 01:58:22.000000000 -0800
@@ -1714,8 +1714,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETNO;
+ SETs(boolSV(left < right));
+#else
dPOPnv;
SETs(boolSV(TOPn < value));
+#endif
RETURN;
}
}
@@ -1790,8 +1797,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETNO;
+ SETs(boolSV(left > right));
+#else
dPOPnv;
SETs(boolSV(TOPn > value));
+#endif
RETURN;
}
}
@@ -1866,8 +1880,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETNO;
+ SETs(boolSV(left <= right));
+#else
dPOPnv;
SETs(boolSV(TOPn <= value));
+#endif
RETURN;
}
}
@@ -1942,8 +1963,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETNO;
+ SETs(boolSV(left >= right));
+#else
dPOPnv;
SETs(boolSV(TOPn >= value));
+#endif
RETURN;
}
}
@@ -2011,8 +2039,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETYES;
+ SETs(boolSV(left != right));
+#else
dPOPnv;
SETs(boolSV(TOPn != value));
+#endif
RETURN;
}
}
==== //depot/perl/pp_hot.c#460 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#459~27533~ 2006-03-17 05:38:34.000000000 -0800
+++ perl/pp_hot.c 2006-03-23 01:58:22.000000000 -0800
@@ -363,8 +363,15 @@
}
#endif
{
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ dPOPTOPnnrl;
+ if (Perl_isnan(left) || Perl_isnan(right))
+ RETSETNO;
+ SETs(boolSV(left == right));
+#else
dPOPnv;
SETs(boolSV(TOPn == value));
+#endif
RETURN;
}
}
==== //depot/perl/sv.c#1201 (text) ====
Index: perl/sv.c
--- perl/sv.c#1200~27575~ 2006-03-22 16:14:53.000000000 -0800
+++ perl/sv.c 2006-03-23 01:58:22.000000000 -0800
@@ -1895,6 +1895,13 @@
certainly cast into the IV range at IV_MAX, whereas the correct
answer is the UV IV_MAX +1. Hence < ensures that dodgy boundary
cases go to UV */
+#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+ if (Perl_isnan(SvNVX(sv))) {
+ SvUV_set(sv, 0);
+ SvIsUV_on(sv);
+ }
+ else
+#endif
if (SvNVX(sv) < (NV)IV_MAX + 0.5) {
SvIV_set(sv, I_V(SvNVX(sv)));
if (SvNVX(sv) == (NV) SvIVX(sv)
==== //depot/perl/win32/win32.h#115 (text) ====
Index: perl/win32/win32.h
--- perl/win32/win32.h#114~26659~ 2006-01-05 08:22:50.000000000 -0800
+++ perl/win32/win32.h 2006-03-23 01:58:22.000000000 -0800
@@ -210,6 +210,11 @@
#define isnan _isnan
+#if _MSC_VER < 1300
+/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
+#define NAN_COMPARE_BROKEN 1
+#endif
+
#endif /* _MSC_VER */
#ifdef __MINGW32__ /* Minimal Gnu-Win32 */
End of Patch.