diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19af28c2..aed3568c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ env: CMAKE_REQUIRED_QUIET: OFF DEBIAN_FRONTEND: noninteractive UPX_CMAKE_BUILD_FLAGS: --verbose - # 2023-07-20 - ZIG_DIST_VERSION: 0.11.0-dev.4059+17255bed4 + # 2023-07-24 + ZIG_DIST_VERSION: 0.11.0-dev.4195+7f3fdd2ff jobs: job-rebuild-and-verify-stubs: @@ -333,8 +333,8 @@ jobs: cat .GITREV.txt set /p GITREV=<.GITREV.txt set UPX_DEFS=-DUPX_CONFIG_DISABLE_WSTRICT=0 -DUPX_CONFIG_DISABLE_WERROR=0 -DWITH_BZIP2=0 -DWITH_ZSTD=0 - set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib set UPX_LIBS=%BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib + @rem set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\console\*.cpp %s%\filter\*.cpp %s%\util\*.cpp %RUN_CL% -J -O2 -W4 -WX -std:c++17 -Zc:__cplusplus -EHsc -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% %UPX_DEFS% -I%H%\vendor -Feupx.exe %sources% %UPX_LIBS% /link ${{ matrix.link_machine_flags }} setargv.obj - name: 'Make artifact' @@ -389,6 +389,7 @@ jobs: # { zig_target: aarch64-macos.12.0-none } # { zig_target: aarch64-macos.13.0-none } - { zig_target: aarch64-windows-gnu } + - { zig_target: arm-linux-musleabihf } # { zig_target: i386-linux-musl } - { zig_target: i386-windows-gnu } # { zig_target: mips-linux-musl } diff --git a/.github/workflows/weekly-ci-zigcc.yml b/.github/workflows/weekly-ci-zigcc.yml index fc0ea416..0652d746 100644 --- a/.github/workflows/weekly-ci-zigcc.yml +++ b/.github/workflows/weekly-ci-zigcc.yml @@ -8,8 +8,8 @@ on: env: CMAKE_REQUIRED_QUIET: OFF DEBIAN_FRONTEND: noninteractive - # 2023-07-20 - ZIG_DIST_VERSION: 0.11.0-dev.4059+17255bed4 + # 2023-07-24 + ZIG_DIST_VERSION: 0.11.0-dev.4195+7f3fdd2ff jobs: job-linux-zigcc: # uses cmake + make @@ -27,6 +27,7 @@ jobs: - { zig_target: aarch64-macos.12.0-none } - { zig_target: aarch64-macos.13.0-none } - { zig_target: aarch64-windows-gnu } + - { zig_target: arm-linux-musleabihf } - { zig_target: i386-linux-musl } - { zig_target: i386-windows-gnu } - { zig_target: mips-linux-musl } diff --git a/src/conf.h b/src/conf.h index bfef441a..cfd78120 100644 --- a/src/conf.h +++ b/src/conf.h @@ -386,31 +386,9 @@ struct UnsignedSizeOf { }; #define usizeof(expr) (UnsignedSizeOf::value) -// simple pointer type alias to explicitly mark ownership of objects; purely -// cosmetic to improve source code readability, no real functionality -#if 0 -#define OwningPointer(T) T * -#else -template using OwningPointer = T *; -#define OwningPointer(T) OwningPointer -#endif -template -inline void owner_delete(OwningPointer(T) (&object)) noexcept { - static_assert(std::is_class_v); - static_assert(std::is_nothrow_destructible_v); - delete object; - object = nullptr; -} -#if defined(__clang__) || __GNUC__ != 7 -template -inline void owner_delete(T (&array)[]) noexcept DELETED_FUNCTION; -#endif -template -inline void owner_delete(T (&array)[N]) noexcept DELETED_FUNCTION; - template inline void mem_clear(T *object) noexcept { - static_assert(std::is_class_v); + static_assert(std::is_class_v); // UPX convention static_assert(std::is_standard_layout_v); static_assert(std::is_trivially_copyable_v); constexpr size_t size = sizeof(*object); diff --git a/src/packer.cpp b/src/packer.cpp index daf70b8f..1bce1da9 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -48,6 +48,7 @@ Packer::~Packer() noexcept { // owner owner_delete(uip); owner_delete(linker); + assert_noexcept(linker == nullptr); // references bele = nullptr; fi = nullptr; diff --git a/src/util/util.h b/src/util/util.h index 3618a769..65b214a2 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -130,6 +130,70 @@ void upx_memswap(void *a, void *b, size_t n); void upx_stable_sort(void *array, size_t n, size_t element_size, int (*compare)(const void *, const void *)); +/************************************************************************* +// OwningPointer(T) +// simple pointer type alias to explicitly mark ownership of objects; purely +// cosmetic to improve source code readability, no real functionality +**************************************************************************/ + +#if 0 + +// this works +#define OwningPointer(T) T * + +#elif 1 + +// this also works +template +using OwningPointer = T *; +#define OwningPointer(T) OwningPointer + +#else + +// simple class with just a number of no-ops +template +struct OwningPointer { + static_assert(std::is_class_v); // UPX convention + typedef typename std::add_lvalue_reference::type reference; + typedef typename std::add_lvalue_reference::type const_reference; + typedef typename std::add_pointer::type pointer; + typedef typename std::add_pointer::type const_pointer; + pointer ptr; + inline OwningPointer(pointer p) noexcept : ptr(p) {} + inline operator pointer() noexcept { return ptr; } + inline operator const_pointer() const noexcept { return ptr; } + inline reference operator*() noexcept { return *ptr; } + inline const_reference operator*() const noexcept { return *ptr; } + inline pointer operator->() noexcept { return ptr; } + inline const_pointer operator->() const noexcept { return ptr; } +}; +// overload mem_clear() +template +inline void mem_clear(OwningPointer object) noexcept { + mem_clear((T *) object); +} +#define OwningPointer(T) OwningPointer + +#endif + +template +inline void owner_delete(OwningPointer(T)(&object)) noexcept { + static_assert(std::is_class_v); // UPX convention + static_assert(std::is_nothrow_destructible_v); + if (object != nullptr) { + delete (T *) object; + object = nullptr; + } +} + +// disable some overloads +#if defined(__clang__) || __GNUC__ != 7 +template +inline void owner_delete(T (&array)[]) noexcept DELETED_FUNCTION; +#endif +template +inline void owner_delete(T (&array)[N]) noexcept DELETED_FUNCTION; + /************************************************************************* // misc. support functions **************************************************************************/