all: minor cleanups

This commit is contained in:
Markus F.X.J. Oberhumer
2024-07-10 10:34:58 +02:00
parent 16c8f6d160
commit 043a54cf3e
11 changed files with 94 additions and 43 deletions
+4
View File
@@ -110,6 +110,10 @@ forceinline bool ptr_is_aligned(const void *p) noexcept {
static_assert(upx::has_single_bit(Alignment));
return (ptr_get_address(p) & (Alignment - 1)) == 0;
}
forceinline bool ptr_is_aligned(const void *p, size_t alignment) noexcept {
assert_noexcept(upx::has_single_bit(alignment));
return (ptr_get_address(p) & (alignment - 1)) == 0;
}
// ptrdiff_t with nullptr checks and asserted size; will throw on failure
// NOTE: returns size_in_bytes, not number of elements!