Merge pull request #5 from Cyan4973/dev

Dev
This commit is contained in:
Yann Collet 2015-01-26 13:37:43 +01:00
commit 00f9507d26
4 changed files with 42 additions and 42 deletions

View File

@ -132,7 +132,7 @@ static U32 FSE_readLE32(const void* memPtr)
return FSE_read32(memPtr); return FSE_read32(memPtr);
else else
{ {
const BYTE* p = memPtr; const BYTE* p = (const BYTE*)memPtr;
return (U32)((U32)p[0] + ((U32)p[1]<<8) + ((U32)p[2]<<16) + ((U32)p[3]<<24)); return (U32)((U32)p[0] + ((U32)p[1]<<8) + ((U32)p[2]<<16) + ((U32)p[3]<<24));
} }
} }
@ -145,7 +145,7 @@ static void FSE_writeLE32(void* memPtr, U32 val32)
} }
else else
{ {
BYTE* p = memPtr; BYTE* p = (BYTE*)memPtr;
p[0] = (BYTE)val32; p[0] = (BYTE)val32;
p[1] = (BYTE)(val32>>8); p[1] = (BYTE)(val32>>8);
p[2] = (BYTE)(val32>>16); p[2] = (BYTE)(val32>>16);
@ -166,7 +166,7 @@ static U64 FSE_readLE64(const void* memPtr)
return FSE_read64(memPtr); return FSE_read64(memPtr);
else else
{ {
const BYTE* p = memPtr; const BYTE* p = (const BYTE*)memPtr;
return (U64)((U64)p[0] + ((U64)p[1]<<8) + ((U64)p[2]<<16) + ((U64)p[3]<<24) return (U64)((U64)p[0] + ((U64)p[1]<<8) + ((U64)p[2]<<16) + ((U64)p[3]<<24)
+ ((U64)p[4]<<32) + ((U64)p[5]<<40) + ((U64)p[6]<<48) + ((U64)p[7]<<56)); + ((U64)p[4]<<32) + ((U64)p[5]<<40) + ((U64)p[6]<<48) + ((U64)p[7]<<56));
} }
@ -180,7 +180,7 @@ static void FSE_writeLE64(void* memPtr, U64 val64)
} }
else else
{ {
BYTE* p = memPtr; BYTE* p = (BYTE*)memPtr;
p[0] = (BYTE)val64; p[0] = (BYTE)val64;
p[1] = (BYTE)(val64>>8); p[1] = (BYTE)(val64>>8);
p[2] = (BYTE)(val64>>16); p[2] = (BYTE)(val64>>16);
@ -618,8 +618,8 @@ typedef struct
int FSE_compareRankT(const void* r1, const void* r2) int FSE_compareRankT(const void* r1, const void* r2)
{ {
const rank_t* R1 = r1; const rank_t* R1 = (const rank_t*)r1;
const rank_t* R2 = r2; const rank_t* R2 = (const rank_t*)r2;
return 2 * (R1->count < R2->count) - 1; return 2 * (R1->count < R2->count) - 1;
} }
@ -1005,7 +1005,7 @@ size_t FSE_decompressRLE(void* dst, size_t originalSize,
size_t FSE_buildDTable_rle (void* DTable, BYTE symbolValue) size_t FSE_buildDTable_rle (void* DTable, BYTE symbolValue)
{ {
U32* const base32 = DTable; U32* const base32 = (U32* const)DTable;
FSE_decode_t* const cell = (FSE_decode_t*)(base32 + 1); FSE_decode_t* const cell = (FSE_decode_t*)(base32 + 1);
/* Sanity check */ /* Sanity check */
@ -1023,7 +1023,7 @@ size_t FSE_buildDTable_rle (void* DTable, BYTE symbolValue)
size_t FSE_buildDTable_raw (void* DTable, unsigned nbBits) size_t FSE_buildDTable_raw (void* DTable, unsigned nbBits)
{ {
U32* const base32 = DTable; U32* const base32 = (U32* const)DTable;
FSE_decode_t* dinfo = (FSE_decode_t*)(base32 + 1); FSE_decode_t* dinfo = (FSE_decode_t*)(base32 + 1);
const unsigned tableSize = 1 << nbBits; const unsigned tableSize = 1 << nbBits;
const unsigned tableMask = tableSize - 1; const unsigned tableMask = tableSize - 1;
@ -1142,7 +1142,7 @@ unsigned FSE_reloadDStream(FSE_DStream_t* bitD)
void FSE_initDState(FSE_DState_t* DStatePtr, FSE_DStream_t* bitD, const void* DTable) void FSE_initDState(FSE_DState_t* DStatePtr, FSE_DStream_t* bitD, const void* DTable)
{ {
const U32* const base32 = DTable; const U32* const base32 = (const U32* const)DTable;
DStatePtr->state = FSE_readBits(bitD, base32[0]); DStatePtr->state = FSE_readBits(bitD, base32[0]);
FSE_reloadDStream(bitD); FSE_reloadDStream(bitD);
DStatePtr->table = base32 + 1; DStatePtr->table = base32 + 1;
@ -1511,7 +1511,7 @@ void FSE_FUNCTION_NAME(FSE_freeDTable, FSE_FUNCTION_EXTENSION) (void* DTable)
size_t FSE_FUNCTION_NAME(FSE_buildDTable, FSE_FUNCTION_EXTENSION) size_t FSE_FUNCTION_NAME(FSE_buildDTable, FSE_FUNCTION_EXTENSION)
(void* DTable, const short* const normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) (void* DTable, const short* const normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
{ {
U32* const base32 = DTable; U32* const base32 = (U32* const)DTable;
FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (base32+1); FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (base32+1);
const U32 tableSize = 1 << tableLog; const U32 tableSize = 1 << tableLog;
const U32 tableMask = tableSize-1; const U32 tableMask = tableSize-1;

View File

@ -202,15 +202,15 @@ static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
static void ZSTD_wildcopy(void* dst, const void* src, size_t length) static void ZSTD_wildcopy(void* dst, const void* src, size_t length)
{ {
const BYTE* ip = src; const BYTE* ip = (const BYTE*)src;
BYTE* op = dst; BYTE* op = (BYTE*)dst;
BYTE* const oend = op + length; BYTE* const oend = op + length;
while (op < oend) COPY8(op, ip); while (op < oend) COPY8(op, ip);
} }
static size_t ZSTD_writeProgressive(void* ptr, size_t value) static size_t ZSTD_writeProgressive(void* ptr, size_t value)
{ {
BYTE* const bStart = ptr; BYTE* const bStart = (BYTE* const)ptr;
BYTE* byte = bStart; BYTE* byte = bStart;
do do
@ -227,7 +227,7 @@ static size_t ZSTD_writeProgressive(void* ptr, size_t value)
static size_t ZSTD_readProgressive(size_t* result, const void* ptr) static size_t ZSTD_readProgressive(size_t* result, const void* ptr)
{ {
const BYTE* const bStart = ptr; const BYTE* const bStart = (const BYTE* const)ptr;
const BYTE* byte = bStart; const BYTE* byte = bStart;
size_t r = 0; size_t r = 0;
U32 shift = 0; U32 shift = 0;
@ -276,7 +276,7 @@ ZSTD_cctx_t ZSTD_createCCtx(void)
void ZSTD_resetCCtx(ZSTD_cctx_t ctx) void ZSTD_resetCCtx(ZSTD_cctx_t ctx)
{ {
refTables_t* srt = ctx; refTables_t* srt = (refTables_t*)ctx;
srt->base = NULL; srt->base = NULL;
memset(srt->hashTable, 0, HASH_TABLESIZE*4); memset(srt->hashTable, 0, HASH_TABLESIZE*4);
} }
@ -437,7 +437,7 @@ size_t ZSTD_compressBound(size_t srcSize) /* maximum compressed size */
static size_t ZSTD_compressRle (void* dst, size_t maxDstSize, const void* src, size_t srcSize) static size_t ZSTD_compressRle (void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
/* at this stage : dstSize >= FSE_compressBound(srcSize) > (ZSTD_blockHeaderSize+1) (checked by ZSTD_compressLiterals()) */ /* at this stage : dstSize >= FSE_compressBound(srcSize) > (ZSTD_blockHeaderSize+1) (checked by ZSTD_compressLiterals()) */
(void)maxDstSize; (void)maxDstSize;
@ -458,7 +458,7 @@ static size_t ZSTD_compressRle (void* dst, size_t maxDstSize, const void* src, s
static size_t ZSTD_noCompressBlock (void* dst, size_t maxDstSize, const void* src, size_t srcSize) static size_t ZSTD_noCompressBlock (void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
if (srcSize + ZSTD_blockHeaderSize > maxDstSize) return (size_t)-ZSTD_ERROR_maxDstSize_tooSmall; if (srcSize + ZSTD_blockHeaderSize > maxDstSize) return (size_t)-ZSTD_ERROR_maxDstSize_tooSmall;
memcpy(ostart + ZSTD_blockHeaderSize, src, srcSize); memcpy(ostart + ZSTD_blockHeaderSize, src, srcSize);
@ -480,7 +480,7 @@ static size_t ZSTD_compressLiterals_usingCTable(void* dst, size_t dstSize,
const void* src, size_t srcSize, const void* src, size_t srcSize,
const void* CTable) const void* CTable)
{ {
const BYTE* const istart = (const BYTE*) src; const BYTE* const istart = (const BYTE*)src;
const BYTE* ip = istart; const BYTE* ip = istart;
const BYTE* const iend = istart + srcSize; const BYTE* const iend = istart + srcSize;
FSE_CStream_t bitC; FSE_CStream_t bitC;
@ -949,7 +949,7 @@ static size_t ZSTD_compressBlock(void* ctx, void* dst, size_t maxDstSize, const
op_l += lastLLSize; op_l += lastLLSize;
/* Finale compression stage */ /* Finale compression stage */
return ZSTD_compressEntropy(dst, maxDstSize, return ZSTD_compressEntropy((BYTE*)dst, maxDstSize,
op_l_start, op_l, op_rl_start, op_rl, op_ml_start, op_offset_start, op_dumps_start, op_dumps, op_l_start, op_l, op_rl_start, op_rl, op_ml_start, op_offset_start, op_dumps_start, op_dumps,
srcSize, lastLLSize); srcSize, lastLLSize);
} }
@ -998,19 +998,19 @@ size_t ZSTD_compressBegin(ZSTD_cctx_t ctx, void* dst, size_t maxDstSize)
size_t ZSTD_compressContinue(ZSTD_cctx_t cctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) size_t ZSTD_compressContinue(ZSTD_cctx_t cctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
refTables_t* ctx = (refTables_t*) cctx; refTables_t* ctx = (refTables_t*) cctx;
const BYTE* const istart = src; const BYTE* const istart = (const BYTE* const)src;
const BYTE* ip = istart; const BYTE* ip = istart;
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* op = ostart; BYTE* op = ostart;
//U32 limit = 4 * BLOCKSIZE; //U32 limit = 4 * BLOCKSIZE;
//const U32 updateRate = 2 * BLOCKSIZE; //const U32 updateRate = 2 * BLOCKSIZE;
/* Init */ /* Init */
if (ctx->base==NULL) ctx->base = src, ctx->current=0; if (ctx->base==NULL) ctx->base = (const BYTE*)src, ctx->current=0;
if (src != ctx->base + ctx->current) /* not contiguous */ if (src != ctx->base + ctx->current) /* not contiguous */
{ {
ZSTD_resetCCtx(ctx); ZSTD_resetCCtx(ctx);
ctx->base = src; ctx->base = (const BYTE*)src;
ctx->current = 0; ctx->current = 0;
} }
ctx->current += (U32)srcSize; ctx->current += (U32)srcSize;
@ -1065,7 +1065,7 @@ size_t ZSTD_compressContinue(ZSTD_cctx_t cctx, void* dst, size_t maxDstSize, con
size_t ZSTD_compressEnd(ZSTD_cctx_t ctx, void* dst, size_t maxDstSize) size_t ZSTD_compressEnd(ZSTD_cctx_t ctx, void* dst, size_t maxDstSize)
{ {
BYTE* op = dst; BYTE* op = (BYTE*)dst;
// Sanity check // Sanity check
(void)ctx; (void)ctx;
@ -1082,7 +1082,7 @@ size_t ZSTD_compressEnd(ZSTD_cctx_t ctx, void* dst, size_t maxDstSize)
static size_t ZSTD_compressCCtx(void* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) static size_t ZSTD_compressCCtx(void* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* op = ostart; BYTE* op = ostart;
/* Header */ /* Header */
@ -1130,7 +1130,7 @@ size_t ZSTD_compress(void* dst, size_t maxDstSize, const void* src, size_t srcSi
size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr) size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
{ {
const BYTE* const in = src; const BYTE* const in = (const BYTE* const)src;
BYTE headerFlags; BYTE headerFlags;
U32 cSize; U32 cSize;
@ -1139,7 +1139,7 @@ size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bp
headerFlags = *in; headerFlags = *in;
cSize = in[2] + (in[1]<<8) + ((in[0] & 7)<<16); cSize = in[2] + (in[1]<<8) + ((in[0] & 7)<<16);
bpPtr->blockType = headerFlags >> 6; bpPtr->blockType = (blockType_t)(headerFlags >> 6);
bpPtr->origSize = (bpPtr->blockType == bt_rle) ? cSize : 0; bpPtr->origSize = (bpPtr->blockType == bt_rle) ? cSize : 0;
if (bpPtr->blockType == bt_end) return 0; if (bpPtr->blockType == bt_end) return 0;
@ -1230,7 +1230,7 @@ static size_t ZSTD_decompressLiterals(void* ctx, void* dst, size_t maxDstSize,
const void* src, size_t srcSize) const void* src, size_t srcSize)
{ {
/* assumed : blockType == blockCompressed */ /* assumed : blockType == blockCompressed */
const BYTE* ip = src; const BYTE* ip = (const BYTE*)src;
short norm[256]; short norm[256];
void* DTable = ctx; void* DTable = ctx;
U32 maxSymbolValue = 255; U32 maxSymbolValue = 255;
@ -1258,9 +1258,9 @@ size_t ZSTD_decodeLiteralsBlock(void* ctx,
const BYTE** litPtr, const BYTE** litPtr,
const void* src, size_t srcSize) const void* src, size_t srcSize)
{ {
const BYTE* const istart = src; const BYTE* const istart = (const BYTE* const)src;
const BYTE* ip = istart; const BYTE* ip = istart;
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* const oend = ostart + maxDstSize; BYTE* const oend = ostart + maxDstSize;
blockProperties_t litbp; blockProperties_t litbp;
@ -1300,7 +1300,7 @@ size_t ZSTD_decodeSeqHeaders(size_t* lastLLPtr, const BYTE** dumpsPtr,
void* DTableLL, void* DTableML, void* DTableOffb, void* DTableLL, void* DTableML, void* DTableOffb,
const void* src, size_t srcSize) const void* src, size_t srcSize)
{ {
const BYTE* const istart = src; const BYTE* const istart = (const BYTE* const)src;
const BYTE* ip = istart; const BYTE* ip = istart;
const BYTE* const iend = istart + srcSize; const BYTE* const iend = istart + srcSize;
U32 LLtype, Offtype, MLtype; U32 LLtype, Offtype, MLtype;
@ -1394,9 +1394,9 @@ size_t ZSTD_decodeSeqHeaders(size_t* lastLLPtr, const BYTE** dumpsPtr,
FORCE_INLINE size_t ZSTD_decompressBlock(void* ctx, void* dst, size_t maxDstSize, FORCE_INLINE size_t ZSTD_decompressBlock(void* ctx, void* dst, size_t maxDstSize,
const void* src, size_t srcSize) const void* src, size_t srcSize)
{ {
const BYTE* ip = src; const BYTE* ip = (const BYTE*)src;
const BYTE* const iend = ip + srcSize; const BYTE* const iend = ip + srcSize;
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* op = ostart; BYTE* op = ostart;
BYTE* const oend = ostart + maxDstSize; BYTE* const oend = ostart + maxDstSize;
size_t errorCode; size_t errorCode;
@ -1558,9 +1558,9 @@ _another_round:
static size_t ZSTD_decompressDCtx(void* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize) static size_t ZSTD_decompressDCtx(void* ctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{ {
const BYTE* ip = src; const BYTE* ip = (const BYTE*)src;
const BYTE* iend = ip + srcSize; const BYTE* iend = ip + srcSize;
BYTE* const ostart = dst; BYTE* const ostart = (BYTE* const)dst;
BYTE* op = ostart; BYTE* op = ostart;
BYTE* const oend = ostart + maxDstSize; BYTE* const oend = ostart + maxDstSize;
size_t remainingSize = srcSize; size_t remainingSize = srcSize;
@ -1637,7 +1637,7 @@ typedef struct
ZSTD_dctx_t ZSTD_createDCtx(void) ZSTD_dctx_t ZSTD_createDCtx(void)
{ {
dctx_t* dctx = malloc(sizeof(dctx_t)); dctx_t* dctx = (dctx_t*)malloc(sizeof(dctx_t));
dctx->expected = 4 + ZSTD_blockHeaderSize; // Frame Header + Block Header dctx->expected = 4 + ZSTD_blockHeaderSize; // Frame Header + Block Header
dctx->started = 0; dctx->started = 0;
return (ZSTD_dctx_t)dctx; return (ZSTD_dctx_t)dctx;
@ -1695,7 +1695,7 @@ size_t ZSTD_decompressContinue(ZSTD_dctx_t dctx, void* dst, size_t maxDstSize, c
// Prepare next block // Prepare next block
{ {
const BYTE* header = src; const BYTE* header = (const BYTE*)src;
blockProperties_t bp; blockProperties_t bp;
size_t blockSize; size_t blockSize;
header += cSize; header += cSize;

View File

@ -63,7 +63,7 @@
# include <fcntl.h> /* _O_BINARY */ # include <fcntl.h> /* _O_BINARY */
# include <io.h> /* _setmode, _isatty */ # include <io.h> /* _setmode, _isatty */
# ifdef __MINGW32__ # ifdef __MINGW32__
int _fileno(FILE *stream); /* MINGW somehow forgets to include this windows declaration into <stdio.h> */ /* int _fileno(FILE *stream); // seems no longer useful // MINGW somehow forgets to include this windows declaration into <stdio.h> */
# endif # endif
# define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY) # define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
# define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream))

View File

@ -54,7 +54,7 @@
# include <fcntl.h> // _O_BINARY # include <fcntl.h> // _O_BINARY
# include <io.h> // _setmode, _isatty # include <io.h> // _setmode, _isatty
# ifdef __MINGW32__ # ifdef __MINGW32__
int _fileno(FILE *stream); // MINGW somehow forgets to include this windows declaration into <stdio.h> /* int _fileno(FILE *stream); // seems no longer useful // MINGW somehow forgets to include this windows declaration into <stdio.h> */
# endif # endif
# define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY) # define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
# define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream))
@ -65,9 +65,9 @@
#endif #endif
//**************************** /**************************************
// Constants * Constants
//**************************** **************************************/
#define COMPRESSOR_NAME "zstd command line interface" #define COMPRESSOR_NAME "zstd command line interface"
#ifndef ZSTD_VERSION #ifndef ZSTD_VERSION
# define ZSTD_VERSION "v0.0.1" # define ZSTD_VERSION "v0.0.1"