updated Makefile : lz4 no longer recompiled when already up-to-date
This commit is contained in:
parent
b41f9bb132
commit
19c0f21b00
2
NEWS
2
NEWS
@ -4,7 +4,7 @@ lz4cat : fix : works with relative path (#284) and stdin (#285) (reported by @be
|
||||
cli : fix minor notification when using -r recursive mode
|
||||
API : lz4frame : LZ4F_frameBound(0) gives upper bound of *flush() and *End() operations (#290, #280)
|
||||
doc : markdown version of man page, by Takayuki Matsuoka (#279)
|
||||
build : Makefile : fix make lib+exe concurrency (#277)
|
||||
build : Makefile : fix make -jX lib+exe concurrency (#277)
|
||||
|
||||
v1.7.4.2
|
||||
fix : Makefile : release build compatible with PIE and customized compilation directives provided through environment variables (#274, reported by Antoine Martin)
|
||||
|
35
lib/lz4opt.h
35
lib/lz4opt.h
@ -33,9 +33,9 @@
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
*/
|
||||
|
||||
#define LZ4_LOG_PARSER(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
#define LZ4_LOG_PRICE(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
#define LZ4_LOG_ENCODE(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
#define LZ4_LOG_PARSER(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
#define LZ4_LOG_PRICE(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
#define LZ4_LOG_ENCODE(fmt, ...) //printf(fmt, __VA_ARGS__)
|
||||
|
||||
|
||||
#define LZ4_OPT_NUM (1<<12)
|
||||
@ -56,23 +56,24 @@ typedef struct
|
||||
} LZ4HC_optimal_t;
|
||||
|
||||
|
||||
FORCE_INLINE size_t LZ4HC_GetLiteralsPrice(size_t litlen)
|
||||
/* price in bits */
|
||||
FORCE_INLINE size_t LZ4HC_literalsPrice(size_t litlen)
|
||||
{
|
||||
size_t price = 8*litlen;
|
||||
if (litlen >= (int)RUN_MASK) price+=8*(1+(litlen-RUN_MASK)/255);
|
||||
if (litlen >= (size_t)RUN_MASK) price+=8*(1+(litlen-RUN_MASK)/255);
|
||||
return price;
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE size_t LZ4HC_get_price(size_t litlen, size_t mlen)
|
||||
/* requires mlen >= MINMATCH */
|
||||
FORCE_INLINE size_t LZ4HC_sequencePrice(size_t litlen, size_t mlen)
|
||||
{
|
||||
size_t price = 16 + 8; /* 16-bit offset + token */
|
||||
|
||||
price += 8*litlen;
|
||||
if (litlen >= (int)RUN_MASK) price+=8*(1+(litlen-RUN_MASK)/255);
|
||||
price += LZ4HC_literalsPrice(litlen);
|
||||
|
||||
mlen -= MINMATCH;
|
||||
if (mlen >= (int)ML_MASK) price+=8*(1+(mlen-ML_MASK)/255);
|
||||
if (mlen >= (size_t)ML_MASK) price+=8*(1+(mlen-ML_MASK)/255);
|
||||
|
||||
return price;
|
||||
}
|
||||
@ -258,7 +259,7 @@ static int LZ4HC_compress_optimal (
|
||||
LZ4_LOG_PARSER("%d: start Found mlen=%d off=%d best_mlen=%d last_pos=%d\n", (int)(ip-source), matches[i].len, matches[i].off, best_mlen, last_pos);
|
||||
while (mlen <= best_mlen) {
|
||||
litlen = 0;
|
||||
price = LZ4HC_get_price(llen + litlen, mlen) - LZ4HC_GetLiteralsPrice(llen);
|
||||
price = LZ4HC_sequencePrice(llen + litlen, mlen) - LZ4HC_literalsPrice(llen);
|
||||
SET_PRICE(mlen, mlen, matches[i].off, litlen, price);
|
||||
mlen++;
|
||||
}
|
||||
@ -274,16 +275,16 @@ static int LZ4HC_compress_optimal (
|
||||
if (opt[cur-1].mlen == 1) {
|
||||
litlen = opt[cur-1].litlen + 1;
|
||||
if (cur != litlen) {
|
||||
price = opt[cur - litlen].price + LZ4HC_GetLiteralsPrice(litlen);
|
||||
price = opt[cur - litlen].price + LZ4HC_literalsPrice(litlen);
|
||||
LZ4_LOG_PRICE("%d: TRY1 opt[%d].price=%d price=%d cur=%d litlen=%d\n", (int)(inr-source), cur - litlen, opt[cur - litlen].price, price, cur, litlen);
|
||||
} else {
|
||||
price = LZ4HC_GetLiteralsPrice(llen + litlen) - LZ4HC_GetLiteralsPrice(llen);
|
||||
price = LZ4HC_literalsPrice(llen + litlen) - LZ4HC_literalsPrice(llen);
|
||||
LZ4_LOG_PRICE("%d: TRY2 price=%d cur=%d litlen=%d llen=%d\n", (int)(inr-source), price, cur, litlen, llen);
|
||||
}
|
||||
} else {
|
||||
litlen = 1;
|
||||
price = opt[cur - 1].price + LZ4HC_GetLiteralsPrice(litlen);
|
||||
LZ4_LOG_PRICE("%d: TRY3 price=%d cur=%d litlen=%d litonly=%d\n", (int)(inr-source), price, cur, litlen, LZ4HC_GetLiteralsPrice(litlen));
|
||||
price = opt[cur - 1].price + LZ4HC_literalsPrice(litlen);
|
||||
LZ4_LOG_PRICE("%d: TRY3 price=%d cur=%d litlen=%d litonly=%d\n", (int)(inr-source), price, cur, litlen, LZ4HC_literalsPrice(litlen));
|
||||
}
|
||||
|
||||
mlen = 1;
|
||||
@ -317,12 +318,12 @@ static int LZ4HC_compress_optimal (
|
||||
litlen = opt[cur2].litlen;
|
||||
|
||||
if (cur2 != litlen)
|
||||
price = opt[cur2 - litlen].price + LZ4HC_get_price(litlen, mlen);
|
||||
price = opt[cur2 - litlen].price + LZ4HC_sequencePrice(litlen, mlen);
|
||||
else
|
||||
price = LZ4HC_get_price(llen + litlen, mlen) - LZ4HC_GetLiteralsPrice(llen);
|
||||
price = LZ4HC_sequencePrice(llen + litlen, mlen) - LZ4HC_literalsPrice(llen);
|
||||
} else {
|
||||
litlen = 0;
|
||||
price = opt[cur2].price + LZ4HC_get_price(litlen, mlen);
|
||||
price = opt[cur2].price + LZ4HC_sequencePrice(litlen, mlen);
|
||||
}
|
||||
|
||||
LZ4_LOG_PARSER("%d: Found2 mlen=%d best_mlen=%d off=%d price=%d litlen=%d price[%d]=%d\n", (int)(inr-source), mlen, best_mlen, matches[i].off, price, litlen, cur - litlen, opt[cur - litlen].price);
|
||||
|
@ -43,7 +43,9 @@ PREFIX ?= /usr/local
|
||||
BINDIR := $(PREFIX)/bin
|
||||
MANDIR := $(PREFIX)/share/man/man1
|
||||
LZ4DIR := ../lib
|
||||
VOID := /dev/null
|
||||
|
||||
SRCFILES := $(wildcard $(LZ4DIR)/*.c) $(wildcard *.c)
|
||||
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
|
||||
|
||||
CPPFLAGS+= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
|
||||
CFLAGS ?= -O3
|
||||
@ -60,33 +62,36 @@ MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4
|
||||
|
||||
# Define *.exe as extension for Windows systems
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
EXT =.exe
|
||||
VOID := nul
|
||||
EXT :=.exe
|
||||
else
|
||||
EXT =
|
||||
VOID := /dev/null
|
||||
EXT :=
|
||||
endif
|
||||
|
||||
|
||||
|
||||
default: lz4-release
|
||||
|
||||
lz4-release: $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.o datagen.o
|
||||
$(CC) $(FLAGS) $^ -o lz4$(EXT)
|
||||
|
||||
all: lz4 lz4c
|
||||
|
||||
all32: CFLAGS+=-m32
|
||||
all32: all
|
||||
|
||||
lz4: CFLAGS += $(DEBUGFLAGS)
|
||||
lz4: lz4-release
|
||||
lz4: $(OBJFILES)
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||
|
||||
lz4c: CFLAGS += $(DEBUGFLAGS)
|
||||
lz4c : $(LZ4DIR)/lz4.o $(LZ4DIR)/lz4hc.o $(LZ4DIR)/lz4frame.o $(LZ4DIR)/xxhash.o bench.o lz4io.o lz4cli.c datagen.o
|
||||
lz4-release: DEBUGFLAGS=
|
||||
lz4-release: lz4
|
||||
|
||||
lz4c : CFLAGS += $(DEBUGFLAGS)
|
||||
lz4c : $(SRCFILES)
|
||||
$(CC) $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
|
||||
|
||||
lz4c32: CFLAGS+=-m32
|
||||
lz4c32: lz4
|
||||
@cp lz4$(EXT) lz4c32$(EXT)
|
||||
lz4c32: CFLAGS += -m32 $(DEBUGFLAGS)
|
||||
lz4c32: $(SRCFILES)
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
||||
|
||||
clean:
|
||||
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
|
||||
|
Loading…
Reference in New Issue
Block a user