summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-11-17 21:02:06 (GMT)
committerYann Collet <cyan@fb.com>2016-11-17 21:02:06 (GMT)
commit1abecbc33c8ec5b84d2623dcbe73136aeb99db37 (patch)
tree398361394772160cd31cbc2b496d4814484fcb10 /programs/lz4io.c
parent7fde7438d39f8452f89e3fee5ba4a16c502dffb0 (diff)
downloadlz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.zip
lz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.tar.gz
lz4-1abecbc33c8ec5b84d2623dcbe73136aeb99db37.tar.bz2
fix 32-bits mode.
Large File support for Mac OS-X in 32-bits mode Fixed potential undefined behavior Changed makefile for 32-bits mode
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 4d076a9..e8eaf60 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -34,6 +34,8 @@
* Compiler Options
**************************************/
#define _LARGE_FILES /* Large file support on 32-bits AIX */
+#define _FILE_OFFSET_BITS 64 /* off_t width */
+#define _LARGEFILE_SOURCE
#if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
# define _POSIX_SOURCE 1 /* disable %llu warnings with MinGW on Windows */
@@ -74,6 +76,9 @@
# define SET_SPARSE_FILE_MODE(file)
# endif
#else
+# if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(__APPLE__) && defined(__MACH__))
+# define fseek fseeko
+# endif
# define SET_BINARY_MODE(file)
# define SET_SPARSE_FILE_MODE(file)
#endif
@@ -103,9 +108,6 @@
#define MIN_STREAM_BUFSIZE (192 KB)
#define LZ4IO_BLOCKSIZEID_DEFAULT 7
-#define sizeT sizeof(size_t)
-#define maskT (sizeT - 1)
-
/**************************************
* Macros
@@ -623,11 +625,14 @@ static unsigned LZ4IO_readLE32 (const void* s)
return value32;
}
+#define sizeT sizeof(size_t)
+#define maskT (sizeT - 1)
+
static unsigned LZ4IO_fwriteSparse(FILE* file, const void* buffer, size_t bufferSize, unsigned storedSkips)
{
const size_t* const bufferT = (const size_t*)buffer; /* Buffer is supposed malloc'ed, hence aligned on size_t */
const size_t* ptrT = bufferT;
- size_t bufferSizeT = bufferSize / sizeT;
+ size_t bufferSizeT = bufferSize / sizeT;
const size_t* const bufferTEnd = bufferT + bufferSizeT;
static const size_t segmentSizeT = (32 KB) / sizeT;
@@ -716,11 +721,11 @@ static unsigned long long LZ4IO_decodeLegacyStream(FILE* finput, FILE* foutput)
unsigned int blockSize;
/* Block Size */
- { size_t const sizeCheck = fread(in_buff, 1, 4, finput);
- if (sizeCheck == 0) break; /* Nothing to read : file read is completed */
- if (sizeCheck != 4) EXM_THROW(52, "Read error : cannot access block size "); }
- blockSize = LZ4IO_readLE32(in_buff); /* Convert to Little Endian */
- if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) {
+ { size_t const sizeCheck = fread(in_buff, 1, 4, finput);
+ if (sizeCheck == 0) break; /* Nothing to read : file read is completed */
+ if (sizeCheck != 4) EXM_THROW(52, "Read error : cannot access block size "); }
+ blockSize = LZ4IO_readLE32(in_buff); /* Convert to Little Endian */
+ if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) {
/* Cannot read next block : maybe new stream ? */
g_magicRead = blockSize;
break;