Merge branch 'dev' of github.com:facebook/zstd into dev

This commit is contained in:
Yann Collet 2017-02-15 12:00:50 -08:00
commit 2252d29a5a
8 changed files with 30 additions and 39 deletions

View File

@ -182,7 +182,7 @@ MEM_STATIC U32 MEM_swap32(U32 in)
{ {
#if defined(_MSC_VER) /* Visual Studio */ #if defined(_MSC_VER) /* Visual Studio */
return _byteswap_ulong(in); return _byteswap_ulong(in);
#elif defined (__GNUC__) #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)
return __builtin_bswap32(in); return __builtin_bswap32(in);
#else #else
return ((in << 24) & 0xff000000 ) | return ((in << 24) & 0xff000000 ) |
@ -196,7 +196,7 @@ MEM_STATIC U64 MEM_swap64(U64 in)
{ {
#if defined(_MSC_VER) /* Visual Studio */ #if defined(_MSC_VER) /* Visual Studio */
return _byteswap_uint64(in); return _byteswap_uint64(in);
#elif defined (__GNUC__) #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)
return __builtin_bswap64(in); return __builtin_bswap64(in);
#else #else
return ((in << 56) & 0xff00000000000000ULL) | return ((in << 56) & 0xff00000000000000ULL) |

View File

@ -2512,7 +2512,7 @@ static size_t ZSTD_loadDictionaryContent(ZSTD_CCtx* zc, const void* src, size_t
return ERROR(GENERIC); /* strategy doesn't exist; impossible */ return ERROR(GENERIC); /* strategy doesn't exist; impossible */
} }
zc->nextToUpdate = zc->loadedDictEnd; zc->nextToUpdate = (U32)(iend - zc->base);
return 0; return 0;
} }

View File

@ -91,8 +91,13 @@ static clock_t g_time = 0;
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
/* ************************************************************
* Avoid fseek()'s 2GiB barrier with MSVC, MacOS, *BSD, MinGW
***************************************************************/
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
# define LONG_SEEK _fseeki64 # define LONG_SEEK _fseeki64
#elif !defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L) /* No point defining Large file for 64 bit */
# define LONG_SEEK fseeko
#elif defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__) #elif defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__)
# define LONG_SEEK fseeko64 # define LONG_SEEK fseeko64
#elif defined(_WIN32) && !defined(__DJGPP__) #elif defined(_WIN32) && !defined(__DJGPP__)
@ -193,7 +198,7 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
f = stdin; f = stdin;
SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdin);
} else { } else {
if (!UTIL_doesFileExists(srcFileName)) { if (!UTIL_isRegFile(srcFileName)) {
DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName); DISPLAYLEVEL(1, "zstd: %s is not a regular file -- ignored \n", srcFileName);
return NULL; return NULL;
} }

View File

@ -51,8 +51,8 @@ extern "C" {
/* ********************************************************* /* *********************************************************
* Turn on Large Files support (>4GB) for 32-bit Linux/Unix * Turn on Large Files support (>4GB) for 32-bit Linux/Unix
***********************************************************/ ***********************************************************/
#if !defined(__64BIT__) /* No point defining Large file for 64 bit */ #if !defined(__64BIT__) || defined(__MINGW32__) /* No point defining Large file for 64 bit but MinGW-w64 requires it */
# if !defined(_FILE_OFFSET_BITS) # if !defined(_FILE_OFFSET_BITS)
# define _FILE_OFFSET_BITS 64 /* turn off_t into a 64-bit type for ftello, fseeko */ # define _FILE_OFFSET_BITS 64 /* turn off_t into a 64-bit type for ftello, fseeko */
# endif # endif
# if !defined(_LARGEFILE_SOURCE) /* obsolete macro, replaced with _FILE_OFFSET_BITS */ # if !defined(_LARGEFILE_SOURCE) /* obsolete macro, replaced with _FILE_OFFSET_BITS */

View File

@ -182,17 +182,34 @@ UTIL_STATIC int UTIL_getFileStat(const char* infilename, stat_t *statbuf)
return 1; return 1;
} }
UTIL_STATIC int UTIL_isRegFile(const char* infilename) UTIL_STATIC int UTIL_isRegFile(const char* infilename)
{ {
stat_t statbuf; stat_t statbuf;
return UTIL_getFileStat(infilename, &statbuf); /* Only need to know whether it is a regular file */ return UTIL_getFileStat(infilename, &statbuf); /* Only need to know whether it is a regular file */
} }
UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
{
int r;
stat_t statbuf;
#if defined(_MSC_VER)
r = _stat64(infilename, &statbuf);
if (!r && (statbuf.st_mode & _S_IFDIR)) return 1;
#else
r = stat(infilename, &statbuf);
if (!r && S_ISDIR(statbuf.st_mode)) return 1;
#endif
return 0;
}
UTIL_STATIC U64 UTIL_getFileSize(const char* infilename) UTIL_STATIC U64 UTIL_getFileSize(const char* infilename)
{ {
int r; int r;
#if defined(_MSC_VER) #if defined(_MSC_VER)
struct _stat64 statbuf; struct __stat64 statbuf;
r = _stat64(infilename, &statbuf); r = _stat64(infilename, &statbuf);
if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */ if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */
#elif defined(__MINGW32__) && defined (__MSVCRT__) #elif defined(__MINGW32__) && defined (__MSVCRT__)
@ -218,37 +235,6 @@ UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFi
} }
UTIL_STATIC int UTIL_doesFileExists(const char* infilename)
{
int r;
#if defined(_MSC_VER)
struct __stat64 statbuf;
r = _stat64(infilename, &statbuf);
if (r || !(statbuf.st_mode & S_IFREG)) return 0; /* No good... */
#else
struct stat statbuf;
r = stat(infilename, &statbuf);
if (r || !S_ISREG(statbuf.st_mode)) return 0; /* No good... */
#endif
return 1;
}
UTIL_STATIC U32 UTIL_isDirectory(const char* infilename)
{
int r;
#if defined(_MSC_VER)
struct __stat64 statbuf;
r = _stat64(infilename, &statbuf);
if (!r && (statbuf.st_mode & _S_IFDIR)) return 1;
#else
struct stat statbuf;
r = stat(infilename, &statbuf);
if (!r && S_ISDIR(statbuf.st_mode)) return 1;
#endif
return 0;
}
/* /*
* A modified version of realloc(). * A modified version of realloc().
* If UTIL_realloc() fails the original block is freed. * If UTIL_realloc() fails the original block is freed.

Binary file not shown.

Binary file not shown.

View File

@ -231,7 +231,7 @@ zstd-playTests: datagen
ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST) ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST)
test: test-zstd test-fullbench test-fuzzer test-zstream test-invalidDictionaries test-legacy test: test-zstd test-fullbench test-fuzzer test-zstream test-invalidDictionaries test-legacy
ifneq ($(QEMU_SYS),qemu-ppc64-static) ifeq ($(QEMU_SYS),)
test: test-pool test: test-pool
endif endif