Loading...
--- xnu/xnu-12377.101.15/libkern/c++/OSObject.cpp
+++ xnu/xnu-4903.270.47/libkern/c++/OSObject.cpp
@@ -42,7 +42,7 @@
#include <kern/queue.h>
__BEGIN_DECLS
-size_t debug_ivars_size;
+int debug_ivars_size;
__END_DECLS
@@ -50,7 +50,7 @@
/* Class global data */
OSObject::MetaClass OSObject::gMetaClass;
const OSMetaClass * const OSObject::metaClass = &OSObject::gMetaClass;
-const OSMetaClass * const OSObject::superClass = NULL;
+const OSMetaClass * const OSObject::superClass = 0;
/* Class member functions - Can't use defaults */
OSObject::~OSObject()
@@ -64,7 +64,7 @@
OSObject *
OSObject::MetaClass::alloc() const
{
- return NULL;
+ return 0;
}
/* The OSObject::MetaClass constructor */
@@ -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
@@ -233,13 +233,13 @@
void
OSObject::release() const
{
- taggedRelease(NULL);
+ taggedRelease(0);
}
void
OSObject::retain() const
{
- taggedRetain(NULL);
+ taggedRetain(0);
}
extern "C" void
@@ -257,7 +257,7 @@
void
OSObject::release(int when) const
{
- taggedRelease(NULL, when);
+ taggedRelease(0, when);
}
bool
@@ -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,44 +289,9 @@
}
#endif
- void *mem = kheap_alloc(KHEAP_DEFAULT, size,
- Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
+ void * mem = kalloc_tag_bt(size, VM_KERN_MEMORY_LIBKERN);
assert(mem);
- OSIVAR_ACCUMSIZE(size);
-
- return (void *) mem;
-}
-
-void *
-OSObject_typed_operator_new(kalloc_type_view_t ktv, vm_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));
- }
- assert(mem);
+ bzero(mem, size);
OSIVAR_ACCUMSIZE(size);
return (void *) mem;
@@ -356,33 +310,9 @@
}
#endif
- kheap_free(KHEAP_DEFAULT, mem, size);
+ kfree(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
bool
OSObject::init()
@@ -435,24 +365,3 @@
retainCount = 1;
// if (kIOTracking & gIOKitDebug) getMetaClass()->trackedInstance(this);
}
-
-
-bool
-OSObject::iterateObjects(void * refcon, bool (*callback)(void * refcon, OSObject * object))
-{
- OSCollection * col;
- if ((col = OSDynamicCast(OSCollection, this))) {
- return col->iterateObjects(refcon, callback);
- }
- return callback(refcon, this);
-}
-
-bool
-OSObject::iterateObjects(bool (^block)(OSObject * object))
-{
- OSCollection * col;
- if ((col = OSDynamicCast(OSCollection, this))) {
- return col->iterateObjects(block);
- }
- return block(this);
-}