CI updates
Some checks failed
CI / Rebuild stubs (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-22.04, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-24.04, true, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-13, g++-13, macos-14, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15-intel, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-15, g++-15, macos-26, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64, windows-11-arm, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64ec, windows-11-arm, true, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-amd64, windows-2022, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-i386, windows-2022, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-amd64, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-i386, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (-arm64EC, /machine:arm64ec, arm64ec-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (amd64-win64-vs2025, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (arm64-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (i386-win32-vs2025, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.17) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-aarch64, -fPIE, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-x86_64, -fPIE, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (i386-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-aarch64, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-arm, arm-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-armeb, armeb-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, -fPIE, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc, powerpc-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, -fPIE, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, -fPIE, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, -fPIE, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.17) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-windows-gnu) (push) Has been cancelled
Some checks failed
CI / Rebuild stubs (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-22.04, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-24.04, true, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-13, g++-13, macos-14, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15-intel, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-15, g++-15, macos-26, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64, windows-11-arm, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64ec, windows-11-arm, true, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-amd64, windows-2022, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-i386, windows-2022, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-amd64, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-i386, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (-arm64EC, /machine:arm64ec, arm64ec-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (amd64-win64-vs2025, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (arm64-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (i386-win32-vs2025, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.17) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-aarch64, -fPIE, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-x86_64, -fPIE, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (i386-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-aarch64, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-arm, arm-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-armeb, armeb-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, -fPIE, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc, powerpc-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, -fPIE, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, -fPIE, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, -fPIE, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.17) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-windows-gnu) (push) Has been cancelled
This commit is contained in:
parent
f3d4503e93
commit
d767332943
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -633,9 +633,9 @@ jobs:
|
|||||||
- { zig_target: x86_64-windows-gnu }
|
- { zig_target: x86_64-windows-gnu }
|
||||||
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
|
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ${{ matrix.container || 'alpine:3.22' }}
|
container: ${{ matrix.container || 'alpine:3.23' }}
|
||||||
env:
|
env:
|
||||||
container: ${{ matrix.container || 'alpine:3.22' }}
|
container: ${{ matrix.container || 'alpine:3.23' }}
|
||||||
UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: ''
|
UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: ''
|
||||||
# for zig-cc wrapper scripts (see below):
|
# for zig-cc wrapper scripts (see below):
|
||||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||||
|
|||||||
@ -1736,9 +1736,7 @@ PeFile::Resource::upx_rnode *PeFile::Resource::convert(const void *rnode, upx_rn
|
|||||||
branch->name = nullptr;
|
branch->name = nullptr;
|
||||||
branch->parent = parent;
|
branch->parent = parent;
|
||||||
branch->nc = ic;
|
branch->nc = ic;
|
||||||
branch->children = New(upx_rnode *, ic);
|
branch->children = New0(upx_rnode *, ic);
|
||||||
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
|
|
||||||
memset(branch->children, 0, sizeof(upx_rnode *) * ic);
|
|
||||||
branch->data = *node;
|
branch->data = *node;
|
||||||
if (!root) // first one
|
if (!root) // first one
|
||||||
root = branch; // prevent leak if xcheck throws (hacked unpack or test)
|
root = branch; // prevent leak if xcheck throws (hacked unpack or test)
|
||||||
|
|||||||
@ -623,10 +623,10 @@ struct TriBool final {
|
|||||||
static constexpr bool is_third_true = IsThirdTrue;
|
static constexpr bool is_third_true = IsThirdTrue;
|
||||||
// types
|
// types
|
||||||
typedef T underlying_type;
|
typedef T underlying_type;
|
||||||
static_assert(std::is_integral_v<underlying_type>);
|
|
||||||
typedef decltype(T(0) + T(0)) promoted_type;
|
typedef decltype(T(0) + T(0)) promoted_type;
|
||||||
static_assert(std::is_integral_v<promoted_type>);
|
|
||||||
enum value_type : underlying_type { False = 0, True = 1, Third = 2 };
|
enum value_type : underlying_type { False = 0, True = 1, Third = 2 };
|
||||||
|
static_assert(std::is_integral_v<underlying_type>);
|
||||||
|
static_assert(std::is_integral_v<promoted_type>);
|
||||||
static_assert(sizeof(value_type) == sizeof(underlying_type));
|
static_assert(sizeof(value_type) == sizeof(underlying_type));
|
||||||
static_assert(sizeof(underlying_type) <= sizeof(promoted_type));
|
static_assert(sizeof(underlying_type) <= sizeof(promoted_type));
|
||||||
// constructors
|
// constructors
|
||||||
|
|||||||
@ -71,7 +71,7 @@ bool mem_size_valid(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extr
|
|||||||
}
|
}
|
||||||
|
|
||||||
upx_rsize_t mem_size(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extra1,
|
upx_rsize_t mem_size(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extra1,
|
||||||
upx_uint64_t extra2) {
|
upx_uint64_t extra2) may_throw {
|
||||||
assert(element_size > 0);
|
assert(element_size > 0);
|
||||||
if very_unlikely (element_size == 0 || element_size > UPX_RSIZE_MAX)
|
if very_unlikely (element_size == 0 || element_size > UPX_RSIZE_MAX)
|
||||||
throwCantPack("mem_size 1; take care");
|
throwCantPack("mem_size 1; take care");
|
||||||
@ -144,7 +144,8 @@ TEST_CASE("ptr_diff") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check that 2 buffers do not overlap; will throw on error
|
// check that 2 buffers do not overlap; will throw on error
|
||||||
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size) {
|
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size)
|
||||||
|
may_throw {
|
||||||
if very_unlikely (a == 0 || b == 0)
|
if very_unlikely (a == 0 || b == 0)
|
||||||
throwCantPack("ptr_check_no_overlap-nullptr");
|
throwCantPack("ptr_check_no_overlap-nullptr");
|
||||||
upx_ptraddr_t a_end = a + mem_size(1, a_size);
|
upx_ptraddr_t a_end = a + mem_size(1, a_size);
|
||||||
@ -160,7 +161,7 @@ void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, s
|
|||||||
|
|
||||||
// check that 3 buffers do not overlap; will throw on error
|
// check that 3 buffers do not overlap; will throw on error
|
||||||
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size,
|
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size,
|
||||||
upx_ptraddr_t c, size_t c_size) {
|
upx_ptraddr_t c, size_t c_size) may_throw {
|
||||||
if very_unlikely (a == 0 || b == 0 || c == 0)
|
if very_unlikely (a == 0 || b == 0 || c == 0)
|
||||||
throwCantPack("ptr_check_no_overlap-nullptr");
|
throwCantPack("ptr_check_no_overlap-nullptr");
|
||||||
upx_ptraddr_t a_end = a + mem_size(1, a_size);
|
upx_ptraddr_t a_end = a + mem_size(1, a_size);
|
||||||
@ -253,6 +254,14 @@ TEST_CASE("ptr_check_no_overlap 3") {
|
|||||||
// stdlib
|
// stdlib
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
void *upx_calloc(size_t n, size_t element_size) may_throw {
|
||||||
|
const upx_rsize_t bytes = mem_size(element_size, n); // assert size
|
||||||
|
void *p = ::malloc(bytes);
|
||||||
|
if (p != nullptr && bytes > 0)
|
||||||
|
memset(p, 0, bytes);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
const char *upx_getenv(const char *envvar) noexcept {
|
const char *upx_getenv(const char *envvar) noexcept {
|
||||||
if (envvar != nullptr && envvar[0])
|
if (envvar != nullptr && envvar[0])
|
||||||
return ::getenv(envvar);
|
return ::getenv(envvar);
|
||||||
@ -282,14 +291,6 @@ void upx_rand_init() noexcept {
|
|||||||
::srand(seed);
|
::srand(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *upx_calloc(size_t n, size_t element_size) may_throw {
|
|
||||||
size_t bytes = mem_size(element_size, n); // assert size
|
|
||||||
void *p = ::malloc(bytes);
|
|
||||||
if (p != nullptr)
|
|
||||||
memset(p, 0, bytes);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
// simple unoptimized memswap()
|
// simple unoptimized memswap()
|
||||||
// TODO later: CHERI clang-14 bug/miscompilation with upx_memswap(); or
|
// TODO later: CHERI clang-14 bug/miscompilation with upx_memswap(); or
|
||||||
// maybe caused by tagged-memory issues ???
|
// maybe caused by tagged-memory issues ???
|
||||||
|
|||||||
@ -67,13 +67,12 @@ inline void mem_size_assert(upx_uint64_t element_size, upx_uint64_t n) may_throw
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "new" with asserted size; will throw on invalid size
|
// "new" with asserted size; will throw on invalid size
|
||||||
#if DEBUG
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T *NewArray(upx_uint64_t n) may_throw {
|
inline T *NewT(upx_uint64_t n) may_throw {
|
||||||
COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value)
|
COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value)
|
||||||
COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value)
|
COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value)
|
||||||
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value)
|
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value)
|
||||||
upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size
|
const upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size
|
||||||
T *array = new T[size_t(n)];
|
T *array = new T[size_t(n)];
|
||||||
#if !defined(__SANITIZE_MEMORY__)
|
#if !defined(__SANITIZE_MEMORY__)
|
||||||
if (array != nullptr && bytes > 0) {
|
if (array != nullptr && bytes > 0) {
|
||||||
@ -84,11 +83,25 @@ T *NewArray(upx_uint64_t n) may_throw {
|
|||||||
UNUSED(bytes);
|
UNUSED(bytes);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
#define New(type, n) (NewArray<type>((n)))
|
#if DEBUG || 1
|
||||||
|
#define New(type, n) (NewT<type>((n)))
|
||||||
#else
|
#else
|
||||||
#define New(type, n) new type[mem_size_get_n(sizeof(type), (n))]
|
#define New(type, n) new type[mem_size_get_n(sizeof(type), (n))]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T *New0T(upx_uint64_t n) may_throw {
|
||||||
|
COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value)
|
||||||
|
COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value)
|
||||||
|
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value)
|
||||||
|
const upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size
|
||||||
|
T *array = new T[size_t(n)];
|
||||||
|
if (array != nullptr && bytes > 0)
|
||||||
|
memset(array, 0, bytes); // NOLINT(bugprone-multi-level-implicit-pointer-conversion)
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
#define New0(type, n) (New0T<type>((n)))
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// ptr util
|
// ptr util
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user