mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 21:42:53 +08:00
Fix unmap unalignment part at end of mmap allocation
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7e9461ffa0
commit
2eaf830aff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -21,6 +21,7 @@ off_t lseekReturn = 4096u;
|
||||
std::atomic<int> lseekCalledCount(0);
|
||||
int closeInputFd = 0;
|
||||
std::atomic<int> closeCalledCount(0);
|
||||
StackVec<void *, 10> mmapVector;
|
||||
|
||||
TestedDrmMemoryManager::TestedDrmMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(gemCloseWorkerMode::gemCloseWorkerInactive,
|
||||
false,
|
||||
|
||||
@@ -17,6 +17,7 @@ extern off_t lseekReturn;
|
||||
extern std::atomic<int> lseekCalledCount;
|
||||
extern int closeInputFd;
|
||||
extern std::atomic<int> closeCalledCount;
|
||||
extern StackVec<void *, 10> mmapVector;
|
||||
|
||||
inline void *mmapMock(void *addr, size_t length, int prot, int flags, int fd, off_t offset) noexcept {
|
||||
if (addr) {
|
||||
@@ -25,13 +26,17 @@ inline void *mmapMock(void *addr, size_t length, int prot, int flags, int fd, of
|
||||
void *ptr = nullptr;
|
||||
if (length > 0) {
|
||||
ptr = alignedMalloc(length, MemoryConstants::pageSize64k);
|
||||
mmapVector.push_back(ptr);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline int munmapMock(void *addr, size_t length) noexcept {
|
||||
if (length > 0) {
|
||||
alignedFree(addr);
|
||||
auto ptrIt = std::find(mmapVector.begin(), mmapVector.end(), addr);
|
||||
if (ptrIt != mmapVector.end()) {
|
||||
alignedFree(addr);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user