In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/3c81f0b3e2da864d10c7b9a137e68516f2c94ce4?hp=3ab1d9735c654257fb7abf549e007d510bbb718f>

- Log -----------------------------------------------------------------
commit 3c81f0b3e2da864d10c7b9a137e68516f2c94ce4
Author: Daniel Dragan <[email protected]>
Date:   Wed Dec 31 15:58:07 2014 -0500

    [PATCH] fix PL_nan_u from leaking in every translation object on Win32 VC

M       gv.c
M       numeric.c
M       perl.h
M       sv.c
M       win32/win32.h

commit 4112ab0dbe2ae98361989f6ab858863697d6ceca
Author: Jarkko Hietaniemi <[email protected]>
Date:   Wed Feb 4 22:06:10 2015 -0500

    infnan: more NV_SNAN/NV_QNAN

M       perl.h
-----------------------------------------------------------------------

Summary of changes:
 gv.c          |  2 +-
 numeric.c     |  8 ++++++++
 perl.h        | 12 +++---------
 sv.c          |  7 +++++++
 win32/win32.h | 25 +++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/gv.c b/gv.c
index 82db197..41cebeb 100644
--- a/gv.c
+++ b/gv.c
@@ -39,7 +39,7 @@ Perl stores its global variables.
 #include "feature.h"
 
 static const char S_autoload[] = "AUTOLOAD";
-static const STRLEN S_autolen = sizeof(S_autoload)-1;
+#define S_autolen (sizeof("AUTOLOAD")-1)
 
 GV *
 Perl_gv_add_by_type(pTHX_ GV *gv, svtype type)
diff --git a/numeric.c b/numeric.c
index d5c422f..a6f6018 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1259,6 +1259,11 @@ Perl_my_atof(pTHX_ const char* s)
     return x;
 }
 
+
+#ifdef USING_MSVC6
+#  pragma warning(push)
+#  pragma warning(disable:4756;disable:4056)
+#endif
 static char*
 S_my_atof_infnan(pTHX_ const char* s, bool negative, const char* send, NV* 
value)
 {
@@ -1330,6 +1335,9 @@ S_my_atof_infnan(pTHX_ const char* s, bool negative, 
const char* send, NV* value
     }
     return NULL;
 }
+#ifdef USING_MSVC6
+#  pragma warning(pop)
+#endif
 
 char*
 Perl_my_atof2(pTHX_ const char* orig, NV* value)
diff --git a/perl.h b/perl.h
index e8e268e..b6dbf61 100644
--- a/perl.h
+++ b/perl.h
@@ -4257,14 +4257,6 @@ START_EXTERN_C
 END_EXTERN_C
 #endif
 
-#ifdef WIN32
-#  if !defined(NV_INF) && defined(HUGE_VAL)
-#    define NV_INF HUGE_VAL
-#  endif
-/* For WIN32 the best NV_NAN is the __PL_nan_u trick, see below.
- * There is no supported way of getting the NAN across all the crts. */
-#endif
-
 /* If you are thinking of using HUGE_VAL for infinity, or using
  * <math.h> functions to generate NV_INF (e.g. exp(1e9), log(-1.0)),
  * stop.  Neither will work portably: HUGE_VAL can be just DBL_MAX,
@@ -4340,16 +4332,18 @@ static const union { unsigned int __i; float __f; } 
__PL_inf_u =
 #endif
 #if !defined(NV_NAN) && defined(DBL_SNAN)
 #  define NV_NAN (NV)DBL_SNAN
-#  define NV_SNAN DBL_QNAN
+#  define NV_SNAN DBL_SNAN
 #endif
 #if !defined(NV_NAN) && defined(NAN)
 #  define NV_NAN (NV)NAN
 #endif
 #if !defined(NV_NAN) && defined(QNAN)
 #  define NV_NAN (NV)QNAN
+#  define NV_QNAN QNAN
 #endif
 #if !defined(NV_NAN) && defined(SNAN)
 #  define NV_NAN (NV)SNAN
+#  define NV_SNAN SNAN
 #endif
 #if !defined(NV_NAN) && defined(I_SUNMATH)
 #  define NV_NAN (NV)quiet_nan()
diff --git a/sv.c b/sv.c
index 0160443..ca1a1da 100644
--- a/sv.c
+++ b/sv.c
@@ -2107,6 +2107,10 @@ S_sv_2iuv_non_preserve(pTHX_ SV *const sv
 
 /* If numtype is infnan, set the NV of the sv accordingly.
  * If numtype is anything else, try setting the NV using Atof(PV). */
+#ifdef USING_MSVC6
+#  pragma warning(push)
+#  pragma warning(disable:4756;disable:4056)
+#endif
 static void
 S_sv_setnv(pTHX_ SV* sv, int numtype)
 {
@@ -2131,6 +2135,9 @@ S_sv_setnv(pTHX_ SV* sv, int numtype)
             SvPOK_on(sv); /* PV is okay, though. */
     }
 }
+#ifdef USING_MSVC6
+#  pragma warning(pop)
+#endif
 
 STATIC bool
 S_sv_2iuv_common(pTHX_ SV *const sv)
diff --git a/win32/win32.h b/win32/win32.h
index 657b008..8a55202 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -260,6 +260,31 @@ typedef unsigned short     mode_t;
 #  pragma intrinsic(_rotl64,_rotr64)
 #endif
 
+#  pragma warning(push)
+#  pragma warning(disable:4756;disable:4056)
+PERL_STATIC_INLINE
+double S_Infinity() {
+    /* this is a real C literal which can get further constant folded
+       unlike using HUGE_VAL/_HUGE which are data symbol imports from the CRT
+       and therefore can not by folded by VC, an example of constant
+       folding INF is creating -INF */
+    return (DBL_MAX+DBL_MAX);
+}
+#  pragma warning(pop)
+#  define NV_INF S_Infinity()
+
+/* selectany allows duplicate and unused data symbols to be removed by
+   VC linker, if this were static, each translation unit will have its own,
+   usually unused __PL_nan_u, if this were plain extern it will cause link
+   to fail due to multiple definitions, since we dont know if we are being
+   compiled as static or DLL XS, selectany simply always works, the cost of
+   importing __PL_nan_u across DLL boundaries in size in the importing DLL
+   will be more than the 8 bytes it will take up being in each XS DLL if
+   that DLL actually uses __PL_nan_u */
+extern const __declspec(selectany) union { unsigned __int64 __q; double __d; }
+__PL_nan_u = { 0x7FF8000000000000UI64 };
+#  define NV_NAN ((NV)__PL_nan_u.__d)
+
 #endif /* _MSC_VER */
 
 #ifdef __MINGW32__             /* Minimal Gnu-Win32 */

--
Perl5 Master Repository

Reply via email to