[scudo] Pass MapPlatformData in more calls
Allow platforms to avoid looking up private data by providing private context
Differential Revision: https://reviews.llvm.org/D129237
GitOrigin-RevId: ff8c0e6eb5a820c012c9de81608648d3ffc78600
diff --git a/release.h b/release.h
index 293a8bc..9dad3c3 100644
--- a/release.h
+++ b/release.h
@@ -82,7 +82,7 @@
} else {
Buffer = reinterpret_cast<uptr *>(
map(nullptr, roundUpTo(BufferSize, getPageSizeCached()),
- "scudo:counters", MAP_ALLOWNOMEM));
+ "scudo:counters", MAP_ALLOWNOMEM, &MapData));
}
}
~PackedCounterArray() {
@@ -92,7 +92,7 @@
Mutex.unlock();
else
unmap(reinterpret_cast<void *>(Buffer),
- roundUpTo(BufferSize, getPageSizeCached()));
+ roundUpTo(BufferSize, getPageSizeCached()), 0, &MapData);
}
bool isAllocated() const { return !!Buffer; }
@@ -138,6 +138,7 @@
uptr SizePerRegion;
uptr BufferSize;
uptr *Buffer;
+ MapPlatformData MapData = {};
static HybridMutex Mutex;
static uptr StaticBuffer[StaticBufferCount];
diff --git a/vector.h b/vector.h
index eae774b..84e9c53 100644
--- a/vector.h
+++ b/vector.h
@@ -27,7 +27,7 @@
}
void destroy() {
if (Data != &LocalData[0])
- unmap(Data, CapacityBytes);
+ unmap(Data, CapacityBytes, 0, &MapData);
}
T &operator[](uptr I) {
DCHECK_LT(I, Size);
@@ -83,8 +83,8 @@
DCHECK_GT(NewCapacity, 0);
DCHECK_LE(Size, NewCapacity);
NewCapacity = roundUpTo(NewCapacity * sizeof(T), getPageSizeCached());
- T *NewData =
- reinterpret_cast<T *>(map(nullptr, NewCapacity, "scudo:vector"));
+ T *NewData = reinterpret_cast<T *>(
+ map(nullptr, NewCapacity, "scudo:vector", 0, &MapData));
memcpy(NewData, Data, Size * sizeof(T));
destroy();
Data = NewData;
@@ -95,6 +95,7 @@
T LocalData[256 / sizeof(T)] = {};
uptr CapacityBytes = 0;
uptr Size = 0;
+ MapPlatformData MapData = {};
};
template <typename T> class Vector : public VectorNoCtor<T> {