all: more minor cleanups

This commit is contained in:
Markus F.X.J. Oberhumer
2023-11-26 18:30:47 +01:00
parent bf8dd31914
commit 3e70021406
10 changed files with 42 additions and 46 deletions
+11 -12
View File
@@ -18,7 +18,7 @@ endif
#
# NOTE that top-level Makefile .DEFAULT_GOAL is build/release
.DEFAULT_GOAL = build/debug
.DEFAULT_GOAL = build/all
build/debug: $(top_srcdir)/build/debug
build/release: $(top_srcdir)/build/release
@@ -33,15 +33,14 @@ debug: build/debug
release: build/release
all build/all: build/debug build/release
$(top_srcdir)/build/debug: PHONY
$(MAKE) -C $(top_srcdir) build/debug
$(top_srcdir)/build/release: PHONY
$(MAKE) -C $(top_srcdir) build/release
# actual rules - redirect to top-level
$(top_srcdir)/build/debug: PHONY; $(MAKE) -C $(top_srcdir) build/debug
$(top_srcdir)/build/release: PHONY; $(MAKE) -C $(top_srcdir) build/release
# convenience
CTEST = ctest
test: $(top_srcdir)/$(.DEFAULT_GOAL)
cd $(top_srcdir)/$(.DEFAULT_GOAL) && $(CTEST)
test:: $(top_srcdir)/build/debug PHONY; cd $< && $(CTEST)
test:: $(top_srcdir)/build/release PHONY; cd $< && $(CTEST)
#
# "make run-testsuite"
@@ -70,10 +69,10 @@ run-testsuite: run-testsuite-release
run-testsuite-%: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
run-testsuite-%: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite
run-testsuite-debug: export upx_exe := $(top_srcdir)/build/debug/upx
run-testsuite-debug: PHONY $(top_srcdir)/build/debug
run-testsuite-debug: $(top_srcdir)/build/debug PHONY
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
run-testsuite-release: export upx_exe := $(top_srcdir)/build/release/upx
run-testsuite-release: PHONY $(top_srcdir)/build/release
run-testsuite-release: $(top_srcdir)/build/release PHONY
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
endif
endif
@@ -83,9 +82,9 @@ endif
#
ifneq ($(wildcard /usr/bin/env),) # needs bash, perl, xargs, etc.
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir)
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/.git/.),)
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir)
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir)
endif
check-whitespace: PHONY; $(CHECK_WHITESPACE)
endif
@@ -102,7 +101,7 @@ CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmli
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
CLANG_FORMAT_FILES := $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES))
clang-format: PHONY $(CLANG_FORMAT_FILES)
clang-format: $(CLANG_FORMAT_FILES) PHONY
@echo "running upx-clang-format"
@$(top_srcdir)/misc/scripts/upx-clang-format.sh -i $(CLANG_FORMAT_FILES)
endif
+2 -4
View File
@@ -136,12 +136,10 @@ bool PackPs1::readBkupHeader() {
}
#define INIT_BH_BKUP(p, l) \
ACC_BLOCK_BEGIN \
{ \
do { \
(p)->id = '1'; \
(p)->len = l; \
} \
ACC_BLOCK_END
} while (0)
#define ADLER16(a) (((a) >> 16) ^ ((a) &0xffff))
void PackPs1::putBkupHeader(const byte *src, byte *dst, unsigned *len) {
+13 -13
View File
@@ -137,19 +137,19 @@ static noinline tribool try_can_unpack(PackerBase *pb, void *user) may_throw {
PackerBase *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const Options *o,
void *user) may_throw {
#define D(Klass) \
ACC_BLOCK_BEGIN \
COMPILE_TIME_ASSERT(std::is_nothrow_destructible_v<Klass>) \
auto pb = std::unique_ptr<PackerBase>(new Klass(f)); \
if (o->debug.debug_level) \
fprintf(stderr, "visitAllPackers: (ver=%d, fmt=%3d) %s\n", pb->getVersion(), \
pb->getFormat(), #Klass); \
pb->assertPacker(); \
tribool r = func(pb.get(), user); \
if (r) \
return pb.release(); /* success */ \
if (r.isThird()) \
return nullptr; /* stop and fail early */ \
ACC_BLOCK_END
do { \
COMPILE_TIME_ASSERT(std::is_nothrow_destructible_v<Klass>) \
auto pb = std::unique_ptr<PackerBase>(new Klass(f)); \
if (o->debug.debug_level) \
fprintf(stderr, "visitAllPackers: (ver=%d, fmt=%3d) %s\n", pb->getVersion(), \
pb->getFormat(), #Klass); \
pb->assertPacker(); \
tribool r = func(pb.get(), user); \
if (r) \
return pb.release(); /* success */ \
if (r.isThird()) \
return nullptr; /* stop and fail early */ \
} while (0)
// NOTE: order of tries is important !!!
+7 -7
View File
@@ -285,13 +285,13 @@ static void memswap_no_overlap(byte *a, byte *b, size_t n) {
#else // clang bug
upx_alignas_max byte tmp_buf[16];
#define SWAP(x) \
ACC_BLOCK_BEGIN \
upx_memcpy_inline(tmp_buf, a, x); \
upx_memcpy_inline(a, b, x); \
upx_memcpy_inline(b, tmp_buf, x); \
a += x; \
b += x; \
ACC_BLOCK_END
do { \
upx_memcpy_inline(tmp_buf, a, x); \
upx_memcpy_inline(a, b, x); \
upx_memcpy_inline(b, tmp_buf, x); \
a += x; \
b += x; \
} while (0)
for (; n >= 16; n -= 16)
SWAP(16);