2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* OSMetaClass.cpp created by gvdl on Fri 1998-11-17 */
34 #include <libkern/OSReturn.h>
36 #include <libkern/c++/OSMetaClass.h>
38 #include <libkern/c++/OSObject.h>
39 #include <libkern/c++/OSCollectionIterator.h>
40 #include <libkern/c++/OSDictionary.h>
41 #include <libkern/c++/OSArray.h>
42 #include <libkern/c++/OSSet.h>
43 #include <libkern/c++/OSSymbol.h>
44 #include <libkern/c++/OSNumber.h>
45 #include <libkern/c++/OSSerialize.h>
46 #include <libkern/c++/OSLib.h>
47 #include <libkern/OSAtomic.h>
51 #include <sys/systm.h>
52 #include <mach/mach_types.h>
53 #include <kern/lock.h>
54 #include <kern/clock.h>
55 #include <kern/thread_call.h>
56 #include <kern/host.h>
57 #include <mach/kmod.h>
58 #include <mach/mach_interface.h>
60 extern void OSRuntimeUnloadCPP(kmod_info_t
*ki
, void *);
63 extern int debug_container_malloc_size
;
64 #define ACCUMSIZE(s) do { debug_container_malloc_size += (s); } while(0)
67 #endif /* OSALLOCDEBUG */
72 kCompletedBootstrap
= 0,
74 kMakingDictionaries
= 2
75 } sBootstrapState
= kNoDictionaries
;
77 static const int kClassCapacityIncrement
= 40;
78 static const int kKModCapacityIncrement
= 10;
79 static OSDictionary
*sAllClassesDict
, *sKModClassesDict
, *sSortedByClassesDict
;
81 static mutex_t
*loadLock
;
82 static struct StalledData
{
85 unsigned int capacity
;
87 OSMetaClass
**classes
;
90 static unsigned int sConsiderUnloadDelay
= 60; /* secs */
92 static const char OSMetaClassBasePanicMsg
[] =
93 "OSMetaClassBase::_RESERVEDOSMetaClassBase%d called\n";
96 void OSMetaClassBase::_RESERVEDOSMetaClassBase0()
97 { panic(OSMetaClassBasePanicMsg
, 0); }
98 void OSMetaClassBase::_RESERVEDOSMetaClassBase1()
99 { panic(OSMetaClassBasePanicMsg
, 1); }
100 void OSMetaClassBase::_RESERVEDOSMetaClassBase2()
101 { panic(OSMetaClassBasePanicMsg
, 2); }
102 #endif /* SLOT_USED */
104 // As these slots are used move them up inside the #if above
105 void OSMetaClassBase::_RESERVEDOSMetaClassBase3()
106 { panic(OSMetaClassBasePanicMsg
, 3); }
107 void OSMetaClassBase::_RESERVEDOSMetaClassBase4()
108 { panic(OSMetaClassBasePanicMsg
, 4); }
109 void OSMetaClassBase::_RESERVEDOSMetaClassBase5()
110 { panic(OSMetaClassBasePanicMsg
, 5); }
111 void OSMetaClassBase::_RESERVEDOSMetaClassBase6()
112 { panic(OSMetaClassBasePanicMsg
, 6); }
115 * These used to be inline in the header but gcc didn't believe us
116 * Now we MUST pull the inline out at least until the compiler is
119 // Helper inlines for runtime type preprocessor macros
120 OSMetaClassBase
*OSMetaClassBase::
121 safeMetaCast(const OSMetaClassBase
*me
, const OSMetaClass
*toType
)
122 { return (me
)? me
->metaCast(toType
) : 0; }
124 bool OSMetaClassBase::
125 checkTypeInst(const OSMetaClassBase
*inst
, const OSMetaClassBase
*typeinst
)
127 const OSMetaClass
*toType
= OSTypeIDInst(typeinst
);
128 return typeinst
&& inst
&& (0 != inst
->metaCast(toType
));
132 // If you need this slot you had better setup an IOCTL style interface.
133 // 'Cause the whole kernel world depends on OSMetaClassBase and YOU
134 // CANT change the VTABLE size ever.
135 void OSMetaClassBase::_RESERVEDOSMetaClassBase7()
136 { panic(OSMetaClassBasePanicMsg
, 7); }
138 OSMetaClassBase::OSMetaClassBase()
142 OSMetaClassBase::~OSMetaClassBase()
146 thisVTable
= (void **) this;
147 *thisVTable
= (void *) -1UL;
150 bool OSMetaClassBase::isEqualTo(const OSMetaClassBase
*anObj
) const
152 return this == anObj
;
155 OSMetaClassBase
*OSMetaClassBase::metaCast(const OSMetaClass
*toMeta
) const
157 return toMeta
->checkMetaCast(this);
160 OSMetaClassBase
*OSMetaClassBase::metaCast(const OSSymbol
*toMetaSymb
) const
162 return OSMetaClass::checkMetaCastWithName(toMetaSymb
, this);
165 OSMetaClassBase
*OSMetaClassBase::metaCast(const OSString
*toMetaStr
) const
167 const OSSymbol
*tempSymb
= OSSymbol::withString(toMetaStr
);
168 OSMetaClassBase
*ret
= 0;
170 ret
= metaCast(tempSymb
);
176 OSMetaClassBase
*OSMetaClassBase::metaCast(const char *toMetaCStr
) const
178 const OSSymbol
*tempSymb
= OSSymbol::withCString(toMetaCStr
);
179 OSMetaClassBase
*ret
= 0;
181 ret
= metaCast(tempSymb
);
187 class OSMetaClassMeta
: public OSMetaClass
191 OSObject
*alloc() const;
193 OSMetaClassMeta::OSMetaClassMeta()
194 : OSMetaClass("OSMetaClass", 0, sizeof(OSMetaClass
))
196 OSObject
*OSMetaClassMeta::alloc() const { return 0; }
198 static OSMetaClassMeta sOSMetaClassMeta
;
200 const OSMetaClass
* const OSMetaClass::metaClass
= &sOSMetaClassMeta
;
201 const OSMetaClass
* OSMetaClass::getMetaClass() const
202 { return &sOSMetaClassMeta
; }
204 static const char OSMetaClassPanicMsg
[] =
205 "OSMetaClass::_RESERVEDOSMetaClass%d called\n";
207 void OSMetaClass::_RESERVEDOSMetaClass0()
208 { panic(OSMetaClassPanicMsg
, 0); }
209 void OSMetaClass::_RESERVEDOSMetaClass1()
210 { panic(OSMetaClassPanicMsg
, 1); }
211 void OSMetaClass::_RESERVEDOSMetaClass2()
212 { panic(OSMetaClassPanicMsg
, 2); }
213 void OSMetaClass::_RESERVEDOSMetaClass3()
214 { panic(OSMetaClassPanicMsg
, 3); }
215 void OSMetaClass::_RESERVEDOSMetaClass4()
216 { panic(OSMetaClassPanicMsg
, 4); }
217 void OSMetaClass::_RESERVEDOSMetaClass5()
218 { panic(OSMetaClassPanicMsg
, 5); }
219 void OSMetaClass::_RESERVEDOSMetaClass6()
220 { panic(OSMetaClassPanicMsg
, 6); }
221 void OSMetaClass::_RESERVEDOSMetaClass7()
222 { panic(OSMetaClassPanicMsg
, 7); }
224 void OSMetaClass::logError(OSReturn result
)
229 case kOSMetaClassNoInit
:
230 msg
="OSMetaClass::preModLoad wasn't called, runtime internal error";
232 case kOSMetaClassNoDicts
:
233 msg
="Allocation failure for Metaclass internal dictionaries"; break;
234 case kOSMetaClassNoKModSet
:
235 msg
="Allocation failure for internal kmodule set"; break;
236 case kOSMetaClassNoInsKModSet
:
237 msg
="Can't insert the KMod set into the module dictionary"; break;
238 case kOSMetaClassDuplicateClass
:
239 msg
="Duplicate class"; break;
240 case kOSMetaClassNoSuper
:
241 msg
="Can't associate a class with its super class"; break;
242 case kOSMetaClassInstNoSuper
:
243 msg
="Instance construction, unknown super class."; break;
245 case kOSMetaClassInternal
:
246 msg
="runtime internal error"; break;
247 case kOSReturnSuccess
:
253 OSMetaClass::OSMetaClass(const char *inClassName
,
254 const OSMetaClass
*inSuperClass
,
255 unsigned int inClassSize
)
258 classSize
= inClassSize
;
259 superClassLink
= inSuperClass
;
261 className
= (const OSSymbol
*) inClassName
;
264 printf("OSMetaClass::preModLoad wasn't called for %s, "
265 "runtime internal error\n", inClassName
);
266 } else if (!sStalled
->result
) {
267 // Grow stalled array if neccessary
268 if (sStalled
->count
>= sStalled
->capacity
) {
269 OSMetaClass
**oldStalled
= sStalled
->classes
;
270 int oldSize
= sStalled
->capacity
* sizeof(OSMetaClass
*);
271 int newSize
= oldSize
272 + kKModCapacityIncrement
* sizeof(OSMetaClass
*);
274 sStalled
->classes
= (OSMetaClass
**) kalloc(newSize
);
275 if (!sStalled
->classes
) {
276 sStalled
->classes
= oldStalled
;
277 sStalled
->result
= kOSMetaClassNoTempData
;
281 sStalled
->capacity
+= kKModCapacityIncrement
;
282 memmove(sStalled
->classes
, oldStalled
, oldSize
);
283 kfree((vm_offset_t
)oldStalled
, oldSize
);
284 ACCUMSIZE(newSize
- oldSize
);
287 sStalled
->classes
[sStalled
->count
++] = this;
291 OSMetaClass::~OSMetaClass()
294 OSCollectionIterator
*iter
;
296 if (sAllClassesDict
) {
297 sAllClassesDict
->removeObject(className
);
298 className
->release();
301 iter
= OSCollectionIterator::withCollection(sKModClassesDict
);
306 while ( (iterKey
= (OSSymbol
*) iter
->getNextObject()) ) {
308 kmodClassSet
= (OSSet
*) sKModClassesDict
->getObject(iterKey
);
309 if (kmodClassSet
&& kmodClassSet
->containsObject(this)) {
310 kmodClassSet
->removeObject(this);
320 // First pass find class in stalled list
321 for (i
= 0; i
< sStalled
->count
; i
++)
322 if (this == sStalled
->classes
[i
])
325 if (i
< sStalled
->count
) {
327 if (i
< sStalled
->count
)
328 memmove(&sStalled
->classes
[i
], &sStalled
->classes
[i
+1],
329 (sStalled
->count
- i
) * sizeof(OSMetaClass
*));
334 void *OSMetaClass::operator new(size_t size
) { return 0; }
335 void OSMetaClass::retain() const { }
336 void OSMetaClass::release() const { }
337 void OSMetaClass::release(int when
) const { }
338 void OSMetaClass::taggedRetain(const void *tag
) const { }
339 void OSMetaClass::taggedRelease(const void *tag
) const { }
340 void OSMetaClass::taggedRelease(const void *tag
, const int when
) const { }
341 int OSMetaClass::getRetainCount() const { return 0; }
343 const char *OSMetaClass::getClassName() const
345 return className
->getCStringNoCopy();
348 unsigned int OSMetaClass::getClassSize() const
353 void *OSMetaClass::preModLoad(const char *kmodName
)
356 loadLock
= mutex_alloc(0);
357 mutex_lock(loadLock
);
360 mutex_lock(loadLock
);
362 sStalled
= (StalledData
*) kalloc(sizeof(*sStalled
));
364 sStalled
->classes
= (OSMetaClass
**)
365 kalloc(kKModCapacityIncrement
* sizeof(OSMetaClass
*));
366 if (!sStalled
->classes
) {
367 kfree((vm_offset_t
) sStalled
, sizeof(*sStalled
));
370 ACCUMSIZE((kKModCapacityIncrement
* sizeof(OSMetaClass
*)) + sizeof(*sStalled
));
372 sStalled
->result
= kOSReturnSuccess
;
373 sStalled
->capacity
= kKModCapacityIncrement
;
375 sStalled
->kmodName
= kmodName
;
376 bzero(sStalled
->classes
, kKModCapacityIncrement
* sizeof(OSMetaClass
*));
382 bool OSMetaClass::checkModLoad(void *loadHandle
)
384 return sStalled
&& loadHandle
== sStalled
385 && sStalled
->result
== kOSReturnSuccess
;
388 OSReturn
OSMetaClass::postModLoad(void *loadHandle
)
390 OSReturn result
= kOSReturnSuccess
;
392 OSSymbol
*myname
= 0;
394 if (!sStalled
|| loadHandle
!= sStalled
) {
395 logError(kOSMetaClassInternal
);
396 return kOSMetaClassInternal
;
399 if (sStalled
->result
)
400 result
= sStalled
->result
;
401 else switch (sBootstrapState
) {
402 case kNoDictionaries
:
403 sBootstrapState
= kMakingDictionaries
;
404 // No break; fall through
406 case kMakingDictionaries
:
407 sKModClassesDict
= OSDictionary::withCapacity(kKModCapacityIncrement
);
408 sAllClassesDict
= OSDictionary::withCapacity(kClassCapacityIncrement
);
409 sSortedByClassesDict
= OSDictionary::withCapacity(kClassCapacityIncrement
);
410 if (!sAllClassesDict
|| !sKModClassesDict
|| !sSortedByClassesDict
) {
411 result
= kOSMetaClassNoDicts
;
414 // No break; fall through
416 case kCompletedBootstrap
:
419 myname
= OSSymbol::withCStringNoCopy(sStalled
->kmodName
);
421 if (!sStalled
->count
)
422 break; // Nothing to do so just get out
424 // First pass checking classes aren't already loaded
425 for (i
= 0; i
< sStalled
->count
; i
++) {
426 OSMetaClass
*me
= sStalled
->classes
[i
];
428 if (0 != sAllClassesDict
->getObject((const char *) me
->className
)) {
429 printf("Class \"%s\" is duplicate\n", (const char *) me
->className
);
430 result
= kOSMetaClassDuplicateClass
;
434 if (i
!= sStalled
->count
)
437 kmodSet
= OSSet::withCapacity(sStalled
->count
);
439 result
= kOSMetaClassNoKModSet
;
443 if (!sKModClassesDict
->setObject(myname
, kmodSet
)) {
444 result
= kOSMetaClassNoInsKModSet
;
448 // Second pass symbolling strings and inserting classes in dictionary
449 for (i
= 0; i
< sStalled
->count
; i
++) {
450 OSMetaClass
*me
= sStalled
->classes
[i
];
452 OSSymbol::withCStringNoCopy((const char *) me
->className
);
454 sAllClassesDict
->setObject(me
->className
, me
);
455 kmodSet
->setObject(me
);
456 sSortedByClassesDict
->setObject((const OSSymbol
*)me
, myname
);
458 sBootstrapState
= kCompletedBootstrap
;
463 result
= kOSMetaClassInternal
;
474 ACCUMSIZE(-(sStalled
->capacity
* sizeof(OSMetaClass
*)
475 + sizeof(*sStalled
)));
476 kfree((vm_offset_t
) sStalled
->classes
,
477 sStalled
->capacity
* sizeof(OSMetaClass
*));
478 kfree((vm_offset_t
) sStalled
, sizeof(*sStalled
));
483 mutex_unlock(loadLock
);
488 void OSMetaClass::instanceConstructed() const
490 // if ((0 == OSIncrementAtomic((SInt32 *)&(((OSMetaClass *) this)->instanceCount))) && superClassLink)
491 if ((0 == OSIncrementAtomic((SInt32
*) &instanceCount
)) && superClassLink
)
492 superClassLink
->instanceConstructed();
495 void OSMetaClass::instanceDestructed() const
497 if ((1 == OSDecrementAtomic((SInt32
*) &instanceCount
)) && superClassLink
)
498 superClassLink
->instanceDestructed();
500 if( ((int) instanceCount
) < 0)
501 printf("%s: bad retain(%d)", getClassName(), instanceCount
);
504 bool OSMetaClass::modHasInstance(const char *kmodName
)
509 loadLock
= mutex_alloc(0);
510 mutex_lock(loadLock
);
513 mutex_lock(loadLock
);
517 OSCollectionIterator
*iter
;
518 OSMetaClass
*checkClass
;
520 kmodClasses
= OSDynamicCast(OSSet
,
521 sKModClassesDict
->getObject(kmodName
));
525 iter
= OSCollectionIterator::withCollection(kmodClasses
);
529 while ( (checkClass
= (OSMetaClass
*) iter
->getNextObject()) )
530 if (checkClass
->getInstanceCount()) {
538 mutex_unlock(loadLock
);
543 void OSMetaClass::reportModInstances(const char *kmodName
)
546 OSCollectionIterator
*iter
;
547 OSMetaClass
*checkClass
;
549 kmodClasses
= OSDynamicCast(OSSet
,
550 sKModClassesDict
->getObject(kmodName
));
554 iter
= OSCollectionIterator::withCollection(kmodClasses
);
558 while ( (checkClass
= (OSMetaClass
*) iter
->getNextObject()) )
559 if (checkClass
->getInstanceCount()) {
560 printf("%s: %s has %d instance(s)\n",
562 checkClass
->getClassName(),
563 checkClass
->getInstanceCount());
569 extern "C" kern_return_t
kmod_unload_cache(void);
571 static void _OSMetaClassConsiderUnloads(thread_call_param_t p0
,
572 thread_call_param_t p1
)
576 OSCollectionIterator
*kmods
;
577 OSCollectionIterator
*classes
;
578 OSMetaClass
*checkClass
;
583 mutex_lock(loadLock
);
587 kmods
= OSCollectionIterator::withCollection(sKModClassesDict
);
592 while ( (kmodName
= (OSSymbol
*) kmods
->getNextObject()) ) {
595 kfree((vm_offset_t
) ki
, sizeof(kmod_info_t
));
599 ki
= kmod_lookupbyname_locked((char *)kmodName
->getCStringNoCopy());
603 if (ki
->reference_count
) {
607 kmodClasses
= OSDynamicCast(OSSet
,
608 sKModClassesDict
->getObject(kmodName
));
609 classes
= OSCollectionIterator::withCollection(kmodClasses
);
613 while ((checkClass
= (OSMetaClass
*) classes
->getNextObject())
614 && (0 == checkClass
->getInstanceCount()))
618 if (0 == checkClass
) {
619 OSRuntimeUnloadCPP(ki
, 0); // call destructors
620 ret
= kmod_destroy(host_priv_self(), ki
->id
);
630 mutex_unlock(loadLock
);
635 void OSMetaClass::considerUnloads()
637 static thread_call_t unloadCallout
;
640 mutex_lock(loadLock
);
643 unloadCallout
= thread_call_allocate(&_OSMetaClassConsiderUnloads
, 0);
645 thread_call_cancel(unloadCallout
);
646 clock_interval_to_deadline(sConsiderUnloadDelay
, 1000 * 1000 * 1000, &when
);
647 thread_call_enter_delayed(unloadCallout
, when
);
649 mutex_unlock(loadLock
);
652 const OSMetaClass
*OSMetaClass::getMetaClassWithName(const OSSymbol
*name
)
654 OSMetaClass
*retMeta
= 0;
660 retMeta
= (OSMetaClass
*) sAllClassesDict
->getObject(name
);
662 if (!retMeta
&& sStalled
)
664 // Oh dear we have to scan the stalled list and walk the
665 // the stalled list manually.
666 const char *cName
= name
->getCStringNoCopy();
669 // find class in stalled list
670 for (i
= 0; i
< sStalled
->count
; i
++) {
671 retMeta
= sStalled
->classes
[i
];
672 if (0 == strcmp(cName
, (const char *) retMeta
->className
))
676 if (i
< sStalled
->count
)
683 OSObject
*OSMetaClass::allocClassWithName(const OSSymbol
*name
)
686 mutex_lock(loadLock
);
688 const OSMetaClass
* const meta
= getMetaClassWithName(name
);
691 result
= meta
->alloc();
695 mutex_unlock(loadLock
);
700 OSObject
*OSMetaClass::allocClassWithName(const OSString
*name
)
702 const OSSymbol
*tmpKey
= OSSymbol::withString(name
);
703 OSObject
*result
= allocClassWithName(tmpKey
);
708 OSObject
*OSMetaClass::allocClassWithName(const char *name
)
710 const OSSymbol
*tmpKey
= OSSymbol::withCStringNoCopy(name
);
711 OSObject
*result
= allocClassWithName(tmpKey
);
717 OSMetaClassBase
*OSMetaClass::
718 checkMetaCastWithName(const OSSymbol
*name
, const OSMetaClassBase
*in
)
720 OSMetaClassBase
* result
;
721 mutex_lock(loadLock
);
722 const OSMetaClass
* const meta
= getMetaClassWithName(name
);
725 result
= meta
->checkMetaCast(in
);
729 mutex_unlock(loadLock
);
733 OSMetaClassBase
*OSMetaClass::
734 checkMetaCastWithName(const OSString
*name
, const OSMetaClassBase
*in
)
736 const OSSymbol
*tmpKey
= OSSymbol::withString(name
);
737 OSMetaClassBase
*result
= checkMetaCastWithName(tmpKey
, in
);
742 OSMetaClassBase
*OSMetaClass::
743 checkMetaCastWithName(const char *name
, const OSMetaClassBase
*in
)
745 const OSSymbol
*tmpKey
= OSSymbol::withCStringNoCopy(name
);
746 OSMetaClassBase
*result
= checkMetaCastWithName(tmpKey
, in
);
752 OSMetaClass::checkMetaCast
753 checkMetaCast(const OSMetaClassBase *check)
755 Check to see if the 'check' object has this object in it's metaclass chain. Returns check if it is indeed a kind of the current meta class, 0 otherwise.
757 Generally this method is not invoked directly but is used to implement the OSMetaClassBase::metaCast member function.
759 See also OSMetaClassBase::metaCast
762 OSMetaClassBase
*OSMetaClass::checkMetaCast(const OSMetaClassBase
*check
) const
764 const OSMetaClass
* const toMeta
= this;
765 const OSMetaClass
*fromMeta
;
767 for (fromMeta
= check
->getMetaClass(); ; fromMeta
= fromMeta
->superClassLink
) {
768 if (toMeta
== fromMeta
)
769 return (OSMetaClassBase
*) check
; // Discard const
771 if (!fromMeta
->superClassLink
)
778 void OSMetaClass::reservedCalled(int ind
) const
780 const char *cname
= className
->getCStringNoCopy();
781 panic("%s::_RESERVED%s%d called\n", cname
, cname
, ind
);
784 const OSMetaClass
*OSMetaClass::getSuperClass() const
786 return superClassLink
;
789 const OSSymbol
*OSMetaClass::getKmodName() const
791 return sSortedByClassesDict
->getObject((const OSSymbol
*)this);
794 unsigned int OSMetaClass::getInstanceCount() const
796 return instanceCount
;
799 void OSMetaClass::printInstanceCounts()
801 OSCollectionIterator
*classes
;
805 classes
= OSCollectionIterator::withCollection(sAllClassesDict
);
809 while( (className
= (OSSymbol
*)classes
->getNextObject())) {
810 meta
= (OSMetaClass
*) sAllClassesDict
->getObject(className
);
813 printf("%24s count: %03d x 0x%03x = 0x%06x\n",
814 className
->getCStringNoCopy(),
815 meta
->getInstanceCount(),
816 meta
->getClassSize(),
817 meta
->getInstanceCount() * meta
->getClassSize() );
823 OSDictionary
* OSMetaClass::getClassDictionary()
825 panic("OSMetaClass::getClassDictionary(): Obsoleted\n");
829 bool OSMetaClass::serialize(OSSerialize
*s
) const
831 panic("OSMetaClass::serialize(): Obsoleted\n");
835 void OSMetaClass::serializeClassDictionary(OSDictionary
*serializeDictionary
)
837 OSDictionary
*classDict
;
839 classDict
= OSDictionary::withCapacity(sAllClassesDict
->getCount());
843 mutex_lock(loadLock
);
845 OSCollectionIterator
*classes
;
846 const OSSymbol
*className
;
848 classes
= OSCollectionIterator::withCollection(sAllClassesDict
);
852 while ((className
= (const OSSymbol
*) classes
->getNextObject())) {
853 const OSMetaClass
*meta
;
856 meta
= (OSMetaClass
*) sAllClassesDict
->getObject(className
);
857 count
= OSNumber::withNumber(meta
->getInstanceCount(), 32);
859 classDict
->setObject(className
, count
);
865 serializeDictionary
->setObject("Classes", classDict
);
868 mutex_unlock(loadLock
);
870 classDict
->release();