mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Adding isAligned impl for numeric types
Supports numeric types (e.g. size_t) Supports constexpr evaluation Change-Id: I6942bdaa12c39df95dcdee84e5d5851c9ec89be8
This commit is contained in:
@ -93,9 +93,13 @@ inline size_t alignSizeWholePage(const void *ptr, size_t size) {
|
||||
}
|
||||
|
||||
template <size_t alignment, typename T>
|
||||
inline bool isAligned(T ptr) {
|
||||
auto p = (uintptr_t)ptr;
|
||||
return (p % alignment) == 0;
|
||||
inline constexpr bool isAligned(T val) {
|
||||
return (static_cast<size_t>(val) % alignment) == 0;
|
||||
}
|
||||
|
||||
template <size_t alignment, typename T>
|
||||
inline bool isAligned(T *ptr) {
|
||||
return ((reinterpret_cast<uintptr_t>(ptr)) % alignment) == 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Reference in New Issue
Block a user