AppleOpenSource/xnu-6153.101.6/iokit/Kernel/IOPMrootDomain.cpp
/* PMAssertionsTracker::createAssertion
 * createAssertion allocates memory for a new PM assertion, and affects system behavior, if
 * appropiate.
 */
:createAssertion
createAssertion allocates memory for a new PM assertion, and affects system behavior, if
appropiate.
: createAssertion createAssertion allocates memory for a new PM assertion and affects system behavior if appropiate .
IOReturn
PMAssertionsTracker::createAssertion(
	IOPMDriverAssertionType which,
	IOPMDriverAssertionLevel level,
	IOService *serviceID,
	const char *whoItIs,
	IOPMDriverAssertionID *outID)
{
	OSData          *dataStore = NULL;
	PMAssertStruct  track;
	track.id = OSIncrementAtomic64((SInt64*) &issuingUniqueID);
	track.level = level;
	track.assertionBits = which;
	track.ownerString = whoItIs ? OSSymbol::withCString(whoItIs):NULL;
	track.ownerService = serviceID;
	track.registryEntryID = serviceID ? serviceID->getRegistryEntryID():0;
	track.modifiedTime = 0;
	pmEventTimeStamp(&track.createdTime);
	dataStore = OSData::withBytes(&track, sizeof(PMAssertStruct));
	if (!dataStore) {
		if (track.ownerString) {
			track.ownerString->release();
		}
		return kIOReturnNoMemory;
	}
	*outID = track.id;
	if (owner && owner->pmPowerStateQueue) {
		owner->pmPowerStateQueue->submitPowerEvent(kPowerEventAssertionCreate, (void *)dataStore);
	}
	return kIOReturnSuccess;
}
IOReturn PMAssertionsTracker :: createAssertion ( IOPMDriverAssertionType which , IOPMDriverAssertionLevel level , IOService * serviceID , const char * whoItIs , IOPMDriverAssertionID * outID ) { OSData * dataStore = NULL ; PMAssertStruct track ; track . id = OSIncrementAtomic64 ( ( SInt64 * ) & issuingUniqueID ) ; track . level = level ; track . assertionBits = which ; track . ownerString = whoItIs ? OSSymbol :: withCString ( whoItIs ) : NULL ; track . ownerService = serviceID ; track . registryEntryID = serviceID ? serviceID -> getRegistryEntryID ( ) : 0 ; track . modifiedTime = 0 ; pmEventTimeStamp ( & track . createdTime ) ; dataStore = OSData :: withBytes ( & track , sizeof ( PMAssertStruct ) ) ; if ( ! dataStore ) { if ( track . ownerString ) { track . ownerString -> release ( ) ; } return kIOReturnNoMemory ; } * outID = track . id ; if ( owner && owner -> pmPowerStateQueue ) { owner -> pmPowerStateQueue -> submitPowerEvent ( kPowerEventAssertionCreate , ( void * ) dataStore ) ; } return kIOReturnSuccess ; }
PMAssertionsTracker::createAssertion
 createAssertion allocates memory for a new PM assertion, and affects system behavior, if
 appropiate.
PMAssertionsTracker :: createAssertion createAssertion allocates memory for a new PM assertion and affects system behavior if appropiate .
// Warning: trillions and trillions of created assertions may overflow the unique ID.