From 5cc3efc2a5309b0047a80c9eff4675d38a11201d Mon Sep 17 00:00:00 2001 From: "yann.collet.73@gmail.com" Date: Sat, 3 Nov 2012 21:04:19 +0000 Subject: Corrected issue 38 : bench.c compilation for Sun Solaris 32 bits Corrected issue 40 : Detect early ending of compressed stream. Thanks Adrian Grand. Corrected issue 41 : minor comment editing on lz4.h git-svn-id: https://lz4.googlecode.com/svn/trunk@82 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- bench.c | 13 +++++++++---- lz4.c | 8 ++++---- lz4.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/bench.c b/bench.c index a48029d..b0a0ecb 100644 --- a/bench.c +++ b/bench.c @@ -29,10 +29,15 @@ #define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_DEPRECATE // VS2005 -// Under Linux at least, pull in the *64 commands -#define _LARGEFILE64_SOURCE +// Unix Large Files support (>4GB) +#if (defined(__sun__) && (!defined(__LP64__))) // Sun Solaris 32-bits requires specific definitions +# define _LARGEFILE_SOURCE +# define FILE_OFFSET_BITS=64 +#else +# define _LARGEFILE64_SOURCE +#endif -// MSVC does not support S_ISREG +// S_ISREG & gettimeofday() are not supported by MSVC #if defined(_MSC_VER) # define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) # define BMK_LEGACY_TIMER 1 @@ -40,7 +45,7 @@ // GCC does not support _rotl outside of Windows #if !defined(_WIN32) -#define _rotl(x,r) ((x << r) | (x >> (32 - r))) +# define _rotl(x,r) ((x << r) | (x >> (32 - r))) #endif diff --git a/lz4.c b/lz4.c index 18c4604..3e472a4 100644 --- a/lz4.c +++ b/lz4.c @@ -719,10 +719,10 @@ int LZ4_uncompress(const char* source, cpy = op+length; if unlikely(cpy>oend-COPYLENGTH) { - if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer + if (cpy != oend) goto _output_error; // Error : we must necessarily stand at EOF memcpy(op, ip, length); ip += length; - break; // Necessarily EOF + break; // EOF } LZ4_WILDCOPY(ip, op, cpy); ip -= (op-cpy); op = cpy; @@ -805,13 +805,13 @@ int LZ4_uncompress_unknownOutputSize( cpy = op+length; if ((cpy>oend-COPYLENGTH) || (ip+length>iend-COPYLENGTH)) { - if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer + if (cpy != oend) goto _output_error; // Error : we must necessarily stand at EOF if (ip+length > iend) goto _output_error; // Error : request to read beyond source buffer memcpy(op, ip, length); op += length; ip += length; if (ip