//**************************************\r
// Compiler Options\r
//**************************************\r
-// Visual warning messages\r
+// Disable some Visual warning messages\r
#define _CRT_SECURE_NO_WARNINGS\r
+#define _CRT_SECURE_NO_DEPRECATE // VS2005\r
\r
// Under Linux at least, pull in the *64 commands\r
#define _LARGEFILE64_SOURCE\r
struct timeb tb;\r
int nCount;\r
ftime( &tb );\r
- nCount = tb.millitm + (tb.time & 0xfffff) * 1000;\r
+ nCount = (int) (tb.millitm + (tb.time & 0xfffff) * 1000);\r
return nCount;\r
}\r
\r
// Alloc\r
chunkP = (struct chunkParameters*) malloc(((benchedsize / chunkSize)+1) * sizeof(struct chunkParameters));\r
in_buff = malloc((size_t )benchedsize);\r
- nbChunks = (benchedsize / chunkSize) + 1;\r
+ nbChunks = (int) (benchedsize / chunkSize) + 1;\r
maxCChunkSize = LZ4_compressBound(chunkSize);\r
out_buff_size = nbChunks * maxCChunkSize;\r
out_buff = malloc((size_t )out_buff_size);\r
{\r
chunkP[i].id = i;\r
chunkP[i].inputBuffer = in; in += chunkSize;\r
- if ((int)remaining > chunkSize) { chunkP[i].inputSize = chunkSize; remaining -= chunkSize; } else { chunkP[i].inputSize = remaining; remaining = 0; }\r
+ if ((int)remaining > chunkSize) { chunkP[i].inputSize = chunkSize; remaining -= chunkSize; } else { chunkP[i].inputSize = (int)remaining; remaining = 0; }\r
chunkP[i].outputBuffer = out; out += maxCChunkSize;\r
chunkP[i].outputSize = 0;\r
}\r
}\r
\r
// Calculating input Checksum\r
- crcc = BMK_checksum_MMH3A(in_buff, benchedsize);\r
+ crcc = BMK_checksum_MMH3A(in_buff, (unsigned int)benchedsize);\r
\r
\r
// Bench\r
DISPLAY("%1i-%-14.14s : %9i -> %9i (%5.2f%%),%7.1f MB/s ,%7.1f MB/s\r", loopNb, infilename, (int)benchedsize, (int)cSize, ratio, (double)benchedsize / fastestC / 1000., (double)benchedsize / fastestD / 1000.);\r
\r
// CRC Checking\r
- crcd = BMK_checksum_MMH3A(in_buff, benchedsize);\r
+ crcd = BMK_checksum_MMH3A(in_buff, (unsigned int)benchedsize);\r
if (crcc!=crcd) { DISPLAY("\n!!! WARNING !!! %14s : Invalid Checksum : %x != %x\n", infilename, (unsigned)crcc, (unsigned)crcd); break; }\r
}\r
\r
\r
#ifdef _MSC_VER // Visual Studio\r
# define inline __forceinline // Visual is not C99, but supports some kind of inline\r
+# include <intrin.h> // For Visual 2005\r
# if LZ4_ARCH64 // 64-bit\r
# pragma intrinsic(_BitScanForward64) // For Visual 2005\r
# pragma intrinsic(_BitScanReverse64) // For Visual 2005\r
while ((ip>anchor) && (ref>(BYTE*)source) && unlikely(ip[-1]==ref[-1])) { ip--; ref--; }\r
\r
// Encode Literal length\r
- length = ip - anchor;\r
+ length = (int)(ip - anchor);\r
token = op++;\r
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit\r
#ifdef _MSC_VER\r
\r
_next_match:\r
// Encode Offset\r
- LZ4_WRITE_LITTLEENDIAN_16(op,ip-ref);\r
+ LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));\r
\r
// Start Counting\r
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified\r
_endCount:\r
\r
// Encode MatchLength\r
- len = (ip - anchor);\r
+ len = (int)(ip - anchor);\r
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; }\r
else *token += len;\r
\r
_last_literals:\r
// Encode Last Literals\r
{\r
- int lastRun = iend - anchor;\r
+ int lastRun = (int)(iend - anchor);\r
if (((char*)op - dest) + lastRun + 1 + ((lastRun-15)/255) >= maxOutputSize) return 0;\r
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }\r
else *op++ = (lastRun<<ML_BITS);\r
\r
forwardH = LZ4_HASH64K_VALUE(forwardIp);\r
ref = base + HashTable[h];\r
- HashTable[h] = ip - base;\r
+ HashTable[h] = (U16)(ip - base);\r
\r
} while (A32(ref) != A32(ip));\r
\r
while ((ip>anchor) && (ref>(BYTE*)source) && (ip[-1]==ref[-1])) { ip--; ref--; }\r
\r
// Encode Literal length\r
- length = ip - anchor;\r
+ length = (int)(ip - anchor);\r
token = op++;\r
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit\r
#ifdef _MSC_VER\r
\r
_next_match:\r
// Encode Offset\r
- LZ4_WRITE_LITTLEENDIAN_16(op,ip-ref);\r
+ LZ4_WRITE_LITTLEENDIAN_16(op,(U16)(ip-ref));\r
\r
// Start Counting\r
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified\r
_endCount:\r
\r
// Encode MatchLength\r
- len = (ip - anchor);\r
+ len = (int)(ip - anchor);\r
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; }\r
else *token += len;\r
\r
if (ip > mflimit) { anchor = ip; break; }\r
\r
// Fill table\r
- HashTable[LZ4_HASH64K_VALUE(ip-2)] = ip - 2 - base;\r
+ HashTable[LZ4_HASH64K_VALUE(ip-2)] = (U16)(ip - 2 - base);\r
\r
// Test next position\r
ref = base + HashTable[LZ4_HASH64K_VALUE(ip)];\r
- HashTable[LZ4_HASH64K_VALUE(ip)] = ip - base;\r
+ HashTable[LZ4_HASH64K_VALUE(ip)] = (U16)(ip - base);\r
if (A32(ref) == A32(ip)) { token = op++; *token=0; goto _next_match; }\r
\r
// Prepare next loop\r
_last_literals:\r
// Encode Last Literals\r
{\r
- int lastRun = iend - anchor;\r
+ int lastRun = (int)(iend - anchor);\r
if (((char*)op - dest) + lastRun + 1 + ((lastRun)>>8) >= maxOutputSize) return 0;\r
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }\r
else *op++ = (lastRun<<ML_BITS);\r
The license of the demo program is GPL.\r
*/\r
\r
-//****************************\r
-// Warning messages\r
-//****************************\r
-#define _CRT_SECURE_NO_WARNINGS // Visual (must be first line)\r
+//**************************************\r
+// Compiler Options\r
+//**************************************\r
+// Disable some Visual warning messages\r
+#define _CRT_SECURE_NO_WARNINGS\r
+#define _CRT_SECURE_NO_DEPRECATE // VS2005\r
\r
\r
//****************************\r
{\r
int outSize;\r
// Read Block\r
- int inSize = fread(in_buff, 1, CHUNKSIZE, finput);\r
+ int inSize = (int) fread(in_buff, (size_t)1, (size_t)CHUNKSIZE, finput);\r
if( inSize<=0 ) break;\r
filesize += inSize;\r
if (displayLevel) DISPLAY("Read : %i MB \r", (int)(filesize>>20));\r
\r
#ifdef _MSC_VER\r
#define inline __forceinline // Visual is not C99, but supports some kind of inline\r
+#include <intrin.h> // For Visual 2005\r
+# if LZ4_ARCH64 // 64-bit\r
+# pragma intrinsic(_BitScanForward64) // For Visual 2005\r
+# pragma intrinsic(_BitScanReverse64) // For Visual 2005\r
+# else\r
+# pragma intrinsic(_BitScanForward) // For Visual 2005\r
+# pragma intrinsic(_BitScanReverse) // For Visual 2005\r
+# endif\r
#endif\r
\r
#ifdef _MSC_VER // Visual Studio\r
if ((ipt<matchlimit) && (*reft == *ipt)) ipt++;\r
_endCount:\r
\r
- if (ipt-ip > ml) { ml = ipt-ip; *matchpos = ref; }\r
+ if (ipt-ip > ml) { ml = (int)(ipt-ip); *matchpos = ref; }\r
}\r
ref = GETNEXT(ref);\r
}\r
INITBASE(base,hc4->base);\r
const BYTE* ref;\r
int nbAttempts = MAX_NB_ATTEMPTS;\r
- int delta = ip-startLimit;\r
+ int delta = (int)(ip-startLimit);\r
\r
// First Match\r
LZ4HC_Insert(hc4, ip);\r
\r
if ((ipt-startt) > longest)\r
{\r
- longest = ipt-startt;\r
+ longest = (int)(ipt-startt);\r
*matchpos = reft;\r
*startpos = startt;\r
}\r
BYTE* token;\r
\r
// Encode Literal length\r
- length = *ip - *anchor;\r
+ length = (int)(*ip - *anchor);\r
token = (*op)++;\r
if (length>=(int)RUN_MASK) { *token=(RUN_MASK<<ML_BITS); len = length-RUN_MASK; for(; len > 254 ; len-=255) *(*op)++ = 255; *(*op)++ = (BYTE)len; } \r
else *token = (length<<ML_BITS);\r
LZ4_BLINDCOPY(*anchor, *op, length);\r
\r
// Encode Offset\r
- LZ4_WRITE_LITTLEENDIAN_16(*op,*ip-ref);\r
+ LZ4_WRITE_LITTLEENDIAN_16(*op,(U16)(*ip-ref));\r
\r
// Encode MatchLength\r
len = (int)(ml-MINMATCH);\r
int correction;\r
int new_ml = ml;\r
if (new_ml > OPTIMAL_ML) new_ml = OPTIMAL_ML;\r
- if (ip+new_ml > start2 + ml2 - MINMATCH) new_ml = start2 - ip + ml2 - MINMATCH;\r
- correction = new_ml - (start2 - ip);\r
+ if (ip+new_ml > start2 + ml2 - MINMATCH) new_ml = (int)(start2 - ip) + ml2 - MINMATCH;\r
+ correction = new_ml - (int)(start2 - ip);\r
if (correction > 0)\r
{\r
start2 += correction;\r
{\r
int correction;\r
if (ml > OPTIMAL_ML) ml = OPTIMAL_ML;\r
- if (ip+ml > start2 + ml2 - MINMATCH) ml = start2 - ip + ml2 - MINMATCH;\r
- correction = ml - (start2 - ip);\r
+ if (ip+ml > start2 + ml2 - MINMATCH) ml = (int)(start2 - ip) + ml2 - MINMATCH;\r
+ correction = ml - (int)(start2 - ip);\r
if (correction > 0)\r
{\r
start2 += correction;\r
}\r
else\r
{\r
- ml = start2 - ip;\r
+ ml = (int)(start2 - ip);\r
}\r
}\r
// Now, encode 2 sequences\r
{\r
if (start2 < ip+ml)\r
{\r
- int correction = (ip+ml) - start2;\r
+ int correction = (int)(ip+ml - start2);\r
start2 += correction;\r
ref2 += correction;\r
ml2 -= correction;\r
{\r
int correction;\r
if (ml > OPTIMAL_ML) ml = OPTIMAL_ML;\r
- if (ip + ml > start2 + ml2 - MINMATCH) ml = start2 - ip + ml2 - MINMATCH;\r
- correction = ml - (start2 - ip);\r
+ if (ip + ml > start2 + ml2 - MINMATCH) ml = (int)(start2 - ip) + ml2 - MINMATCH;\r
+ correction = ml - (int)(start2 - ip);\r
if (correction > 0)\r
{\r
start2 += correction;\r
}\r
else\r
{\r
- ml = start2 - ip;\r
+ ml = (int)(start2 - ip);\r
}\r
}\r
LZ4_encodeSequence(&ip, &op, &anchor, ml, ref);\r
\r
// Encode Last Literals\r
{\r
- int lastRun = iend - anchor;\r
+ int lastRun = (int)(iend - anchor);\r
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; } \r
else *op++ = (lastRun<<ML_BITS);\r
memcpy(op, anchor, iend - anchor);\r