Loading...
--- libmalloc/libmalloc-474.0.13/src/magazine_zone.h
+++ libmalloc/libmalloc-657.60.21/src/magazine_zone.h
@@ -23,6 +23,9 @@
#ifndef __MAGAZINE_ZONE_H
#define __MAGAZINE_ZONE_H
+
+#include <malloc/_ptrcheck.h>
+__ptrcheck_abi_assume_single()
/********************* DEFINITIONS ************************/
@@ -42,7 +45,7 @@
// In-place free list entry. Unlike the out-of-band entry, the in-place entries
// are stored at the start of the range that has been freed.
-typedef struct _inplace_free_entry_s *inplace_free_entry_t;
+typedef struct _inplace_free_entry_s * __single inplace_free_entry_t;
typedef struct {
void *ptr;
@@ -57,7 +60,7 @@
typedef struct _inplace_free_entry_s {
inplace_union previous;
inplace_union next;
-} inplace_free_entry_s, *inplace_free_entry_t;
+} inplace_free_entry_s, * __single inplace_free_entry_t;
#ifdef __LP64__
MALLOC_STATIC_ASSERT(sizeof(inplace_free_entry_s) == 16, "inplace free list must be 16-bytes long");
@@ -89,10 +92,6 @@
} tiny_free_list_t;
typedef unsigned int grain_t; // N.B. wide enough to index all free slots
-
-#define CHECK_REGIONS (1 << 31)
-#define DISABLE_ASLR (1 << 30)
-#define DISABLE_LARGE_ASLR (1 << 29)
#define MAX_RECORDER_BUFFER 256
@@ -190,12 +189,12 @@
* Beginning and end pointers for a region's heap.
*/
#define TINY_REGION_HEAP_BASE(region) ((void *)(((tiny_region_t)region)->blocks))
-#define TINY_REGION_HEAP_END(region) ((void *)(((uintptr_t)TINY_REGION_HEAP_BASE(region)) + TINY_HEAP_SIZE))
+#define TINY_REGION_HEAP_END(region) __unsafe_forge_single(void *, ((uintptr_t)TINY_REGION_HEAP_BASE(region)) + TINY_HEAP_SIZE)
/*
* Locate the region for a pointer known to be within a tiny region.
*/
-#define TINY_REGION_FOR_PTR(ptr) ((tiny_region_t)((uintptr_t)(ptr) & ~((1 << TINY_BLOCKS_ALIGN) - 1)))
+#define TINY_REGION_FOR_PTR(ptr) __unsafe_forge_single(tiny_region_t, (uintptr_t)(ptr) & ~((1 << TINY_BLOCKS_ALIGN) - 1))
/*
* Convert between byte and msize units.
@@ -420,7 +419,7 @@
/*
* Locate the heap base for a pointer known to be within a small region.
*/
-#define SMALL_REGION_FOR_PTR(ptr) ((small_region_t)((uintptr_t)(ptr) & ~((1 << SMALL_BLOCKS_ALIGN) - 1)))
+#define SMALL_REGION_FOR_PTR(ptr) __unsafe_forge_single(small_region_t, (uintptr_t)(ptr) & ~((1 << SMALL_BLOCKS_ALIGN) - 1))
#define SMALL_REGION_OFFSET_FOR_PTR(ptr) ((uintptr_t)(ptr) & ((1 << SMALL_BLOCKS_ALIGN) - 1))
/*
@@ -624,7 +623,7 @@
/*
* Locate the heap base for a pointer known to be within a medium region.
*/
-#define MEDIUM_REGION_FOR_PTR(ptr) ((void *)((uintptr_t)(ptr) & ~((1ull << MEDIUM_BLOCKS_ALIGN) - 1)))
+#define MEDIUM_REGION_FOR_PTR(ptr) __unsafe_forge_single(void *, (uintptr_t)(ptr) & ~((1ull << MEDIUM_BLOCKS_ALIGN) - 1))
#define MEDIUM_REGION_OFFSET_FOR_PTR(ptr) ((uintptr_t)(ptr) & ((1ull << MEDIUM_BLOCKS_ALIGN) - 1))
/*
@@ -786,7 +785,7 @@
// Take magazine_lock first, Depot lock when needed for recirc, then szone->{tiny,small}_regions_lock when needed for alloc
_malloc_lock_s magazine_lock MALLOC_CACHE_ALIGN;
// Protection for the crtical section that does allocate_pages outside the magazine_lock
- volatile boolean_t alloc_underway;
+ _malloc_lock_s magazine_alloc_lock;
// One element deep "death row", optimizes malloc/free/malloc for identical size.
void *mag_last_free;