src: introduce ptr_get_address()

This commit is contained in:
Markus F.X.J. Oberhumer
2024-05-11 17:37:15 +02:00
parent 07b533f95b
commit cba44c45fc
8 changed files with 38 additions and 24 deletions
+3 -2
View File
@@ -76,9 +76,10 @@ void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_byte
xspan_fail_range_nullptr();
if very_unlikely (base == nullptr)
xspan_fail_range_nullbase();
#if defined(__SANITIZE_ADDRESS__)
#if defined(__SANITIZE_ADDRESS__) || 1
// info: pointers are out of range deliberately during internal doctest checks; see dt_xspan.cpp
const acc_intptr_t off = (acc_uintptr_t) ptr - (acc_uintptr_t) base;
ACC_COMPILE_TIME_ASSERT(sizeof(intptr_t) == sizeof(upx_ptraddr_t))
const intptr_t off = ptr_get_address(ptr) - ptr_get_address(base);
#else
const ptrdiff_t off = (const charptr) ptr - (const charptr) base;
#endif