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

int kldrDyldModUnmap ( PKLDRDYLDMOD  pMod  ) 

Unmaps the module, unlinks it from everywhere marks it PENDING_DESTROY.

Returns:
0 on success, non-zero native OS or kLdr status code on failure.
Parameters:
pMod The module which needs to be unmapped and set pending for destruction.

Definition at line 843 of file kLdrDyldMod.c.

References KLDRDYLDMOD::cRefs, KLDRDYLDMOD::enmState, KLDRDYLDMOD::fAllocatedTLS, KLDRDYLDMOD::fMapped, KLDRDYLDMOD_ASSERT, kldrDyldModUnlink(), kLdrModFreeTLS(), kLdrModUnmap(), KLDRSTATE_GC, KLDRSTATE_MAPPED, KLDRSTATE_PENDING_DESTROY, and KLDRDYLDMOD::pMod.

Referenced by kldrDyldDoModuleTerminationAndGarabageCollection(), and kldrDyldStackCleanupOne().

{
    int rc;

    /* sanity */
    KLDRDYLDMOD_ASSERT(pMod->cRefs > 0);
    KLDRDYLDMOD_ASSERT(pMod->fMapped);
    switch (pMod->enmState)
    {
        case KLDRSTATE_MAPPED:
        case KLDRSTATE_GC:
        case KLDRSTATE_PENDING_DESTROY:
            break;
        default:
            KLDRDYLDMOD_ASSERT(!"invalid state");
            return -1;
    }

    /* do the job. */
    if (pMod->fAllocatedTLS)
    {
        kLdrModFreeTLS(pMod->pMod);
        pMod->fAllocatedTLS = 0;
    }
    rc = kLdrModUnmap(pMod->pMod);
    if (!rc)
    {
        pMod->fMapped = 0;
        if (pMod->enmState < KLDRSTATE_PENDING_DESTROY)
        {
            pMod->enmState = KLDRSTATE_PENDING_DESTROY;
            kldrDyldModUnlink(pMod);
        }
    }

    return rc;
}


Generated by  Doxygen 1.6.0   Back to index