本文整理汇总了C++中OSOrderedSet类的典型用法代码示例。如果您正苦于以下问题:C++ OSOrderedSet类的具体用法?C++ OSOrderedSet怎么用?C++ OSOrderedSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSOrderedSet类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: db_dumpiojunk
void db_dumpiojunk( const IORegistryPlane * plane )
{
IORegistryEntry * next;
IORegistryIterator * iter;
OSOrderedSet * all;
char format[] = "%xxxs";
IOService * service;
iter = IORegistryIterator::iterateOver( plane );
all = iter->iterateAll();
if( all) {
dbugprintf("Count %d\n", all->getCount() );
all->release();
} else dbugprintf("Empty\n");
iter->reset();
while( (next = iter->getNextObjectRecursive())) {
snprintf(format + 1, sizeof(format) - 1, "%ds", 2 * next->getDepth( plane ));
dbugprintf( format, "");
dbugprintf( "%s", next->getName( plane ));
if( (next->getLocation( plane )))
dbugprintf("@%s", next->getLocation( plane ));
dbugprintf(" <class %s", next->getMetaClass()->getClassName());
if( (service = OSDynamicCast(IOService, next)))
dbugprintf(", busy %ld", service->getBusyState());
dbugprintf( ">\n");
}
iter->release();
}
示例2: IOPrintPlane
void IOPrintPlane( const IORegistryPlane * plane )
{
IORegistryEntry * next;
IORegistryIterator * iter;
OSOrderedSet * all;
char format[] = "%xxxs";
IOService * service;
iter = IORegistryIterator::iterateOver( plane );
assert( iter );
all = iter->iterateAll();
if( all) {
DEBG("Count %d\n", all->getCount() );
all->release();
} else
DEBG("Empty\n");
iter->reset();
while( (next = iter->getNextObjectRecursive())) {
snprintf(format + 1, sizeof(format) - 1, "%ds", 2 * next->getDepth( plane ));
DEBG( format, "");
DEBG( "\033[33m%s", next->getName( plane ));
if( (next->getLocation( plane )))
DEBG("@%s", next->getLocation( plane ));
DEBG("\033[0m <class %s", next->getMetaClass()->getClassName());
if( (service = OSDynamicCast(IOService, next)))
DEBG(", busy %ld", (long) service->getBusyState());
DEBG( ">\n");
// IOSleep(250);
}
iter->release();
}
示例3: OSDynamicCast
OSCollection * OSOrderedSet::copyCollection(OSDictionary *cycleDict)
{
bool allocDict = !cycleDict;
OSCollection *ret = 0;
OSOrderedSet *newSet = 0;
if (allocDict) {
cycleDict = OSDictionary::withCapacity(16);
if (!cycleDict)
return 0;
}
do {
// Check for a cycle
ret = super::copyCollection(cycleDict);
if (ret)
continue;
// Duplicate the set with no contents
newSet = OSOrderedSet::withCapacity(capacity, ordering, orderingRef);
if (!newSet)
continue;
// Insert object into cycle Dictionary
cycleDict->setObject((const OSSymbol *) this, newSet);
newSet->capacityIncrement = capacityIncrement;
// Now copy over the contents to the new duplicate
for (unsigned int i = 0; i < count; i++) {
OSObject *obj = EXT_CAST(array[i].obj);
OSCollection *coll = OSDynamicCast(OSCollection, obj);
if (coll) {
OSCollection *newColl = coll->copyCollection(cycleDict);
if (newColl) {
obj = newColl; // Rely on cycleDict ref for a bit
newColl->release();
}
else
goto abortCopy;
};
newSet->setLastObject(obj);
};
ret = newSet;
newSet = 0;
} while (false);
abortCopy:
if (newSet)
newSet->release();
if (allocDict)
cycleDict->release();
return ret;
}
示例4: IORWLockWrite
/*********************************************************************
* Remove drivers from the catalog which match the
* properties in the matching dictionary.
*********************************************************************/
bool
IOCatalogue::removeDrivers(
OSDictionary * matching,
bool doNubMatching)
{
OSOrderedSet * set;
OSCollectionIterator * iter;
OSDictionary * dict;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
if ( !matching )
return false;
set = OSOrderedSet::withCapacity(10,
IOServiceOrdering,
(void *)gIOProbeScoreKey);
if ( !set )
return false;
iter = OSCollectionIterator::withCollection(personalities);
if (!iter)
{
set->release();
return (false);
}
IORWLockWrite(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* This comparison must be done with only the keys in the
* "matching" dict to enable general searches.
*/
if ( dict->isEqualTo(matching, matching) ) {
set->setObject(dict);
array->removeObject(idx);
idx--;
}
}
// Start device matching.
if ( doNubMatching && (set->getCount() > 0) ) {
IOService::catalogNewDrivers(set);
generation++;
}
}
IORWLockUnlock(lock);
set->release();
iter->release();
return true;
}
示例5: withCapacity
OSOrderedSet * OSOrderedSet::
withCapacity(unsigned int capacity,
OSOrderFunction ordering, void * orderingRef)
{
OSOrderedSet *me = new OSOrderedSet;
if (me && !me->initWithCapacity(capacity, ordering, orderingRef)) {
me->release();
me = 0;
}
return me;
}
示例6: IORWLockRead
/*********************************************************************
* Is personality already in the catalog?
*********************************************************************/
OSOrderedSet *
IOCatalogue::findDrivers(
OSDictionary * matching,
SInt32 * generationCount)
{
OSCollectionIterator * iter;
OSDictionary * dict;
OSOrderedSet * set;
OSArray * array;
const OSSymbol * key;
unsigned int idx;
OSKext::uniquePersonalityProperties(matching);
set = OSOrderedSet::withCapacity( 1, IOServiceOrdering,
(void *)gIOProbeScoreKey );
if (!set) return (0);
iter = OSCollectionIterator::withCollection(personalities);
if (!iter)
{
set->release();
return (0);
}
IORWLockRead(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (array) for (idx = 0; (dict = (OSDictionary *) array->getObject(idx)); idx++)
{
/* This comparison must be done with only the keys in the
* "matching" dict to enable general searches.
*/
if ( dict->isEqualTo(matching, matching) )
set->setObject(dict);
}
}
*generationCount = getGenerationCount();
IORWLockUnlock(lock);
iter->release();
return set;
}
示例7: OSDynamicCast
bool IOCatalogue::resetAndAddDrivers(OSArray * drivers, bool doNubMatching)
{
bool result = false;
OSArray * newPersonalities = NULL; // do not release
OSCollectionIterator * iter = NULL; // must release
OSOrderedSet * matchSet = NULL; // must release
const OSSymbol * key;
OSArray * array;
OSDictionary * thisNewPersonality = NULL; // do not release
OSDictionary * thisOldPersonality = NULL; // do not release
signed int idx, newIdx;
if (drivers) {
newPersonalities = OSDynamicCast(OSArray, drivers);
if (!newPersonalities) {
goto finish;
}
matchSet = OSOrderedSet::withCapacity(10, IOServiceOrdering,
(void *)gIOProbeScoreKey);
if (!matchSet) {
goto finish;
}
iter = OSCollectionIterator::withCollection(personalities);
if (!iter) {
goto finish;
}
}
result = true;
IOLog("Resetting IOCatalogue.\n");
/* No goto finish from here to unlock.
*/
IORWLockWrite(lock);
while ((key = (const OSSymbol *) iter->getNextObject()))
{
array = (OSArray *) personalities->getObject(key);
if (!array) continue;
for (idx = 0; (thisOldPersonality = (OSDictionary *) array->getObject(idx)); idx++)
{
if (thisOldPersonality->getObject("KernelConfigTable")) continue;
if (newPersonalities) for (newIdx = 0;
(thisNewPersonality = (OSDictionary *) newPersonalities->getObject(newIdx));
newIdx++)
{
/* Unlike in other functions, this comparison must be exact!
* The catalogue must be able to contain personalities that
* are proper supersets of others.
* Do not compare just the properties present in one driver
* pesonality or the other.
*/
if (thisNewPersonality->isEqualTo(thisOldPersonality))
break;
}
if (thisNewPersonality)
{
// dup, ignore
newPersonalities->removeObject(newIdx);
}
else
{
// not in new set - remove
// only remove dictionary if this module in not loaded - 9953845
if ( isModuleLoaded(thisOldPersonality) == false )
{
if (matchSet) matchSet->setObject(thisOldPersonality);
array->removeObject(idx);
idx--;
}
}
}
}
// add new
for (newIdx = 0;
(thisNewPersonality = (OSDictionary *) newPersonalities->getObject(newIdx));
newIdx++)
{
OSKext::uniquePersonalityProperties(thisNewPersonality);
addPersonality(thisNewPersonality);
matchSet->setObject(thisNewPersonality);
}
/* Finally, start device matching on all new & removed personalities.
*/
if (result && doNubMatching && (matchSet->getCount() > 0)) {
IOService::catalogNewDrivers(matchSet);
generation++;
}
IORWLockUnlock(lock);
finish:
if (matchSet) matchSet->release();
if (iter) iter->release();
return result;
//.........这里部分代码省略.........
示例8: OSDynamicCast
bool IOCatalogue::resetAndAddDrivers(OSArray * drivers, bool doNubMatching)
{
bool result = false;
OSArray * newPersonalities = NULL; // do not release
OSCollectionIterator * newPIterator = NULL; // must release
OSOrderedSet * matchSet = NULL; // must release
OSArray * oldPersonalities = NULL; // must release
OSArray * kernelPersonalities = NULL; // must release
OSString * errorString = NULL; // must release
OSObject * object = NULL; // do not release
OSDictionary * thisNewPersonality = NULL; // do not release
signed int count, i;
extern const char * gIOKernelConfigTables;
if (drivers) {
newPersonalities = OSDynamicCast(OSArray, drivers);
if (!newPersonalities) {
goto finish;
}
newPIterator = OSCollectionIterator::withCollection(newPersonalities);
if (!newPIterator) {
goto finish;
}
matchSet = OSOrderedSet::withCapacity(10, IOServiceOrdering,
(void *)gIOProbeScoreKey);
if (!matchSet) {
goto finish;
}
}
/* Read personalities for the built-in kernel driver classes.
* We don't have many any more.
*/
kernelPersonalities = OSDynamicCast(OSArray,
OSUnserialize(gIOKernelConfigTables, &errorString));
if (!kernelPersonalities && errorString) {
IOLog("KernelConfigTables syntax error: %s\n",
errorString->getCStringNoCopy());
goto finish;
}
/* Now copy the current array of personalities so we can reuse them
* if the new list contains any duplicates. This saves on memory
* consumption.
*/
oldPersonalities = OSDynamicCast(OSArray, array->copyCollection());
if (!oldPersonalities) {
goto finish;
}
result = true;
IOLog("Resetting IOCatalogue.\n");
/* No goto finish from here to unlock.
*/
IOLockLock(lock);
array->flushCollection();
/* Add back the kernel personalities and remove them from the old
* array so we don't try to match on them again. Go forward through
* the arrays as this causes the least iteration since kernel personalities
* should always be first.
*/
count = kernelPersonalities->getCount();
for (i = 0; i < count; i++) {
/* Static cast here, as the data is coming from within the kernel image.
*/
OSDictionary * thisNewPersonality = (OSDictionary *)
kernelPersonalities->getObject(i);
array->setObject(thisNewPersonality);
signed int oldPCount = oldPersonalities->getCount();
for (signed int oldPIndex = 0; oldPIndex < oldPCount; oldPIndex++) {
if (thisNewPersonality->isEqualTo(oldPersonalities->getObject(oldPIndex))) {
oldPersonalities->removeObject(oldPIndex);
break;
}
}
}
/* Now add the new set of personalities passed in, using existing
* copies if we had them in kernel memory already.
*/
if (newPIterator) {
OSDictionary * thisOldPersonality = NULL; // do not release
while ( (object = newPIterator->getNextObject()) ) {
thisNewPersonality = OSDynamicCast(OSDictionary, object);
if (!thisNewPersonality) {
IOLog("IOCatalogue::resetAndAddDrivers() encountered non-dictionary; bailing.\n");
result = false;
break;
}
//.........这里部分代码省略.........