mirror of
https://github.com/facebook/zstd.git
synced 2025-08-07 06:23:00 +03:00
added target zstd in root Makefile
This commit is contained in:
4
Makefile
4
Makefile
@@ -41,7 +41,7 @@ else
|
|||||||
VOID = /dev/null
|
VOID = /dev/null
|
||||||
endif
|
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
|
default: zstdprogram
|
||||||
|
|
||||||
@@ -53,6 +53,8 @@ zstdprogram:
|
|||||||
$(MAKE) -C $(PRGDIR)
|
$(MAKE) -C $(PRGDIR)
|
||||||
cp $(PRGDIR)/zstd .
|
cp $(PRGDIR)/zstd .
|
||||||
|
|
||||||
|
zstd: zstdprogram
|
||||||
|
|
||||||
zlibwrapper:
|
zlibwrapper:
|
||||||
$(MAKE) -C $(ZSTDDIR) all
|
$(MAKE) -C $(ZSTDDIR) all
|
||||||
$(MAKE) -C $(ZWRAPDIR) all
|
$(MAKE) -C $(ZWRAPDIR) all
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h> // malloc, exit
|
#include <stdlib.h> // malloc, exit
|
||||||
#include <stdio.h> // printf
|
#include <stdio.h> // fprintf, perror
|
||||||
#include <string.h> // strerror
|
#include <string.h> // strerror
|
||||||
#include <errno.h> // errno
|
#include <errno.h> // errno
|
||||||
#include <sys/stat.h> // stat
|
#include <sys/stat.h> // stat
|
||||||
@@ -36,7 +36,7 @@ static off_t fsize_X(const char *filename)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(filename, &st) == 0) return st.st_size;
|
if (stat(filename, &st) == 0) return st.st_size;
|
||||||
/* error */
|
/* error */
|
||||||
printf("stat: %s : %s \n", filename, strerror(errno));
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ static FILE* fopen_X(const char *filename, const char *instruction)
|
|||||||
FILE* const inFile = fopen(filename, instruction);
|
FILE* const inFile = fopen(filename, instruction);
|
||||||
if (inFile) return inFile;
|
if (inFile) return inFile;
|
||||||
/* error */
|
/* error */
|
||||||
printf("fopen: %s : %s \n", filename, strerror(errno));
|
perror(filename);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ static void* malloc_X(size_t size)
|
|||||||
void* const buff = malloc(size);
|
void* const buff = malloc(size);
|
||||||
if (buff) return buff;
|
if (buff) return buff;
|
||||||
/* error */
|
/* error */
|
||||||
printf("malloc: %s \n", strerror(errno));
|
perror(NULL);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ static void* loadFile_X(const char* fileName, size_t* size)
|
|||||||
void* const buffer = malloc_X(buffSize);
|
void* const buffer = malloc_X(buffSize);
|
||||||
size_t const readSize = fread(buffer, 1, buffSize, inFile);
|
size_t const readSize = fread(buffer, 1, buffSize, inFile);
|
||||||
if (readSize != (size_t)buffSize) {
|
if (readSize != (size_t)buffSize) {
|
||||||
printf("fread: %s : %s \n", fileName, strerror(errno));
|
fprintf(stderr, "fread: %s : %s \n", fileName, strerror(errno));
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
fclose(inFile);
|
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");
|
FILE* const oFile = fopen_X(fileName, "wb");
|
||||||
size_t const wSize = fwrite(buff, 1, buffSize, oFile);
|
size_t const wSize = fwrite(buff, 1, buffSize, oFile);
|
||||||
if (wSize != (size_t)buffSize) {
|
if (wSize != (size_t)buffSize) {
|
||||||
printf("fwrite: %s : %s \n", fileName, strerror(errno));
|
fprintf(stderr, "fwrite: %s : %s \n", fileName, strerror(errno));
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
size_t const closeError = fclose(oFile);
|
if (fclose(oFile)) {
|
||||||
if (closeError) {
|
perror(fileName);
|
||||||
printf("fclose: %s : %s \n", fileName, strerror(errno));
|
|
||||||
exit(6);
|
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);
|
size_t const cSize = ZSTD_compress(cBuff, cBuffSize, fBuff, fSize, 1);
|
||||||
if (ZSTD_isError(cSize)) {
|
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);
|
exit(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -535,6 +535,7 @@ static size_t HUF_compress_internal (
|
|||||||
{ size_t const hSize = HUF_writeCTable (op, dstSize, CTable, maxSymbolValue, huffLog);
|
{ size_t const hSize = HUF_writeCTable (op, dstSize, CTable, maxSymbolValue, huffLog);
|
||||||
if (HUF_isError(hSize)) return hSize;
|
if (HUF_isError(hSize)) return hSize;
|
||||||
if (hSize + 12 >= srcSize) return 0; /* not useful to try compression */
|
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;
|
op += hSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -657,7 +657,7 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc,
|
|||||||
: HUF_compress2 (ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 12);
|
: 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);
|
return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);
|
||||||
if (cLitSize==1)
|
if (cLitSize==1)
|
||||||
return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize);
|
return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize);
|
||||||
|
Reference in New Issue
Block a user