added target zstd in root Makefile

This commit is contained in:
Yann Collet 2016-07-15 16:12:38 +02:00
parent d3d2db587e
commit 98c8884999
4 changed files with 14 additions and 12 deletions

View File

@ -41,7 +41,7 @@ else
VOID = /dev/null
endif
.PHONY: default all zlibwrapper zstdprogram clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
.PHONY: default all zlibwrapper zstdprogram zstd clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
default: zstdprogram
@ -53,6 +53,8 @@ zstdprogram:
$(MAKE) -C $(PRGDIR)
cp $(PRGDIR)/zstd .
zstd: zstdprogram
zlibwrapper:
$(MAKE) -C $(ZSTDDIR) all
$(MAKE) -C $(ZWRAPDIR) all

View File

@ -24,7 +24,7 @@
*/
#include <stdlib.h> // malloc, exit
#include <stdio.h> // printf
#include <stdio.h> // fprintf, perror
#include <string.h> // strerror
#include <errno.h> // errno
#include <sys/stat.h> // stat
@ -36,7 +36,7 @@ static off_t fsize_X(const char *filename)
struct stat st;
if (stat(filename, &st) == 0) return st.st_size;
/* error */
printf("stat: %s : %s \n", filename, strerror(errno));
perror(filename);
exit(1);
}
@ -45,7 +45,7 @@ static FILE* fopen_X(const char *filename, const char *instruction)
FILE* const inFile = fopen(filename, instruction);
if (inFile) return inFile;
/* error */
printf("fopen: %s : %s \n", filename, strerror(errno));
perror(filename);
exit(2);
}
@ -54,7 +54,7 @@ static void* malloc_X(size_t size)
void* const buff = malloc(size);
if (buff) return buff;
/* error */
printf("malloc: %s \n", strerror(errno));
perror(NULL);
exit(3);
}
@ -65,7 +65,7 @@ static void* loadFile_X(const char* fileName, size_t* size)
void* const buffer = malloc_X(buffSize);
size_t const readSize = fread(buffer, 1, buffSize, inFile);
if (readSize != (size_t)buffSize) {
printf("fread: %s : %s \n", fileName, strerror(errno));
fprintf(stderr, "fread: %s : %s \n", fileName, strerror(errno));
exit(4);
}
fclose(inFile);
@ -79,12 +79,11 @@ static void saveFile_X(const char* fileName, const void* buff, size_t buffSize)
FILE* const oFile = fopen_X(fileName, "wb");
size_t const wSize = fwrite(buff, 1, buffSize, oFile);
if (wSize != (size_t)buffSize) {
printf("fwrite: %s : %s \n", fileName, strerror(errno));
fprintf(stderr, "fwrite: %s : %s \n", fileName, strerror(errno));
exit(5);
}
size_t const closeError = fclose(oFile);
if (closeError) {
printf("fclose: %s : %s \n", fileName, strerror(errno));
if (fclose(oFile)) {
perror(fileName);
exit(6);
}
}
@ -99,7 +98,7 @@ static void compress(const char* fname, const char* oname)
size_t const cSize = ZSTD_compress(cBuff, cBuffSize, fBuff, fSize, 1);
if (ZSTD_isError(cSize)) {
printf("error compressing %s : %s \n", fname, ZSTD_getErrorName(cSize));
fprintf(stderr, "error compressing %s : %s \n", fname, ZSTD_getErrorName(cSize));
exit(7);
}

View File

@ -535,6 +535,7 @@ static size_t HUF_compress_internal (
{ size_t const hSize = HUF_writeCTable (op, dstSize, CTable, maxSymbolValue, huffLog);
if (HUF_isError(hSize)) return hSize;
if (hSize + 12 >= srcSize) return 0; /* not useful to try compression */
//static U64 totalHSize = 0; static U32 nbHSize = 0; totalHSize += hSize; nbHSize++; if ((nbHSize & 63) == 1) printf("average : %6.3f \n", (double)totalHSize / nbHSize);
op += hSize;
}

View File

@ -657,7 +657,7 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc,
: HUF_compress2 (ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 12);
}
if ((cLitSize==0) || (cLitSize >= srcSize - minGain))
if ((cLitSize==0) | (cLitSize >= srcSize - minGain))
return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);
if (cLitSize==1)
return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize);