refactor(memory): make the Align function use the maximum integer uint64
This commit is contained in:
parent
6b63436d41
commit
b3a97cfe21
@ -12,25 +12,25 @@ NAMESPACE_BEGIN(Memory)
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
FORCEINLINE constexpr T Align(T InValue, size_t Alignment)
|
||||
{
|
||||
return (T)(((uintptr)(InValue) + static_cast<uintptr>(Alignment) - 1) & ~(static_cast<uintptr>(Alignment) - 1));
|
||||
return (T)(((uint64)(InValue) + static_cast<uint64>(Alignment) - 1) & ~(static_cast<uint64>(Alignment) - 1));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
FORCEINLINE constexpr T AlignDown(T InValue, size_t Alignment)
|
||||
{
|
||||
return (T)((uintptr)(InValue) & ~(static_cast<uintptr>(Alignment) - 1));
|
||||
return (T)((uint64)(InValue) & ~(static_cast<uint64>(Alignment) - 1));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
FORCEINLINE constexpr T AlignArbitrary(T InValue, size_t Alignment)
|
||||
{
|
||||
return (T)((((uintptr)(InValue) + static_cast<uintptr>(Alignment) - 1) / static_cast<uintptr>(Alignment)) * static_cast<uintptr>(Alignment));
|
||||
return (T)((((uint64)(InValue) + static_cast<uint64>(Alignment) - 1) / static_cast<uint64>(Alignment)) * static_cast<uint64>(Alignment));
|
||||
}
|
||||
|
||||
template <typename T> requires TIsIntegral<T>::Value || TIsPointer<T>::Value
|
||||
FORCEINLINE constexpr bool IsAligned(T InValue, size_t Alignment)
|
||||
{
|
||||
return !((uintptr)(InValue) & (static_cast<uintptr>(Alignment) - 1));
|
||||
return !((uint64)(InValue) & (static_cast<uint64>(Alignment) - 1));
|
||||
}
|
||||
|
||||
NAMESPACE_END(Memory)
|
||||
|
Loading…
Reference in New Issue
Block a user