Loading...
--- libmalloc/libmalloc-792.60.6/src/internal.h
+++ libmalloc/libmalloc-521.120.7/src/internal.h
@@ -93,7 +93,6 @@
 	uint64_t opaque[2];
 } plat_map_exclaves_t;
 #if !MALLOC_TARGET_EXCLAVES
-# include <mach/error.h>
 # include <mach/mach.h>
 # include <mach/mach_init.h>
 # include <mach/mach_time.h>
@@ -105,7 +104,6 @@
 # include <mach/vm_page_size.h>
 # include <mach/vm_param.h>
 # include <mach/vm_reclaim.h>
-# include <mach/vm_reclaim_private.h>
 # include <mach/vm_statistics.h>
 # include <machine/cpu_capabilities.h>
 
@@ -126,7 +124,6 @@
 # define vm_page_size PAGE_SIZE
 # define PAGE_MASK (PAGE_SIZE-1)
 
-typedef uint64_t mach_vm_reclaim_id_t;
 # define mach_vm_round_page(x) (((mach_vm_offset_t)(x) + PAGE_MASK) & ~((signed)PAGE_MASK))
 # define round_page(x) (((vm_offset_t)(x) + PAGE_MASK) & ~((vm_offset_t)PAGE_MASK))
 
@@ -156,7 +153,6 @@
 # include <os/crashlog_private.h>
 # include <os/lock_private.h>
 # include <os/once_private.h>
-# include <os/security_config_private.h>
 #else
 # include <_liblibc/_error.h>
 #endif // !MALLOC_TARGET_EXCLAVES
@@ -174,7 +170,6 @@
 # include <pthread/private.h>  // _pthread_threadid_self_np_direct()
 # include <pthread/tsd_private.h>  // TSD keys
 #else
-# include <platform/platform.h>
 # include <pthread.h>
 #endif // !MALLOC_TARGET_EXCLAVES
 
@@ -210,13 +205,11 @@
 #include <sys/mman.h>
 #include <sys/queue.h>
 #if !MALLOC_TARGET_EXCLAVES
-# include <sys/codesign.h>
 # include <sys/event.h>
 # include <sys/param.h>
 # include <sys/stat.h>
 # include <sys/sysctl.h>
 # include <sys/random.h>
-# include <sys/csr.h>
 #else
 # include <vas/vas.h>
 # define howmany(x, y)   ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1))
@@ -237,16 +230,12 @@
 #endif // !MALLOC_TARGET_EXCLAVES
 
 #if !MALLOC_TARGET_EXCLAVES
-#include <corecrypto/ccsha2.h>
-#endif
-
-#if !MALLOC_TARGET_EXCLAVES
 // pthread reserves 5 TSD keys for libmalloc
 # define __TSD_MALLOC_PROB_GUARD_SAMPLE_COUNTER __PTK_LIBMALLOC_KEY0
 # define __TSD_MALLOC_ZERO_CORRUPTION_COUNTER   __PTK_LIBMALLOC_KEY1
 # define __TSD_MALLOC_THREAD_OPTIONS            __PTK_LIBMALLOC_KEY2
 # define __TSD_MALLOC_TYPE_DESCRIPTOR           __PTK_LIBMALLOC_KEY3
-# define __TSD_MALLOC_XZONE_THREAD_CACHE        __PTK_LIBMALLOC_KEY4
+# define __TSD_MALLOC_UNUSED4                   __PTK_LIBMALLOC_KEY4
 #else
 # include "liblibc_overrides.h"
 # define __TSD_MALLOC_TYPE_DESCRIPTOR           __LIBLIBC_XZONE_TSS_KEY
@@ -267,8 +256,8 @@
 #endif // !MALLOC_TARGET_EXCLAVES
 #include "malloc/malloc.h"
 #include "early_malloc.h"
-#include "instrumentation.h"
-#if !MALLOC_TARGET_EXCLAVES
+#if !MALLOC_TARGET_EXCLAVES
+# include "instrumentation.h"
 # include "frozen_malloc.h"
 # include "legacy_malloc.h"
 # include "magazine_malloc.h"
@@ -297,10 +286,10 @@
 # include "nanov2_zone.h"
 # include "magazine_inline.h"
 #endif // !MALLOC_TARGET_EXCLAVES && MALLOC_TARGET_EXCLAVES_INTROSPECTOR
-#include "xzone_malloc/xzone_introspect.h"
-#include "xzone_malloc/xzone_malloc.h"
+#include "xzone/xzone_introspect.h"
+#include "xzone/xzone_malloc.h"
 #if !(MALLOC_TARGET_EXCLAVES_INTROSPECTOR && defined(__x86_64__))
-# include "xzone_malloc/xzone_inline_internal.h"
+# include "xzone/xzone_inline_internal.h"
 #endif // !(MALLOC_TARGET_EXCLAVES_INTROSPECTOR && defined(__x86_64__))
 #if !MALLOC_TARGET_EXCLAVES
 # include "stack_logging.h"
@@ -314,11 +303,11 @@
  *  - freed pages are not aggressively madvised by default
  *  - the large cache is enabled (and not enrolled in deferred reclamation)
  */
-#if CONFIG_MADVISE_PRESSURE_RELIEF || (CONFIG_LARGE_CACHE && !CONFIG_MAGAZINE_DEFERRED_RECLAIM)
+#if CONFIG_MADVISE_PRESSURE_RELIEF || (CONFIG_LARGE_CACHE && !CONFIG_DEFERRED_RECLAIM)
 #define MALLOC_MEMORYSTATUS_MASK_PRESSURE_RELIEF ( \
 		NOTE_MEMORYSTATUS_PRESSURE_WARN | \
 		NOTE_MEMORYSTATUS_PRESSURE_NORMAL)
-#else /* CONFIG_MADVISE_PRESSURE_RELIEF || (CONFIG_LARGE_CACHE && !CONFIG_MAGAZINE_DEFERRED_RECLAIM) */
+#else /* CONFIG_MADVISE_PRESSURE_RELIEF || (CONFIG_LARGE_CACHE && !CONFIG_DEFERRED_RECLAIM) */
 #define MALLOC_MEMORYSTATUS_MASK_PRESSURE_RELIEF 0
 #endif
 
@@ -326,10 +315,14 @@
  * Resource Exception Reports are generated on process limits and
  * system-critical memory pressure.
  */
+#if ENABLE_MEMORY_RESOURCE_EXCEPTION_HANDLING
 #define MALLOC_MEMORYSTATUS_MASK_RESOURCE_EXCEPTION_HANDLING ( \
 		NOTE_MEMORYSTATUS_PROC_LIMIT_WARN | \
 		NOTE_MEMORYSTATUS_PROC_LIMIT_CRITICAL | \
 		NOTE_MEMORYSTATUS_PRESSURE_CRITICAL )
+#else /* ENABLE_MEMORY_RESOURCE_EXCEPTION_HANDLING */
+#define MALLOC_MEMORYSTATUS_MASK_RESOURCE_EXCEPTION_HANDLING 0
+#endif
 
 /* MallocStackLogging.framework notification dependencies */
 #define MSL_MEMORYPRESSURE_MASK ( NOTE_MEMORYSTATUS_PROC_LIMIT_WARN | \
@@ -349,7 +342,8 @@
  * the `_MSL` mask.
  */
 #define MALLOC_MEMORYPRESSURE_MASK_DEFAULT ( NOTE_MEMORYSTATUS_MSL_STATUS | \
-		MALLOC_MEMORYSTATUS_MASK_PRESSURE_RELIEF )
+		MALLOC_MEMORYSTATUS_MASK_PRESSURE_RELIEF | \
+		MALLOC_MEMORYSTATUS_MASK_RESOURCE_EXCEPTION_HANDLING )
 #define MALLOC_MEMORYPRESSURE_MASK_MSL ( MALLOC_MEMORYPRESSURE_MASK_DEFAULT | \
 		MSL_MEMORYPRESSURE_MASK )
 
@@ -382,20 +376,6 @@
 MALLOC_NOEXPORT
 extern bool malloc_sanitizer_enabled;
 
-#if CONFIG_MTE
-
-MALLOC_NOEXPORT
-extern bool malloc_has_sec_transition;
-
-MALLOC_NOEXPORT
-extern uint32_t malloc_sec_transition_policy;
-
-#if !MALLOC_TARGET_EXCLAVES
-MALLOC_NOEXPORT
-extern bool malloc_sec_transition_early_malloc_support;
-#endif // !MALLOC_TARGET_EXCLAVES
-
-#endif // CONFIG_MTE
 
 #if CONFIG_MALLOC_PROCESS_IDENTITY
 MALLOC_NOEXPORT
@@ -403,33 +383,33 @@
 #endif
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(size)
+void *
 _malloc_zone_malloc(malloc_zone_t *zone, size_t size, malloc_zone_options_t mzo) __alloc_size(2);
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(num_items * size)
+void *
 _malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size, malloc_zone_options_t mzo) __alloc_size(2,3);
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(size)
+void *
 _malloc_zone_valloc(malloc_zone_t *zone, size_t size, malloc_zone_options_t mzo) __alloc_size(2);
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(size)
+void *
 _malloc_zone_realloc(malloc_zone_t *zone, void * __unsafe_indexable ptr,
 		size_t size, malloc_type_descriptor_t type_desc) __alloc_size(3);
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(size)
+void *
 _malloc_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size,
 		malloc_zone_options_t mzo, malloc_type_descriptor_t type_desc)
 		 __alloc_align(2) __alloc_size(3);
 
 #if !MALLOC_TARGET_EXCLAVES
 MALLOC_NOEXPORT
-void * __sized_by_or_null(size)
-_malloc_zone_malloc_with_options_outlined(malloc_zone_t *zone, size_t align,
-		size_t size, malloc_zone_malloc_options_t options)
+void *
+_malloc_zone_malloc_with_options_np_outlined(malloc_zone_t *zone, size_t align,
+		size_t size, malloc_options_np_t options)
 		__alloc_align(2) __alloc_size(3);
 #endif // !MALLOC_TARGET_EXCLAVES
 
@@ -445,13 +425,8 @@
 #endif // DARWINTEST || MALLOC_BUILDING_XCTESTS
 
 MALLOC_NOEXPORT
-void * __sized_by_or_null(new_size)
+void *
 _realloc(void * __unsafe_indexable in_ptr, size_t new_size) __alloc_size(2);
-
-MALLOC_NOEXPORT
-malloc_zone_t *
-find_registered_zone(const void * __unsafe_indexable ptr, size_t *returned_size,
-		bool known_non_default);
 
 MALLOC_NOEXPORT
 int
@@ -494,23 +469,7 @@
 #endif // TARGET_OS_SIMULATOR
 }
 
-#if !MALLOC_TARGET_EXCLAVES
-typedef union {
-	malloc_thread_options_t options;
-	void *storage;
-} th_opts_t;
-
-MALLOC_STATIC_ASSERT(sizeof(th_opts_t) == sizeof(void *), "Options fit into pointer bits");
-
-static inline void
-_malloc_set_thread_options(malloc_thread_options_t opts)
-{
-	th_opts_t x = {.options = opts};
-	_pthread_setspecific_direct(__TSD_MALLOC_THREAD_OPTIONS, x.storage);
-}
-#endif // MALLOC_TARGET_EXCLAVES
-
-#if CONFIG_CLUSTER_AWARE
+#if CONFIG_MAGAZINE_PER_CLUSTER
 
 static inline unsigned int
 _malloc_cpu_cluster_number(void)
@@ -532,7 +491,7 @@
 #endif
 }
 
-#endif // CONFIG_CLUSTER_AWARE
+#endif // CONFIG_MAGAZINE_PER_CLUSTER
 
 // Gets the allocation size for a calloc(). Multiples size by num_items and adds
 // extra_size, storing the result in *total_size. Returns 0 on success, -1 (with
@@ -589,6 +548,7 @@
 typedef void (*set_msl_lite_hooks_callout_t) (struct _malloc_msl_lite_hooks_s *hooksp, size_t size);
 void set_msl_lite_hooks(set_msl_lite_hooks_callout_t callout);
 
+
 static MALLOC_INLINE void
 yield(void)
 {
@@ -600,16 +560,4 @@
 #endif // !MALLOC_TARGET_EXCLAVES
 }
 
-#if CONFIG_FEATUREFLAGS_SIMPLE
-#if TARGET_OS_SIMULATOR
-#define malloc_secure_feature_enabled(name, fallback, simulator_default) \
-	(simulator_default)
-#else
-// TODO: Do we want the secure fallback to be the same as the no-ff fallback?
-#define malloc_secure_feature_enabled(name, fallback, simulator_default) \
-	(malloc_internal_security_policy ? \
-			os_feature_enabled_simple(libmalloc, name, fallback) : (fallback))
-#endif // TARGET_OS_SIMULATOR
-#endif // CONFIG_FEATUREFLAGS_SIMPLE
-
 #endif // __INTERNAL_H