summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc18
1 files changed, 7 insertions, 11 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
index 11b29c6e736..14a3c53a2db 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
@@ -274,20 +274,16 @@ void UnmapOrDieVmar(void *addr, uptr size, zx_handle_t target_vmar) {
DecreaseTotalMmap(size);
}
-void ReservedAddressRange::Unmap(uptr fixed_addr, uptr size) {
- uptr offset = fixed_addr - reinterpret_cast<uptr>(base_);
- uptr addr = reinterpret_cast<uptr>(base_) + offset;
- void *addr_as_void = reinterpret_cast<void *>(addr);
- uptr base_as_uptr = reinterpret_cast<uptr>(base_);
- // Only unmap at the beginning or end of the range.
- CHECK((addr_as_void == base_) || (addr + size == base_as_uptr + size_));
+void ReservedAddressRange::Unmap(uptr addr, uptr size) {
CHECK_LE(size, size_);
+ if (addr == reinterpret_cast<uptr>(base_))
+ // If we unmap the whole range, just null out the base.
+ base_ = (size == size_) ? nullptr : reinterpret_cast<void*>(addr + size);
+ else
+ CHECK_EQ(addr + size, reinterpret_cast<uptr>(base_) + size_);
+ size_ -= size;
UnmapOrDieVmar(reinterpret_cast<void *>(addr), size,
static_cast<zx_handle_t>(os_handle_));
- if (addr_as_void == base_) {
- base_ = reinterpret_cast<void *>(addr + size);
- }
- size_ = size_ - size;
}
// This should never be called.
OpenPOWER on IntegriCloud