Subject: | Does not support Visual C++ 6.0, patch attached to fix |
Date: | Mon, 11 Mar 2013 10:27:41 +0200 |
To: | bug-Compress-LZ4 [...] rt.cpan.org |
From: | "Roey Almog (Infoneto Ltd)" <almog [...] infoneto.co.il> |
Hi,
Due to missing BitScanForward/Reverse on visual C++ 6.0 code is not
compiling.
I added a patched so the BitScan fiction are used from Visual C++ 2005 and
above while using default method for the older versions:
two files need the patch:
--- lz4hc.c (revision 9373)
+++ lz4hc.c (revision 9392)
@@ -215,7 +215,7 @@
inline static int LZ4_NbCommonBytes (register U64 val)
{
#if defined(LZ4_BIG_ENDIAN)
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanReverse64( &r, val );
return (int)(r>>3);
@@ -229,7 +229,7 @@
return r;
#endif
#else
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanForward64( &r, val );
return (int)(r>>3);
@@ -247,7 +247,7 @@
inline static int LZ4_NbCommonBytes (register U32 val)
{
#if defined(LZ4_BIG_ENDIAN)
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanReverse( &r, val );
return (int)(r>>3);
@@ -260,7 +260,7 @@
return r;
#endif
#else
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanForward( &r, val );
return (int)(r>>3);
--- lz4c.c (revision 9373)
+++ lz4c.c (revision 9392)
@@ -101,13 +101,15 @@
#ifdef _MSC_VER // Visual Studio
# define inline __forceinline // Visual is not C99, but
supports some kind of inline
-# include <intrin.h> // For Visual 2005
-# if LZ4_ARCH64 // 64-bit
-# pragma intrinsic(_BitScanForward64) // For Visual 2005
-# pragma intrinsic(_BitScanReverse64) // For Visual 2005
-# else
-# pragma intrinsic(_BitScanForward) // For Visual 2005
-# pragma intrinsic(_BitScanReverse) // For Visual 2005
+# if _MSC_VER >= 1400
+# include <intrin.h> // For Visual 2005
+# if LZ4_ARCH64 // 64-bit
+# pragma intrinsic(_BitScanForward64) // For Visual 2005
+# pragma intrinsic(_BitScanReverse64) // For Visual 2005
+# else
+# pragma intrinsic(_BitScanForward) // For Visual 2005
+# pragma intrinsic(_BitScanReverse) // For Visual 2005
+# endif
# endif
#endif
@@ -254,7 +256,7 @@
static inline int LZ4_NbCommonBytes (register U64 val)
{
#if defined(LZ4_BIG_ENDIAN)
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanReverse64( &r, val );
return (int)(r>>3);
@@ -268,7 +270,7 @@
return r;
#endif
#else
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanForward64( &r, val );
return (int)(r>>3);
@@ -286,7 +288,7 @@
static inline int LZ4_NbCommonBytes (register U32 val)
{
#if defined(LZ4_BIG_ENDIAN)
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanReverse( &r, val );
return (int)(r>>3);
@@ -299,7 +301,7 @@
return r;
#endif
#else
- #if defined(_MSC_VER) && !defined(LZ4_FORCE_SW_BITCOUNT)
+ #if defined(_MSC_VER) && _MSC_VER >= 1400 &&
!defined(LZ4_FORCE_SW_BITCOUNT)
unsigned long r = 0;
_BitScanForward( &r, val );
return (int)(r>>3);