4225bc8a58fac5b46a0e40418e339c090078c0e1
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _LIBKERN_OSMETACLASS_H
26 #define _LIBKERN_OSMETACLASS_H
28 #include <sys/types.h>
30 #include <libkern/OSReturn.h>
40 #define APPLE_KEXT_COMPATIBILITY
42 #define APPLE_KEXT_COMPATIBILITY __attribute__ ((apple_kext_compatibility))
48 /*! @function OSTypeAlloc
49 @abstract Allocate an instance of the desired object.
50 @discussion The OSTypeAlloc macro can be used to break the binary compatibility difficulties presented by new. The problem is that C++ compiles the knowledge of the size of the class into the cade calling new. If you use the alloc code however the class size is determined by the callee not the caller.
51 @param type Name of the desired type to be created.
52 @result 'this' if object cas been successfully created.
54 #define OSTypeAlloc(type) ((type *) ((type::metaClass)->alloc()))
56 /*! @function OSTypeID
57 @abstract Given the name of a class return it's typeID
58 @param type Name of the desired type, eg. OSObject.
59 @result A unique Type ID for the class.
61 #define OSTypeID(type) (type::metaClass)
63 /*! @function OSTypeIDInst
64 @abstract Given a pointer to an object return it's typeID
65 @param typeinst An instance of an OSObject subclass.
66 @result The typeID, ie. OSMetaClass *.
68 #define OSTypeIDInst(typeinst) ((typeinst)->getMetaClass())
70 /*! @function OSDynamicCast
71 @abstract Roughly analogous to (type *) inst, but check if valid first.
72 @discussion OSDynamicCast is an attempt to implement a rudimentary equivalent to rtti's dynamic_cast<T> operator. Embedded-C++ doesn't allow the use of rtti. OSDynamicCast is build on the OSMetaClass mechanism. Note it is safe to call this with a 0 parameter.
73 @param type name of desired class name. Notice that it is assumed that you desire to cast to a pointer to an object of this type. Also type qualifiers, like const, are not recognized and will cause an, usually obscure, compile error.
74 @param inst Pointer to object that you wish to attempt to type cast. May be 0.
75 @result inst if object non-zero and it is of the desired type, otherwise 0.
77 #define OSDynamicCast(type, inst) \
78 ((type *) OSMetaClassBase::safeMetaCast((inst), OSTypeID(type)))
80 /*! @function OSCheckTypeInst
81 @abstract Is the target object a subclass of the reference object?
82 @param typeinst Reference instance of an object, desired type.
83 @param inst Instance of object to check for type compatibility.
84 @result false if typeinst or inst are 0 or inst is not a subclass of typeinst's class. true otherwise.
86 #define OSCheckTypeInst(typeinst, inst) \
87 OSMetaClassBase::checkTypeInst(inst, typeinst)
92 virtual ~OSMetaClassBase();
95 // Disable copy constructors of OSMetaClassBase based objects
96 /*! @function operator =
97 @abstract Disable implicit copy constructor by making private
98 @param src Reference to source object that isn't allowed to be copied
100 void operator =(OSMetaClassBase
&src
);
102 /*! @function OSMetaClassBase
103 @abstract Disable implicit copy constructor by making private
104 @param src Reference to source object that isn't allowed to be copied
106 OSMetaClassBase(OSMetaClassBase
&src
);
109 /*! @function release
110 @abstract Primary implementation of the release mechanism.
111 @discussion If $link retainCount <= the when argument then call $link free(). This indirect implementation of $link release allows the developer to break reference circularity. An example of this sort of problem is a parent/child mutual reference, either the parent or child can implement: void release() { release(2); } thus breaking the cirularity.
112 @param when When retainCount == when then call free(). */
113 virtual void release(int when
) const = 0;
115 /*! @function getRetainCount
116 @abstract How many times has this object been retained?
117 @result Current retain count
119 virtual int getRetainCount() const = 0;
122 @abstract Retain a reference in this object.
124 virtual void retain() const = 0;
125 /*! @function release
126 @abstract Release a reference to this object
128 virtual void release() const = 0;
130 /*! @function serialize
136 virtual bool serialize(OSSerialize
*s
) const = 0;
138 virtual const OSMetaClass
* getMetaClass() const = 0;
140 /*! @function isEqualTo
141 @abstract Is this == anObj?
142 @discussion OSMetaClassBase::isEqualTo implements this as a shallow pointer comparison. The OS container classes do a more meaningful comparison. Your mileage may vary.
143 @param anObj Object to compare 'this' to.
144 @result true if the objects are equivalent, false otherwise.
146 virtual bool isEqualTo(const OSMetaClassBase
*anObj
) const;
148 /*! @function metaCast
149 @abstract Check to see if this object is or inherits from the given type.
150 @discussion This function is the guts of the OSMetaClass system. IODynamicCast, qv, is implemented using this function.
151 @param toMeta Pointer to a constant OSMetaClass for the desired target type.
152 @result 'this' if object is of desired type, otherwise 0.
154 OSMetaClassBase
*metaCast(const OSMetaClass
*toMeta
) const;
157 /*! @function metaCast
158 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
159 @param toMeta OSSymbol of the desired class' name.
160 @result 'this' if object is of desired type, otherwise 0.
162 OSMetaClassBase
*metaCast(const OSSymbol
*toMeta
) const;
164 /*! @function metaCast
165 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
166 @param toMeta OSString of the desired class' name.
167 @result 'this' if object is of desired type, otherwise 0.
169 OSMetaClassBase
*metaCast(const OSString
*toMeta
) const;
171 /*! @function metaCast
172 @abstract See OSMetaClassBase::metaCast(const OSMetaClass *)
173 @param toMeta const char * C String of the desired class' name.
174 @result 'this' if object is of desired type, otherwise 0.
176 OSMetaClassBase
*metaCast(const char *toMeta
) const;
178 // Helper inlines for runtime type preprocessor macros
179 static OSMetaClassBase
*
180 safeMetaCast(const OSMetaClassBase
*me
, const OSMetaClass
*toType
);
183 checkTypeInst(const OSMetaClassBase
*inst
, const OSMetaClassBase
*typeinst
);
187 /*! @function taggedRetain
188 @abstract Retain a tagged reference in this object.
190 // WAS: virtual void _RESERVEDOSMetaClassBase0();
191 virtual void taggedRetain(const void *tag
= 0) const = 0;
193 /*! @function taggedRelease
194 @abstract Release a tagged reference to this object
196 // WAS: virtual void _RESERVEDOSMetaClassBase1();
197 virtual void taggedRelease(const void *tag
= 0) const = 0;
200 /*! @function taggedRelease
201 @abstract Release a tagged reference to this object and free if retainCount == when on entry
203 // WAS: virtual void _RESERVEDOSMetaClassBase2();
204 virtual void taggedRelease(const void *tag
, const int when
) const = 0;
208 virtual void _RESERVEDOSMetaClassBase3();
209 virtual void _RESERVEDOSMetaClassBase4();
210 virtual void _RESERVEDOSMetaClassBase5();
211 virtual void _RESERVEDOSMetaClassBase6();
212 virtual void _RESERVEDOSMetaClassBase7();
213 } APPLE_KEXT_COMPATIBILITY
;
216 @class OSMetaClass : OSMetaClassBase
217 @abstract An instance of a OSMetaClass represents one class then the kernel's runtime type information system is aware of.
219 class OSMetaClass
: private OSMetaClassBase
223 // Can never be allocated must be created at compile time
224 static void *operator new(size_t size
);
226 struct ExpansionData
{ };
228 /*! @var reserved Reserved for future use. (Internal use only) */
229 ExpansionData
*reserved
;
231 /*! @var superClass Handle to the superclass' meta class. */
232 const OSMetaClass
*superClassLink
;
234 /*! @var className OSSymbol of the class' name. */
235 const OSSymbol
*className
;
237 /*! @var classSize How big is a single instancde of this class. */
238 unsigned int classSize
;
240 /*! @var instanceCount Roughly number of instances of the object. Used primarily as a code in use flag. */
241 mutable unsigned int instanceCount
;
243 /*! @function OSMetaClass
244 @abstract Private the default constructor */
247 // Called by postModLoad
248 /*! @function logError
249 @abstract Given an error code log an error string using printf */
250 static void logError(OSReturn result
);
252 /*! @function getMetaClassWithName
253 @abstract Lookup a meta-class in the runtime type information system
254 @param name Name of the desired class's meta-class.
255 @result pointer to a meta-class object if found, 0 otherwise. */
257 static const OSMetaClass
*getMetaClassWithName(const OSSymbol
*name
);
261 @abstract Implement abstract but should no dynamic allocation is allowed */
262 virtual void retain() const;
264 /*! @function release
265 @abstract Implement abstract but should no dynamic allocation is allowed */
266 virtual void release() const;
268 /*! @function release
269 @abstract Implement abstract but should no dynamic allocation is allowed
270 @param when ignored. */
271 virtual void release(int when
) const;
273 /*! @function taggedRetain
274 @abstract Retain a tagged reference in this object.
276 virtual void taggedRetain(const void *tag
= 0) const;
278 /*! @function release
279 @abstract Release a tagged reference to this object
281 virtual void taggedRelease(const void *tag
= 0) const;
283 /*! @function release
284 @abstract Release a tagged reference to this object
286 virtual void taggedRelease(const void *tag
, const int when
) const;
288 /*! @function getRetainCount
289 @abstract Implement abstract but should no dynamic allocation is allowed */
290 virtual int getRetainCount() const;
292 virtual const OSMetaClass
* getMetaClass() const;
294 /*! @function OSMetaClass
295 @abstract Constructor for OSMetaClass objects
296 @discussion This constructor is protected and cannot not be used to instantiate an OSMetaClass object, i.e. OSMetaClass is an abstract class. This function stores the currently constructing OSMetaClass instance away for later processing. See preModLoad and postModLoad.
297 @param inClassName cString of the name of the class this meta-class represents.
298 @param inSuperClassName cString of the name of the super class.
299 @param inClassSize sizeof the class. */
300 OSMetaClass(const char *inClassName
,
301 const OSMetaClass
*inSuperClass
,
302 unsigned int inClassSize
);
304 /*! @function ~OSMetaClass
305 @abstract Destructor for OSMetaClass objects
306 @discussion If this function is called it means that the object code that implemented this class is actually in the process of unloading. The destructor removes all reference's to the subclass from the runtime type information system. */
307 virtual ~OSMetaClass();
309 // Needs to be overriden as NULL as all OSMetaClass objects are allocated
310 // statically at compile time, don't accidently try to free them.
311 void operator delete(void *mem
, size_t size
) { };
314 static const OSMetaClass
* const metaClass
;
316 /*! @function preModLoad
317 @abstract Prepare the runtime type system for the load of a module.
318 @discussion Prepare the runtime type information system for the loading of new all meta-classes constructed between now and the next postModLoad. preModLoad grab's a lock so that the runtime type information system loading can be protected, the lock is released by the postModLoad function. Any OSMetaClass that is constructed between the bracketing pre and post calls will be assosiated with the module name.
319 @param kmodName globally unique cString name of the kernel module being loaded.
320 @result If success full return a handle to be used in later calls 0 otherwise. */
321 static void *preModLoad(const char *kmodName
);
323 /*! @function failModLoad
324 @abstract Record an error during the loading of an kernel module.
325 @discussion As constructor's can't return errors nor can they through exceptions in embedded-c++ an indirect error mechanism is necessary. Check mod load returns a bool to indicate the current error state of the runtime type information system. During object construction a call to failModLoad will cause an error code to be recorded. Once an error has been set the continuing construction will be ignored until the end of the pre/post load.
326 @param error Code of the error. */
327 static void failModLoad(OSReturn error
);
329 /*! @function checkModLoad
330 @abstract Check if the current load attempt is still OK.
331 @param loadHandle Handle returned when a successful call to preModLoad is made.
332 @result true if no error's are outstanding and the system is primed to recieve more objects. */
333 static bool checkModLoad(void *loadHandle
);
335 /*! @function postModLoad
336 @abstract Finish postprocessing on a kernel module's meta-classes.
337 @discussion As the order of static object construction is undefined it is necessary to process the constructors in two phases. These phases rely on global information that is created be the preparation step, preModLoad, which also guarantees single threading between multiple modules. Phase one was the static construction of each meta-class object one by one withing the context prepared by the preModLoad call. postModLoad is the second phase of processing. Inserts links all of the super class inheritance chains up, inserts the meta-classes into the global register of classes and records for each meta-class which kernel module caused it's construction. Finally it cleans up the temporary storage and releases the single threading lock and returns whatever error has been recorded in during the construction phase or the post processing phase.
338 @param loadHandle Handle returned when a successful call to preModLoad is made.
339 @result Error code of the first error encountered. */
340 static OSReturn
postModLoad(void *loadHandle
);
342 /*! @function modHasInstance
343 @abstract Do any of the objects represented by OSMetaClass and associated with the given kernel module name have instances?
344 @discussion Check all meta-classes associated with the module name and check their instance counts. This function is used to check to see if a module can be unloaded. Obviously if an instance is still outstanding it isn't safe to unload the code that relies on that object.
345 @param kmodName cString of the kernel module name.
346 @result true if there are any current instances of any class in the module.
348 static bool modHasInstance(const char *kmodName
);
350 /*! @function reportModInstances
351 @abstract Log any object that has instances in a module.
352 @discussion When a developer ask for a module to be unloaded but the unload fails due to outstanding instances. This function will report which classes still have instances. It is intended mostly for developers to find problems with unloading classes and will be called automatically by 'verbose' unloads.
353 @param kmodName cString of the kernel module name. */
354 static void reportModInstances(const char *kmodName
);
356 /*! @function considerUnloads
357 @abstract Schedule module unloading.
358 @discussion Schedule unused modules to be unloaded; called when IOKit matching goes idle. */
360 static void considerUnloads();
362 /*! @function allocClassWithName
363 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
364 @param name Name of the desired class.
365 @result pointer to an new object, 0 if not found or so memory. */
366 static OSObject
*allocClassWithName(const OSSymbol
*name
);
368 /*! @function allocClassWithName
369 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
370 @param name Name of the desired class.
371 @result pointer to an new object, 0 if not found or so memory. */
372 static OSObject
*allocClassWithName(const OSString
*name
);
374 /*! @function allocClassWithName
375 @abstract Lookup a meta-class in the runtime type information system and return the results of an alloc call.
376 @param name Name of the desired class.
377 @result pointer to an new object, 0 if not found or so memory. */
378 static OSObject
*allocClassWithName(const char *name
);
380 /*! @function checkMetaCastWithName
381 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
382 @param name Name of the desired class or super class.
383 @param in object to be introspected.
384 @result in parameter if cast valid, 0 otherwise. */
385 static OSMetaClassBase
*
386 checkMetaCastWithName(const OSSymbol
*name
, const OSMetaClassBase
*in
);
388 /*! @function checkMetaCastWithName
389 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
390 @param name Name of the desired class or super class.
391 @param in object to be introspected.
392 @result in parameter if cast valid, 0 otherwise. */
393 static OSMetaClassBase
*
394 checkMetaCastWithName(const OSString
*name
, const OSMetaClassBase
*in
);
396 /*! @function checkMetaCastWithName
397 @abstract Introspect an objects inheritance tree looking for a class of the given name. Basis of MacOSX's kernel dynamic casting mechanism.
398 @param name Name of the desired class or super class.
399 @param in object to be introspected.
400 @result in parameter if cast valid, 0 otherwise. */
401 static OSMetaClassBase
*
402 checkMetaCastWithName(const char *name
, const OSMetaClassBase
*in
);
405 /*! @function instanceConstructed
406 @abstract Counts the instances of the class behind this metaclass.
407 @discussion Every non-abstract class that inherits from OSObject has a default constructor that calls it's own meta-class' instanceConstructed function. This constructor is defined by the OSDefineMetaClassAndStructors macro (qv) that all OSObject subclasses must use. Also if the instance count goes from 0 to 1, ie the first instance, then increment the instance count of the super class */
408 void instanceConstructed() const;
410 /*! @function instanceDestructed
411 @abstract Removes one instance of the class behind this metaclass.
412 @discussion OSObject's free function calls this method just before it does a 'delete this' on itself. If the instance count transitions from 1 to 0, i.e. the last object, then one instance of the superclasses is also removed. */
413 void instanceDestructed() const;
416 /*! @function checkMetaCast
417 @abstract Ask a OSMetaClass instance if the given object is either an instance of it or an instance of a subclass of it.
418 @param check Pointer of object to introspect.
419 @result check parameter if cast valid, 0 otherwise. */
420 OSMetaClassBase
*checkMetaCast(const OSMetaClassBase
*check
) const;
423 /*! @function getInstanceCount
424 @abstract How many instances of the class have been created.
425 @result Count of the number of instances. */
426 unsigned int getInstanceCount() const;
429 /*! @function getSuperClass
430 @abstract 'Get'ter for the super class.
431 @result Pointer to superclass, chain ends with 0 for OSObject. */
432 const OSMetaClass
*getSuperClass() const;
434 /*! @function getClassName
435 @abstract 'Get'ter for class name.
436 @result cString of the class name. */
437 const char *getClassName() const;
439 /*! @function getClassSize
440 @abstract 'Get'ter for sizeof(class).
441 @result sizeof of class that this OSMetaClass instance represents. */
442 unsigned int getClassSize() const;
445 @abstract Allocate an instance of the class that this OSMetaClass instance represents.
446 @discussion This alloc function is analogous to the old ObjC class alloc method. Typically not used by clients as the static function allocClassWithName is more generally useful. Infact that function is implemented in terms of this virtual function. All subclass's of OSMetaClass must implement this function but that is what the OSDefineMetaClassAndStructor's families of macros does for the developer automatically.
447 @result Pointer to a new object with a retain count of 1. */
448 virtual OSObject
*alloc() const = 0;
450 /*! @function OSDeclareCommonStructors
451 @abstract Basic helper macro for the OSDeclare for Default and Abstract macros, qv. DO NOT USE.
452 @param className Name of class. NO QUOTES. */
453 #define OSDeclareCommonStructors(className) \
455 static const OSMetaClass * const superClass; \
457 static const OSMetaClass * const metaClass; \
458 static class MetaClass : public OSMetaClass { \
461 virtual OSObject *alloc() const; \
463 friend class className ::MetaClass; \
464 virtual const OSMetaClass * getMetaClass() const; \
466 className (const OSMetaClass *); \
467 virtual ~ className ()
470 /*! @function OSDeclareDefaultStructors
471 @abstract One of the macro's used in the class declaration of all subclasses of OSObject, declares runtime type information data and interfaces.
472 @discussion Macro used in the class declaration all subclasses of OSObject, declares runtime type information data and interfaces. By convention it should be 'called' immediately after the opening brace in a class declaration. It leaves the current privacy state as 'protected:'.
473 @param className Name of class. NO QUOTES. */
474 #define OSDeclareDefaultStructors(className) \
475 OSDeclareCommonStructors(className); \
481 /*! @function OSDeclareAbstractStructors
482 @abstract One of the macro's used in the class declaration of all subclasses of OSObject, declares runtime type information data and interfaces.
483 @discussion This macro is used when the class being declared has one or more '= 0' pure virtual methods and thus it is illegal to create an instance of this class. It leaves the current privacy state as 'protected:'.
484 @param className Name of class. NO QUOTES. */
485 #define OSDeclareAbstractStructors(className) \
486 OSDeclareCommonStructors(className); \
488 className (); /* Make primary constructor private in abstract */ \
491 /*! @function OSDefineMetaClassWithInit
492 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
493 @param className Name of class. NO QUOTES and NO MACROS.
494 @param superClassName Name of super class. NO QUOTES and NO MACROS.
495 @param init Name of a function to call after the OSMetaClass is constructed. */
496 #define OSDefineMetaClassWithInit(className, superClassName, init) \
497 /* Class global data */ \
498 className ::MetaClass className ::gMetaClass; \
499 const OSMetaClass * const className ::metaClass = \
500 & className ::gMetaClass; \
501 const OSMetaClass * const className ::superClass = \
502 & superClassName ::gMetaClass; \
503 /* Class member functions */ \
504 className :: className(const OSMetaClass *meta) \
505 : superClassName (meta) { } \
506 className ::~ className() { } \
507 const OSMetaClass * className ::getMetaClass() const \
508 { return &gMetaClass; } \
509 /* The ::MetaClass constructor */ \
510 className ::MetaClass::MetaClass() \
511 : OSMetaClass(#className, className::superClass, sizeof(className)) \
514 /*! @function OSDefineAbstractStructors
515 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
516 @param className Name of class. NO QUOTES and NO MACROS.
517 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
518 #define OSDefineAbstractStructors(className, superClassName) \
519 OSObject * className ::MetaClass::alloc() const { return 0; }
521 /*! @function OSDefineDefaultStructors
522 @abstract Basic helper macro for the OSDefineMetaClass for the default and Abstract macros, qv. DO NOT USE.
523 @param className Name of class. NO QUOTES and NO MACROS.
524 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
525 #define OSDefineDefaultStructors(className, superClassName) \
526 OSObject * className ::MetaClass::alloc() const \
527 { return new className; } \
528 className :: className () : superClassName (&gMetaClass) \
529 { gMetaClass.instanceConstructed(); }
532 /*! @function OSDefineMetaClassAndAbstractStructorsWithInit
533 @abstract Primary definition macro for all abstract classes that a subclasses of OSObject.
534 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that is an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class. Once the OSMetaClass has been constructed, at load time, call the init routine. NB you can not rely on the order of execution of the init routines.
535 @param className Name of class. NO QUOTES and NO MACROS.
536 @param superClassName Name of super class. NO QUOTES and NO MACROS.
537 @param init Name of a function to call after the OSMetaClass is constructed. */
538 #define OSDefineMetaClassAndAbstractStructorsWithInit(className, superClassName, init) \
539 OSDefineMetaClassWithInit(className, superClassName, init) \
540 OSDefineAbstractStructors(className, superClassName)
542 /*! @function OSDefineMetaClassAndStructorsWithInit
543 @abstract See OSDefineMetaClassAndStructors
544 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that isn't an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class. Once the OSMetaClass has been constructed, at load time, call the init routine. NB you can not rely on the order of execution of the init routines.
545 @param className Name of class. NO QUOTES and NO MACROS.
546 @param superClassName Name of super class. NO QUOTES and NO MACROS.
547 @param init Name of a function to call after the OSMetaClass is constructed. */
548 #define OSDefineMetaClassAndStructorsWithInit(className, superClassName, init) \
549 OSDefineMetaClassWithInit(className, superClassName, init) \
550 OSDefineDefaultStructors(className, superClassName)
553 /*! @function OSDefineMetaClass
554 @abstract Define an OSMetaClass instance, used for backward compatiblility only.
555 @param className Name of class. NO QUOTES and NO MACROS.
556 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
557 #define OSDefineMetaClass(className, superClassName) \
558 OSDefineMetaClassWithInit(className, superClassName, )
560 /*! @function OSDefineMetaClassAndStructors
561 @abstract Define an OSMetaClass subclass and the runtime system routines.
562 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that isn't an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class.
563 @param className Name of class. NO QUOTES and NO MACROS.
564 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
565 #define OSDefineMetaClassAndStructors(className, superClassName) \
566 OSDefineMetaClassAndStructorsWithInit(className, superClassName, )
568 /*! @function OSDefineMetaClassAndAbstractStructors
569 @abstract Define an OSMetaClass subclass and the runtime system routines.
570 @discussion Define an OSMetaClass subclass and the primary constructors and destructors for a subclass of OSObject that is an abstract class. In general this 'function' is 'called' at the top of the file just before the first function is implemented for a particular class.
571 @param className Name of class. NO QUOTES and NO MACROS.
572 @param superClassName Name of super class. NO QUOTES and NO MACROS. */
573 #define OSDefineMetaClassAndAbstractStructors(className, superClassName) \
574 OSDefineMetaClassAndAbstractStructorsWithInit (className, superClassName, )
576 // Dynamic vtable patchup support routines and types
577 void reservedCalled(int ind
) const;
579 #define OSMetaClassDeclareReservedUnused(classname, index) \
581 virtual void _RESERVED ## classname ## index ()
583 #define OSMetaClassDeclareReservedUsed(classname, index)
585 #define OSMetaClassDefineReservedUnused(classname, index) \
586 void classname ::_RESERVED ## classname ## index () \
587 { gMetaClass.reservedCalled(index); }
589 #define OSMetaClassDefineReservedUsed(classname, index)
591 // IOKit debug internal routines.
592 static void printInstanceCounts();
593 static OSDictionary
*getClassDictionary();
594 virtual bool serialize(OSSerialize
*s
) const;
596 // Virtual Padding functions for MetaClass's
597 OSMetaClassDeclareReservedUnused(OSMetaClass
, 0);
598 OSMetaClassDeclareReservedUnused(OSMetaClass
, 1);
599 OSMetaClassDeclareReservedUnused(OSMetaClass
, 2);
600 OSMetaClassDeclareReservedUnused(OSMetaClass
, 3);
601 OSMetaClassDeclareReservedUnused(OSMetaClass
, 4);
602 OSMetaClassDeclareReservedUnused(OSMetaClass
, 5);
603 OSMetaClassDeclareReservedUnused(OSMetaClass
, 6);
604 OSMetaClassDeclareReservedUnused(OSMetaClass
, 7);
607 #endif /* !_LIBKERN_OSMETACLASS_H */