22static inline uintptr_t GetAddrNum(
const void *p) {
23 return reinterpret_cast<uintptr_t
>(p);
26static inline void *GetAddrPtr(uintptr_t n) {
27 return reinterpret_cast<void *
>(n);
30static inline void *AddOffset(
const void *p,
size_t offset) {
31 return GetAddrPtr(GetAddrNum(p) + offset);
34static inline void *SubOffset(
const void *p,
size_t offset) {
35 return GetAddrPtr(GetAddrNum(p) - offset);
38static inline uintptr_t RoundUp(uintptr_t value, uintptr_t alignment) {
39 return (value + alignment - 1) & ~(alignment - 1);
42static inline void *RoundUp(
void *ptr, uintptr_t alignment) {
43 return GetAddrPtr(RoundUp(GetAddrNum(ptr), alignment));
46static inline uintptr_t RoundDown(uintptr_t value, uintptr_t alignment) {
47 return value & ~(alignment - 1);
50static inline void *RoundDown(
void *ptr, uintptr_t alignment) {
51 return GetAddrPtr(RoundDown(GetAddrNum(ptr), alignment));