Loading...
--- xnu/xnu-12377.101.15/libkern/c++/OSObject.cpp
+++ xnu/xnu-7195.141.2/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,51 +289,53 @@
}
#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);
return (void *) mem;
}
+void
+OSObject::operator delete(void * mem, size_t size)
+{
+ if (!mem) {
+ return;
+ }
+
+#if IOTRACKING
+ if (kIOTracking & gIOKitDebug) {
+ return OSMetaClass::trackedDelete(mem, size);
+ }
+#endif
+
+ kern_os_kfree(mem, size);
+ OSIVAR_ACCUMSIZE(-size);
+}
+
+__BEGIN_DECLS
+void *OSObject_operator_new_external(size_t size);
void *
-OSObject_typed_operator_new(kalloc_type_view_t ktv, vm_size_t size)
-{
-#if IOTRACKING
+OSObject_operator_new_external(size_t size)
+{
+ #if IOTRACKING
if (kIOTracking & gIOKitDebug) {
return OSMetaClass::trackedNew(size);
}
#endif
- /*
- * Some classes in kexts that subclass from iokit classes
- * don't use OSDeclare/OSDefine to declare/define structors.
- * When operator new is called on such objects they end up
- * using the parent's operator new/delete. If we detect such
- * a case we default to using kalloc rather than kalloc_type
- */
- void *mem = NULL;
- if (size <= kalloc_type_get_size(ktv->kt_size)) {
- /*
- * OSObject_typed_operator_new can be called from kexts,
- * use the external symbol for kalloc_type_impl as
- * kalloc_type_views generated at some external callsites
- * many not have been processed during boot.
- */
- mem = kalloc_type_impl_external(ktv, Z_WAITOK_ZERO);
- } else {
- mem = kheap_alloc(KHEAP_DEFAULT, size,
- Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
- }
+ 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;
}
-void
-OSObject::operator delete(void * mem, size_t size)
+void OSObject_operator_delete_external(void * mem, size_t size);
+void
+OSObject_operator_delete_external(void * mem, size_t size)
{
if (!mem) {
return;
@@ -356,34 +347,10 @@
}
#endif
- kheap_free(KHEAP_DEFAULT, mem, size);
+ kheap_free(KHEAP_KEXT, mem, size);
OSIVAR_ACCUMSIZE(-size);
}
-
-void
-OSObject_typed_operator_delete(kalloc_type_view_t ktv, void * mem,
- vm_size_t size)
-{
- if (!mem) {
- return;
- }
-
-#if IOTRACKING
- if (kIOTracking & gIOKitDebug) {
- return OSMetaClass::trackedDelete(mem, size);
- }
-#endif
-
- if (size <= kalloc_type_get_size(ktv->kt_size)) {
- kern_os_typed_free(ktv, mem, size);
- } else {
- kheap_free(KHEAP_DEFAULT, mem, size);
- }
- OSIVAR_ACCUMSIZE(-size);
-}
-
-__typed_allocators_ignore_pop
-
+__END_DECLS
bool
OSObject::init()
{