summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2020-11-09 05:17:32 (GMT)
committerYann Collet <cyan@fb.com>2020-11-09 05:17:32 (GMT)
commit52646e8d7517b9b399d3e3719c65816afdc833ab (patch)
treea75a37e6fa5abbb87e721dbfa17755ac7984a9a8 /tests
parentbe634559e3b6bb7bce77cc83ec2080b2bfb6c844 (diff)
downloadlz4-52646e8d7517b9b399d3e3719c65816afdc833ab.zip
lz4-52646e8d7517b9b399d3e3719c65816afdc833ab.tar.gz
lz4-52646e8d7517b9b399d3e3719c65816afdc833ab.tar.bz2
first proposal for LZ4_USER_MEMORY_FUNCTIONS
makes it possible to replace at link time malloc, calloc and free by user-provided functions which must be named LZ4_malloc(), LZ4_calloc() and LZ4_free(). answer #937
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile9
-rw-r--r--tests/fullbench.c8
2 files changed, 14 insertions, 3 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 43c9651..476849e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -53,6 +53,7 @@ TEST_FILES := COPYING
FUZZER_TIME := -T90s
NB_LOOPS ?= -i1
+.PHONY: default
default: all
all: fullbench fuzzer frametest roundTripTest datagen checkFrame decompress-partial
@@ -89,6 +90,10 @@ fullbench-dll: fullbench.c $(LZ4DIR)/xxhash.c
$(MAKE) -C $(LZ4DIR) liblz4
$(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/$(LIBLZ4).dll
+# test LZ4_USER_MEMORY_FUNCTIONS
+fullbench-wmalloc: CPPFLAGS += -DLZ4_USER_MEMORY_FUNCTIONS
+fullbench-wmalloc: fullbench
+
fuzzer : lz4.o lz4hc.o xxhash.o fuzzer.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
@@ -107,6 +112,7 @@ checkFrame : lz4frame.o lz4.o lz4hc.o xxhash.o checkFrame.c
decompress-partial: lz4.o decompress-partial.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
+.PHONY: clean
clean:
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
@@ -170,9 +176,6 @@ test32: test
test-amalgamation: lz4_all.o
-lz4_all.o: lz4_all.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
-
lz4_all.c: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c
$(CAT) $^ > $@
diff --git a/tests/fullbench.c b/tests/fullbench.c
index 77f475b..0e3c009 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -156,6 +156,14 @@ static size_t BMK_findMaxMem(U64 requiredMem)
/*********************************************************
+* Memory management, to test LZ4_USER_MEMORY_FUNCTIONS
+*********************************************************/
+void* LZ4_malloc(size_t s) { return malloc(s); }
+void* LZ4_calloc(size_t s) { return calloc(1,s); }
+void LZ4_free(void* p) { return free(p); }
+
+
+/*********************************************************
* Benchmark function
*********************************************************/
static LZ4_stream_t LZ4_stream;