Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

int kldrDyldModDynamicUnload ( PKLDRDYLDMOD  pMod  ) 

Decrement the dynamic load count of the module and unload the module if the total reference count reaches zero.

This may cause a cascade of unloading to occure. See kldrDyldModUnloadPrerequisites().

Returns:
status code.
Return values:
0 on success.
KLDR_ERR_NOT_LOADED_DYNAMICALLY if the module wasn't loaded dynamically.
Parameters:
pMod The module to unload.

Definition at line 586 of file kLdrDyldMod.c.

References KLDRDYLDMOD::cDepRefs, KLDRDYLDMOD::cDynRefs, KLDRDYLDMOD::cRefs, KLDRDYLDMOD::enmState, KLDR_ERR_NOT_LOADED_DYNAMICALLY, KLDRDYLDMOD_ASSERT, kldrDyldModUnloadPrerequisites(), and KLDRSTATE_GOOD.

Referenced by kldrDyldDoUnload().

{
    if (pMod->cDynRefs == 0)
        return KLDR_ERR_NOT_LOADED_DYNAMICALLY;
    KLDRDYLDMOD_ASSERT(pMod->cDynRefs <= pMod->cRefs);
    KLDRDYLDMOD_ASSERT(pMod->enmState == KLDRSTATE_GOOD);

    pMod->cRefs--;
    pMod->cDynRefs--;
    if (    pMod->cDynRefs > 0
        ||  pMod->cDepRefs > 0)
        return 0;

    /*
     * The module should be unloaded.
     */
    kldrDyldModUnloadPrerequisites(pMod);
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index