Use uintptr_t instead of addr_t

They're never actually going to change independently, and it's also
brining in kutil headers more places than they should be.
This commit is contained in:
Justin C. Miller
2018-09-20 09:37:30 -07:00
parent a9d72b8102
commit cef0a71bce
20 changed files with 108 additions and 112 deletions

View File

@@ -4,8 +4,6 @@
#include <stdint.h>
using addr_t = uint64_t;
void * operator new (size_t, void *p) noexcept;
@@ -50,7 +48,7 @@ inline T read_from(const void *p)
template <typename T>
inline T * offset_pointer(T *p, ptrdiff_t n)
{
return reinterpret_cast<T *>(reinterpret_cast<addr_t>(p) + n);
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(p) + n);
}
/// Return a pointer with the given bits masked out
@@ -58,9 +56,9 @@ inline T * offset_pointer(T *p, ptrdiff_t n)
/// \arg mask A bitmask of bits to clear from p
/// \returns The masked pointer
template <typename T>
inline T* mask_pointer(T *p, addr_t mask)
inline T* mask_pointer(T *p, uintptr_t mask)
{
return reinterpret_cast<T *>(reinterpret_cast<addr_t>(p) & ~mask);
return reinterpret_cast<T *>(reinterpret_cast<uintptr_t>(p) & ~mask);
}
/// Do a simple byte-wise checksum of an area of memory.

View File

@@ -17,13 +17,13 @@ struct memory_manager::mem_header
inline void set_size(uint8_t size)
{
m_prev = reinterpret_cast<mem_header *>(
reinterpret_cast<addr_t>(prev()) | (size & 0x3f));
reinterpret_cast<uintptr_t>(prev()) | (size & 0x3f));
}
inline void set_used(bool used)
{
m_next = reinterpret_cast<mem_header *>(
reinterpret_cast<addr_t>(next()) | (used ? 1 : 0));
reinterpret_cast<uintptr_t>(next()) | (used ? 1 : 0));
}
inline void set_next(mem_header *next)
@@ -53,13 +53,13 @@ struct memory_manager::mem_header
inline mem_header * buddy() const {
return reinterpret_cast<mem_header *>(
reinterpret_cast<addr_t>(this) ^ (1 << size()));
reinterpret_cast<uintptr_t>(this) ^ (1 << size()));
}
inline bool eldest() const { return this < buddy(); }
inline uint8_t size() const { return reinterpret_cast<addr_t>(m_prev) & 0x3f; }
inline bool used() const { return reinterpret_cast<addr_t>(m_next) & 0x1; }
inline uint8_t size() const { return reinterpret_cast<uintptr_t>(m_prev) & 0x3f; }
inline bool used() const { return reinterpret_cast<uintptr_t>(m_next) & 0x1; }
private:
mem_header *m_prev;