mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 08:07:19 +08:00
fix: get right page size when malloc uses 0 alignment
Related-To: GSD-7103 Signed-off-by: Lu, Wenbin <wenbin.lu@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
739d181026
commit
67fa39c9a1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -25,6 +25,15 @@ constexpr inline TNoRef alignUp(T before, size_t alignment) {
|
||||
return (before + mask) & ~mask;
|
||||
}
|
||||
|
||||
template <typename T, typename TNoRef = typename std::remove_reference<T>::type>
|
||||
constexpr inline TNoRef alignUpNonZero(T before, size_t alignment) {
|
||||
if (before == 0) {
|
||||
return alignment;
|
||||
} else {
|
||||
return alignUp(before, alignment);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr inline T *alignUp(T *ptrBefore, size_t alignment) {
|
||||
return reinterpret_cast<T *>(alignUp(reinterpret_cast<uintptr_t>(ptrBefore), alignment));
|
||||
|
||||
Reference in New Issue
Block a user