Factor out freeing of stack buffer to ease testing
Bug: 378140560
Change-Id: I51f610be83512233f7e5e23483315c1ca4770d06
diff --git a/libc/platform/bionic/mte.h b/libc/platform/bionic/mte.h
index 98b3d27..d27f92b 100644
--- a/libc/platform/bionic/mte.h
+++ b/libc/platform/bionic/mte.h
@@ -86,6 +86,12 @@
return ptr | ((1ULL << size_cls) << 56ULL);
}
+inline void stack_mte_free_ringbuffer(uintptr_t stack_mte_tls) {
+ size_t size = stack_mte_ringbuffer_size_from_pointer(stack_mte_tls);
+ void* ptr = reinterpret_cast<void*>(stack_mte_tls & ((1ULL << 56ULL) - 1ULL));
+ munmap(ptr, size);
+}
+
inline void* stack_mte_ringbuffer_allocate(size_t n, const char* name) {
if (n > 7) return nullptr;
// Allocation needs to be aligned to 2*size to make the fancy code-gen work.