summaryrefslogtreecommitdiffstats
path: root/lz4.c
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-08-13 07:30:58 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2012-08-13 07:30:58 (GMT)
commit6078c33f8c4b0a58e63308cdd6299075bef755ae (patch)
tree9ddcaecfe254a930e6c4bc82324cedf2bb5faf6f /lz4.c
parent4e11dc62baf8f4e01b588caa75718c028b23a091 (diff)
downloadlz4-6078c33f8c4b0a58e63308cdd6299075bef755ae.zip
lz4-6078c33f8c4b0a58e63308cdd6299075bef755ae.tar.gz
lz4-6078c33f8c4b0a58e63308cdd6299075bef755ae.tar.bz2
Fixed Visual 2005 issues (warning/linking)
git-svn-id: https://lz4.googlecode.com/svn/trunk@75 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
Diffstat (limited to 'lz4.c')
-rw-r--r--lz4.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lz4.c b/lz4.c
index ea327d5..8bb7a45 100644
--- a/lz4.c
+++ b/lz4.c
@@ -101,6 +101,7 @@
#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
@@ -399,7 +400,7 @@ static inline int LZ4_compressCtx(void** ctx,
while ((ip>anchor) && (ref>(BYTE*)source) && unlikely(ip[-1]==ref[-1])) { ip--; ref--; }
// Encode Literal length
- length = ip - anchor;
+ length = (int)(ip - anchor);
token = op++;
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit
#ifdef _MSC_VER
@@ -429,7 +430,7 @@ static inline int LZ4_compressCtx(void** ctx,
_next_match:
// Encode Offset
- LZ4_WRITE_LITTLEENDIAN_16(op,ip-ref);
+ LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));
// Start Counting
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified
@@ -447,7 +448,7 @@ _next_match:
_endCount:
// Encode MatchLength
- len = (ip - anchor);
+ len = (int)(ip - anchor);
if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; }
else *token += len;
@@ -470,7 +471,7 @@ _endCount:
_last_literals:
// Encode Last Literals
{
- int lastRun = iend - anchor;
+ int lastRun = (int)(iend - anchor);
if (((char*)op - dest) + lastRun + 1 + ((lastRun-15)/255) >= maxOutputSize) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);
@@ -555,7 +556,7 @@ static inline int LZ4_compress64kCtx(void** ctx,
forwardH = LZ4_HASH64K_VALUE(forwardIp);
ref = base + HashTable[h];
- HashTable[h] = ip - base;
+ HashTable[h] = (U16)(ip - base);
} while (A32(ref) != A32(ip));
@@ -563,7 +564,7 @@ static inline int LZ4_compress64kCtx(void** ctx,
while ((ip>anchor) && (ref>(BYTE*)source) && (ip[-1]==ref[-1])) { ip--; ref--; }
// Encode Literal length
- length = ip - anchor;
+ length = (int)(ip - anchor);
token = op++;
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit
#ifdef _MSC_VER
@@ -593,7 +594,7 @@ static inline int LZ4_compress64kCtx(void** ctx,
_next_match:
// Encode Offset
- LZ4_WRITE_LITTLEENDIAN_16(op,ip-ref);
+ LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));
// Start Counting
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified
@@ -611,7 +612,7 @@ _next_match:
_endCount:
// Encode MatchLength
- len = (ip - anchor);
+ len = (int)(ip - anchor);
if (len>=(int)ML_MASK) { *token+=ML_MASK; len-=ML_MASK; for(; len > 509 ; len-=510) { *op++ = 255; *op++ = 255; } if (len > 254) { len-=255; *op++ = 255; } *op++ = (BYTE)len; }
else *token += len;
@@ -619,11 +620,11 @@ _endCount:
if (ip > mflimit) { anchor = ip; break; }
// Fill table
- HashTable[LZ4_HASH64K_VALUE(ip-2)] = ip - 2 - base;
+ HashTable[LZ4_HASH64K_VALUE(ip-2)] = (U16)(ip - 2 - base);
// Test next position
ref = base + HashTable[LZ4_HASH64K_VALUE(ip)];
- HashTable[LZ4_HASH64K_VALUE(ip)] = ip - base;
+ HashTable[LZ4_HASH64K_VALUE(ip)] = (U16)(ip - base);
if (A32(ref) == A32(ip)) { token = op++; *token=0; goto _next_match; }
// Prepare next loop
@@ -634,7 +635,7 @@ _endCount:
_last_literals:
// Encode Last Literals
{
- int lastRun = iend - anchor;
+ int lastRun = (int)(iend - anchor);
if (((char*)op - dest) + lastRun + 1 + ((lastRun)>>8) >= maxOutputSize) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);