diff --git a/Makefile b/Makefile index 11f461d..d1fedb7 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,16 @@ SUBDIRS := libhashset hashset -.PHONY: all clean +BUILD_ALL := $(patsubst %,build_rule\:%,$(SUBDIRS)) +CLEAN_ALL := $(patsubst %,clean_rule\:%,$(SUBDIRS)) -all: - for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir; done +.PHONY: all clean $(BUILD_ALL) $(CLEAN_ALL) -clean: - for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir clean; done +all: $(BUILD_ALL) + +clean: $(CLEAN_ALL) + +$(BUILD_ALL): + $(MAKE) -C $(patsubst build_rule:%,%,$@) + +$(CLEAN_ALL): + $(MAKE) -C $(patsubst clean_rule:%,%,$@) clean diff --git a/hashset/Makefile b/hashset/Makefile index 31223af..1da7b70 100644 --- a/hashset/Makefile +++ b/hashset/Makefile @@ -1,19 +1,24 @@ DUMPMACHINE := $(shell $(CC) -dumpmachine) +ifneq ($(SANITIZE_ADDRESS),1) + XCFLAGS = -O3 -DNDEBUG ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),) - XCFLAGS = -march=x86-64 -mtune=nocona -s + XCFLAGS += -march=x86-64 -mtune=nocona else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) - XCFLAGS = -march=pentiumpro -mtune=intel -s + XCFLAGS += -march=pentiumpro -mtune=intel +endif +else + XCFLAGS = -fsanitize=address -static-libasan -g endif -ifeq ($(OS),Windows_NT) +ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),) + EXE_SUFFIX := .exe ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) XCFLAGS += -Wl,--large-address-aware endif - EXE_SUFFIX := .exe endif -CFLAGS = -std=c99 -O3 -DNDEBUG -D_DEFAULT_SOURCE -Wpedantic -I../libhashset/include $(XCFLAGS) +CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -I../libhashset/include $(XCFLAGS) SRC_PATH := src BIN_PATH := bin diff --git a/hashset/src/main.c b/hashset/src/main.c index bdfc635..b3cb124 100644 --- a/hashset/src/main.c +++ b/hashset/src/main.c @@ -326,7 +326,7 @@ static int test_function_3(hash_set_t *const hash_set) /* TEST #4 */ /* ========================================================================= */ -#define LIMIT (UINT64_MAX >> 2) +#define LIMIT (((uint64_t)UINT32_MAX) >> 2) static int test_function_4(hash_set_t *const hash_set) { diff --git a/libhashset/Makefile b/libhashset/Makefile index 54c5083..10a8ae9 100644 --- a/libhashset/Makefile +++ b/libhashset/Makefile @@ -1,12 +1,17 @@ DUMPMACHINE := $(shell $(CC) -dumpmachine) +ifneq ($(SANITIZE_ADDRESS),1) + XCFLAGS = -O3 -DNDEBUG ifneq ($(firstword $(filter x86_64-%,$(DUMPMACHINE))),) - XCFLAGS = -march=x86-64 -mtune=nocona + XCFLAGS += -march=x86-64 -mtune=nocona else ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) - XCFLAGS = -march=pentiumpro -mtune=intel + XCFLAGS += -march=pentiumpro -mtune=intel +endif +else + XCFLAGS = -fsanitize=address -static-libasan -g endif -CFLAGS = -std=c99 -O3 -DNDEBUG -Wpedantic -Iinclude $(XCFLAGS) +CFLAGS = -std=c99 -D_DEFAULT_SOURCE -Wpedantic -Iinclude $(XCFLAGS) SRC_PATH := src OBJ_PATH := obj