summaryrefslogtreecommitdiff
path: root/win32/win32.h
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-12-31 15:58:07 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2015-02-04 22:15:55 -0500
commit3c81f0b3e2da864d10c7b9a137e68516f2c94ce4 (patch)
treea517207e0a9933fbe74794ba9ce9c3fd2a76d092 /win32/win32.h
parent4112ab0dbe2ae98361989f6ab858863697d6ceca (diff)
downloadperl-3c81f0b3e2da864d10c7b9a137e68516f2c94ce4.tar.gz
[PATCH] fix PL_nan_u from leaking in every translation object on Win32 VC
Diffstat (limited to 'win32/win32.h')
-rw-r--r--win32/win32.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/win32/win32.h b/win32/win32.h
index 657b008740..8a55202b8e 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 */