summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
Diffstat (limited to 'programs')
-rw-r--r--programs/Makefile26
-rw-r--r--programs/lz4io.c23
2 files changed, 28 insertions, 21 deletions
diff --git a/programs/Makefile b/programs/Makefile
index de18f78..2f1c3cc 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -29,18 +29,18 @@
DESTDIR ?=
PREFIX ?= /usr/local
-VOID := /dev/null
BINDIR := $(PREFIX)/bin
MANDIR := $(PREFIX)/share/man/man1
LZ4DIR := ../lib
+VOID := /dev/null
CFLAGS ?= -O3 # allows custom optimization flags. For example : CFLAGS="-O2 -g" make
-CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
+CFLAGS += -g -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
CPPFLAGS:= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
-FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
# Define *.exe as extension for Windows systems
@@ -52,27 +52,29 @@ endif
-default: lz4
+default: lz4-release
-m32: lz4c32
+all: lz4 lz4c
-native: lz4 lz4c
-
-all: native m32
+all32: CFLAGS+=-m32
+all32: all
lz4: $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.o datagen.o
$(CC) $(FLAGS) $^ -o $@$(EXT)
-lz4c : $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.o datagen.o
+lz4-release: CFLAGS := -O3
+lz4-release: lz4
+
+lz4c : $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.c datagen.o
$(CC) $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
-lz4c32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c datagen.c
- $(CC) -m32 $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
+lz4c32: CFLAGS += -m32
+lz4c32: lz4
clean:
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
@$(RM) core *.o *.test tmp* \
- lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \
+ lz4$(EXT) lz4c$(EXT)
@echo Cleaning completed
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;