Loading...
--- xnu/xnu-12377.101.15/libkern/c++/OSObject.cpp
+++ xnu/xnu-8019.41.5/libkern/c++/OSObject.cpp
@@ -136,8 +136,8 @@
#else /* DEBUG */
// @@@ gvdl: eventually need to make this panic optional
// based on a boot argument i.e. debug= boot flag
- panic("OSObject(%p)::refcount: "
- "About to wrap the reference count, reference leak?", this);
+ panic("OSObject::refcount: "
+ "About to wrap the reference count, reference leak?");
#endif /* !DEBUG */
}
}
@@ -152,7 +152,7 @@
OSObject::taggedRetain(const void *tag) const
{
if (!taggedTryRetain(tag)) {
- panic("OSObject(%p)::refcount: Attempting to retain a freed object", this);
+ panic("OSObject::refcount: Attempting to retain a freed object");
}
}
@@ -195,8 +195,8 @@
#else /* DEBUG */
// @@@ gvdl: eventually need to make this panic optional
// based on a boot argument i.e. debug= boot flag
- panic("OSObject(%p)::refcount: %s",
- "About to unreference a pegged object, reference leak?", this);
+ panic("OSObject::refcount: %s",
+ "About to unreference a pegged object, reference leak?");
#endif /* !DEBUG */
}
}
@@ -220,8 +220,8 @@
// xxx - any code in the kernel could trip this,
// xxx - and it applies as noted to all collections, not just the registry
if ((UInt16) actualCount < (actualCount >> 16)) {
- panic("A kext releasing a(n) %s %p has corrupted the registry.",
- getClassName(this), this);
+ panic("A kext releasing a(n) %s has corrupted the registry.",
+ getClassName(this));
}
// Check for a 'free' condition and that if we are first through
@@ -280,17 +280,6 @@
return ok;
}
-/*
- * Ignore -Wxnu-typed-allocators for the operator new/delete implementations
- */
-__typed_allocators_ignore_push
-
-/*
- * Given that all OSObjects have been transitioned to use
- * OSObject_typed_operator_new/OSObject_typed_operator_delete, this should
- * only be called from kexts that havent recompiled to use the new
- * definitions.
- */
void *
OSObject::operator new(size_t size)
{
@@ -300,8 +289,8 @@
}
#endif
- void *mem = kheap_alloc(KHEAP_DEFAULT, size,
- Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
+ void *mem = kheap_alloc_tag_bt(KHEAP_DEFAULT, size,
+ (zalloc_flags_t) (Z_WAITOK | Z_ZERO), VM_KERN_MEMORY_LIBKERN);
assert(mem);
OSIVAR_ACCUMSIZE(size);
@@ -332,10 +321,11 @@
* kalloc_type_views generated at some external callsites
* many not have been processed during boot.
*/
- mem = kalloc_type_impl_external(ktv, Z_WAITOK_ZERO);
+ mem = kalloc_type_impl_external(ktv, (zalloc_flags_t)
+ (Z_WAITOK | Z_ZERO));
} else {
- mem = kheap_alloc(KHEAP_DEFAULT, size,
- Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
+ mem = kheap_alloc_tag_bt(KHEAP_DEFAULT, size,
+ (zalloc_flags_t) (Z_WAITOK | Z_ZERO), VM_KERN_MEMORY_LIBKERN);
}
assert(mem);
OSIVAR_ACCUMSIZE(size);
@@ -356,7 +346,7 @@
}
#endif
- kheap_free(KHEAP_DEFAULT, mem, size);
+ kern_os_kfree(mem, size);
OSIVAR_ACCUMSIZE(-size);
}
@@ -377,12 +367,48 @@
if (size <= kalloc_type_get_size(ktv->kt_size)) {
kern_os_typed_free(ktv, mem, size);
} else {
- kheap_free(KHEAP_DEFAULT, mem, size);
+ kern_os_kfree(mem, size);
}
OSIVAR_ACCUMSIZE(-size);
}
-__typed_allocators_ignore_pop
+extern "C" void *
+OSObject_operator_new_external(size_t size);
+void *
+OSObject_operator_new_external(size_t size)
+{
+ #if IOTRACKING
+ if (kIOTracking & gIOKitDebug) {
+ return OSMetaClass::trackedNew(size);
+ }
+#endif
+
+ void * mem = kheap_alloc_tag_bt(KHEAP_KEXT, size,
+ (zalloc_flags_t) (Z_WAITOK | Z_ZERO), VM_KERN_MEMORY_LIBKERN);
+ assert(mem);
+ OSIVAR_ACCUMSIZE(size);
+
+ return (void *) mem;
+}
+
+extern "C" void
+OSObject_operator_delete_external(void * mem, size_t size);
+void
+OSObject_operator_delete_external(void * mem, size_t size)
+{
+ if (!mem) {
+ return;
+ }
+
+#if IOTRACKING
+ if (kIOTracking & gIOKitDebug) {
+ return OSMetaClass::trackedDelete(mem, size);
+ }
+#endif
+
+ kheap_free(KHEAP_KEXT, mem, size);
+ OSIVAR_ACCUMSIZE(-size);
+}
bool
OSObject::init()