VirtualBox

Changeset 11311 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 8, 2008 11:31:54 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34406
Message:

VMM: ELEMENTS -> RT_ELEMENTS.

Location:
trunk/src/VBox/VMM
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/CPUM.cpp

    r11298 r11311  
    508508     */
    509509    PCPUMCPUID  pCpuId = &pCPUM->aGuestCpuIdStd[0];
    510     uint32_t    cElements = ELEMENTS(pCPUM->aGuestCpuIdStd);
     510    uint32_t    cElements = RT_ELEMENTS(pCPUM->aGuestCpuIdStd);
    511511    for (i=0;; )
    512512    {
     
    732732    SSMR3PutU32(pSSM, pVM->cpum.s.fChanged);
    733733
    734     SSMR3PutU32(pSSM, ELEMENTS(pVM->cpum.s.aGuestCpuIdStd));
     734    SSMR3PutU32(pSSM, RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd));
    735735    SSMR3PutMem(pSSM, &pVM->cpum.s.aGuestCpuIdStd[0], sizeof(pVM->cpum.s.aGuestCpuIdStd));
    736736
    737     SSMR3PutU32(pSSM, ELEMENTS(pVM->cpum.s.aGuestCpuIdExt));
     737    SSMR3PutU32(pSSM, RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt));
    738738    SSMR3PutMem(pSSM, &pVM->cpum.s.aGuestCpuIdExt[0], sizeof(pVM->cpum.s.aGuestCpuIdExt));
    739739
    740     SSMR3PutU32(pSSM, ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur));
     740    SSMR3PutU32(pSSM, RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdCentaur));
    741741    SSMR3PutMem(pSSM, &pVM->cpum.s.aGuestCpuIdCentaur[0], sizeof(pVM->cpum.s.aGuestCpuIdCentaur));
    742742
     
    785785    int rc = SSMR3GetU32(pSSM, &cElements); AssertRCReturn(rc, rc);
    786786    /* Support old saved states with a smaller standard cpuid array. */
    787     if (cElements > ELEMENTS(pVM->cpum.s.aGuestCpuIdStd))
     787    if (cElements > RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd))
    788788        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    789789    SSMR3GetMem(pSSM, &pVM->cpum.s.aGuestCpuIdStd[0], cElements*sizeof(pVM->cpum.s.aGuestCpuIdStd[0]));
    790790
    791791    rc = SSMR3GetU32(pSSM, &cElements); AssertRCReturn(rc, rc);
    792     if (cElements != ELEMENTS(pVM->cpum.s.aGuestCpuIdExt))
     792    if (cElements != RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt))
    793793        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    794794    SSMR3GetMem(pSSM, &pVM->cpum.s.aGuestCpuIdExt[0], sizeof(pVM->cpum.s.aGuestCpuIdExt));
     
    876876    };
    877877    char *psz = pszEFlags;
    878     for (unsigned i = 0; i < ELEMENTS(s_aFlags); i++)
     878    for (unsigned i = 0; i < RT_ELEMENTS(s_aFlags); i++)
    879879    {
    880880        const char *pszAdd = s_aFlags[i].fFlag & efl ? s_aFlags[i].pszSet : s_aFlags[i].pszClear;
     
    15421542                    "         RAW Extended CPUIDs\n"
    15431543                    "     Function  eax      ebx      ecx      edx\n");
    1544     for (unsigned i = 0; i < ELEMENTS(pVM->cpum.s.aGuestCpuIdExt); i++)
     1544    for (unsigned i = 0; i < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt); i++)
    15451545    {
    15461546        Guest = pVM->cpum.s.aGuestCpuIdExt[i];
  • trunk/src/VBox/VMM/DBGF.cpp

    r9421 r11311  
    562562        RTGCPTR eip = pCtx->rip + pCtx->csHid.u64Base;
    563563#endif
    564         for (iBp = 0; iBp < ELEMENTS(pVM->dbgf.s.aBreakpoints); iBp++)
     564        for (iBp = 0; iBp < RT_ELEMENTS(pVM->dbgf.s.aBreakpoints); iBp++)
    565565            if (    pVM->dbgf.s.aBreakpoints[iBp].enmType == DBGFBPTYPE_REM
    566566                &&  pVM->dbgf.s.aBreakpoints[iBp].GCPtr == eip)
  • trunk/src/VBox/VMM/DBGFBp.cpp

    r8155 r11311  
    6868     */
    6969    unsigned i;
    70     for (i = 0; i < ELEMENTS(pVM->dbgf.s.aHwBreakpoints); i++)
     70    for (i = 0; i < RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints); i++)
    7171    {
    7272        pVM->dbgf.s.aHwBreakpoints[i].iBp = i;
     
    7575    }
    7676
    77     for (i = 0; i < ELEMENTS(pVM->dbgf.s.aBreakpoints); i++)
    78     {
    79         pVM->dbgf.s.aBreakpoints[i].iBp = i + ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
     77    for (i = 0; i < RT_ELEMENTS(pVM->dbgf.s.aBreakpoints); i++)
     78    {
     79        pVM->dbgf.s.aBreakpoints[i].iBp = i + RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
    8080        pVM->dbgf.s.aBreakpoints[i].enmType = DBGFBPTYPE_FREE;
    8181    }
     
    110110    {
    111111        case DBGFBPTYPE_REG:
    112             cBps = ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
     112            cBps = RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
    113113            paBps = &pVM->dbgf.s.aHwBreakpoints[0];
    114114            pcBpsCur = &pVM->dbgf.s.cHwBreakpoints;
     
    117117        case DBGFBPTYPE_INT3:
    118118        case DBGFBPTYPE_REM:
    119             cBps = ELEMENTS(pVM->dbgf.s.aBreakpoints);
     119            cBps = RT_ELEMENTS(pVM->dbgf.s.aBreakpoints);
    120120            paBps = &pVM->dbgf.s.aBreakpoints[0];
    121121            pcBpsCur = &pVM->dbgf.s.cBreakpoints;
     
    156156    /* Find it. */
    157157    PDBGFBP pBp;
    158     if (iBp < ELEMENTS(pVM->dbgf.s.aHwBreakpoints))
     158    if (iBp < RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints))
    159159        pBp = &pVM->dbgf.s.aHwBreakpoints[iBp];
    160160    else
    161161    {
    162         iBp -= ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
    163         if (iBp >= ELEMENTS(pVM->dbgf.s.aBreakpoints))
     162        iBp -= RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
     163        if (iBp >= RT_ELEMENTS(pVM->dbgf.s.aBreakpoints))
    164164            return NULL;
    165165        pBp = &pVM->dbgf.s.aBreakpoints[iBp];
     
    205205    {
    206206        case DBGFBPTYPE_REG:
    207             cBps = ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
     207            cBps = RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
    208208            paBps = &pVM->dbgf.s.aHwBreakpoints[0];
    209209            break;
     
    211211        case DBGFBPTYPE_INT3:
    212212        case DBGFBPTYPE_REM:
    213             cBps = ELEMENTS(pVM->dbgf.s.aBreakpoints);
     213            cBps = RT_ELEMENTS(pVM->dbgf.s.aBreakpoints);
    214214            paBps = &pVM->dbgf.s.aBreakpoints[0];
    215215            break;
     
    957957     */
    958958    unsigned i;
    959     for (i = 0; i < ELEMENTS(pVM->dbgf.s.aHwBreakpoints); i++)
     959    for (i = 0; i < RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints); i++)
    960960        if (pVM->dbgf.s.aHwBreakpoints[i].enmType != DBGFBPTYPE_FREE)
    961961        {
     
    968968     * Enumerate the other breakpoints.
    969969     */
    970     for (i = 0; i < ELEMENTS(pVM->dbgf.s.aBreakpoints); i++)
     970    for (i = 0; i < RT_ELEMENTS(pVM->dbgf.s.aBreakpoints); i++)
    971971        if (pVM->dbgf.s.aBreakpoints[i].enmType != DBGFBPTYPE_FREE)
    972972        {
  • trunk/src/VBox/VMM/PATM/CSAM.cpp

    r9675 r11311  
    198198    if (!fRegisteredCmds)
    199199    {
    200         int rc = DBGCRegisterCommands(&g_aCmds[0], ELEMENTS(g_aCmds));
     200        int rc = DBGCRegisterCommands(&g_aCmds[0], RT_ELEMENTS(g_aCmds));
    201201        if (VBOX_SUCCESS(rc))
    202202            fRegisteredCmds = true;
     
    24052405                AssertRC(rc);   /* can't fail */
    24062406
    2407                 for (unsigned i=0;i<ELEMENTS(aOpenBsdPushCSOffset);i++)
     2407                for (unsigned i=0;i<RT_ELEMENTS(aOpenBsdPushCSOffset);i++)
    24082408                {
    24092409                    rc = CPUMR3DisasmInstrCPU(pVM, pCtx, pHandler - aOpenBsdPushCSOffset[i], &cpu, NULL);
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r9675 r11311  
    184184    if (!fRegisteredCmds)
    185185    {
    186         int rc = DBGCRegisterCommands(&g_aCmds[0], ELEMENTS(g_aCmds));
     186        int rc = DBGCRegisterCommands(&g_aCmds[0], RT_ELEMENTS(g_aCmds));
    187187        if (VBOX_SUCCESS(rc))
    188188            fRegisteredCmds = true;
     
    324324    memset(pVM->patm.s.pGCStateHC, 0, PAGE_SIZE);
    325325    AssertReleaseMsg(pVM->patm.s.pGCStateGC, ("Impossible! MMHyperHC2GC(%p) failed!\n", pVM->patm.s.pGCStateGC));
    326    
     326
    327327    Log(("Patch memory allocated at %p - %VRv\n", pVM->patm.s.pPatchMemHC, pVM->patm.s.pPatchMemGC));
    328328    pVM->patm.s.pGCStateHC->uVMFlags = X86_EFL_IF;
  • trunk/src/VBox/VMM/PDM.cpp

    r11299 r11311  
    298298     * The register PCI Buses.
    299299     */
    300     for (unsigned i = 0; i < ELEMENTS(pVM->pdm.s.aPciBuses); i++)
     300    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pdm.s.aPciBuses); i++)
    301301    {
    302302        if (pVM->pdm.s.aPciBuses[i].pDevInsRC)
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r11261 r11311  
    24112411     */
    24122412    unsigned iBus = 0;
    2413     for (iBus = 0; iBus < ELEMENTS(pVM->pdm.s.aPciBuses); iBus++)
     2413    for (iBus = 0; iBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses); iBus++)
    24142414        if (!pVM->pdm.s.aPciBuses[iBus].pDevInsR3)
    24152415            break;
    2416     if (iBus >= ELEMENTS(pVM->pdm.s.aPciBuses))
    2417     {
    2418         AssertMsgFailed(("Too many PCI buses. Max=%u\n", ELEMENTS(pVM->pdm.s.aPciBuses)));
     2416    if (iBus >= RT_ELEMENTS(pVM->pdm.s.aPciBuses))
     2417    {
     2418        AssertMsgFailed(("Too many PCI buses. Max=%u\n", RT_ELEMENTS(pVM->pdm.s.aPciBuses)));
    24192419        LogFlow(("pdmR3DevHlp_PCIBusRegister: caller='%s'/%d: returns %Vrc (pci bus)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER));
    24202420        return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r10710 r11311  
    906906    int rc = VINF_SUCCESS;
    907907    PVM pVM = pDrvIns->Internal.s.pVM;
    908     if (pVM->pdm.s.cPollers < ELEMENTS(pVM->pdm.s.apfnPollers))
     908    if (pVM->pdm.s.cPollers < RT_ELEMENTS(pVM->pdm.s.apfnPollers))
    909909    {
    910910        pVM->pdm.s.apfnPollers[pVM->pdm.s.cPollers] = pfnPoller;
  • trunk/src/VBox/VMM/PGM.cpp

    r11299 r11311  
    11301130    pVM->pgm.s.pGstPaePDPTHC    = NULL;
    11311131    pVM->pgm.s.pGstPaePDPTGC    = 0;
    1132     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apGstPaePDsHC); i++)
     1132    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apGstPaePDsHC); i++)
    11331133    {
    11341134        pVM->pgm.s.apGstPaePDsHC[i]             = NULL;
     
    12501250        if (!fRegisteredCmds)
    12511251        {
    1252             int rc = DBGCRegisterCommands(&g_aCmds[0], ELEMENTS(g_aCmds));
     1252            int rc = DBGCRegisterCommands(&g_aCmds[0], RT_ELEMENTS(g_aCmds));
    12531253            if (VBOX_SUCCESS(rc))
    12541254                fRegisteredCmds = true;
     
    13521352
    13531353    ASMMemZeroPage(pVM->pgm.s.pInterPaePDPT);
    1354     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apInterPaePDs); i++)
     1354    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apInterPaePDs); i++)
    13551355    {
    13561356        ASMMemZeroPage(pVM->pgm.s.apInterPaePDs[i]);
     
    13591359    }
    13601360
    1361     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.pInterPaePDPT64->a); i++)
    1362     {
    1363         const unsigned iPD = i % ELEMENTS(pVM->pgm.s.apInterPaePDs);
     1361    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.pInterPaePDPT64->a); i++)
     1362    {
     1363        const unsigned iPD = i % RT_ELEMENTS(pVM->pgm.s.apInterPaePDs);
    13641364        pVM->pgm.s.pInterPaePDPT64->a[i].u = X86_PDPE_P | X86_PDPE_RW | X86_PDPE_US | X86_PDPE_A | PGM_PLXFLAGS_PERMANENT
    13651365                                            | MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[iPD]);
     
    13671367
    13681368    RTHCPHYS HCPhysInterPaePDPT64 = MMPage2Phys(pVM, pVM->pgm.s.pInterPaePDPT64);
    1369     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.pInterPaePML4->a); i++)
     1369    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.pInterPaePML4->a); i++)
    13701370        pVM->pgm.s.pInterPaePML4->a[i].u = X86_PML4E_P | X86_PML4E_RW | X86_PML4E_US | X86_PML4E_A | PGM_PLXFLAGS_PERMANENT
    13711371                                         | HCPhysInterPaePDPT64;
     
    14171417    ASMMemZero32(pVM->pgm.s.pHCPaePDPT, PAGE_SIZE);
    14181418    ASMMemZero32(pVM->pgm.s.pHCNestedRoot, PAGE_SIZE);
    1419     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apHCPaePDs); i++)
     1419    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apHCPaePDs); i++)
    14201420    {
    14211421        ASMMemZero32(pVM->pgm.s.apHCPaePDs[i], PAGE_SIZE);
     
    17121712     * Reserve space for mapping the paging pages into guest context.
    17131713     */
    1714     int rc = MMR3HyperReserve(pVM, PAGE_SIZE * (2 + ELEMENTS(pVM->pgm.s.apHCPaePDs) + 1 + 2 + 2), "Paging", &GCPtr);
     1714    int rc = MMR3HyperReserve(pVM, PAGE_SIZE * (2 + RT_ELEMENTS(pVM->pgm.s.apHCPaePDs) + 1 + 2 + 2), "Paging", &GCPtr);
    17151715    AssertRCReturn(rc, rc);
    17161716    pVM->pgm.s.pGC32BitPD = GCPtr;
     
    17611761    GCPtr += PAGE_SIZE; /* reserved page */
    17621762
    1763     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apHCPaePDs); i++)
     1763    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apHCPaePDs); i++)
    17641764    {
    17651765        rc = PGMMap(pVM, GCPtr, pVM->pgm.s.aHCPhysPaePDs[i], PAGE_SIZE, 0);
     
    17961796    /* init cache */
    17971797    RTHCPHYS HCPhysDummy = MMR3PageDummyHCPhys(pVM);
    1798     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache); i++)
     1798    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache); i++)
    17991799        pVM->pgm.s.aHCPhysDynPageMapCache[i] = HCPhysDummy;
    18001800
     
    18291829    pVM->pgm.s.pGC32BitPD    += offDelta;
    18301830    pVM->pgm.s.pGuestPDGC    += offDelta;
    1831     AssertCompile(ELEMENTS(pVM->pgm.s.apGCPaePDs) == ELEMENTS(pVM->pgm.s.apGstPaePDsGC));
    1832     for (unsigned i = 0; i < ELEMENTS(pVM->pgm.s.apGCPaePDs); i++)
     1831    AssertCompile(RT_ELEMENTS(pVM->pgm.s.apGCPaePDs) == RT_ELEMENTS(pVM->pgm.s.apGstPaePDsGC));
     1832    for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.apGCPaePDs); i++)
    18331833    {
    18341834        pVM->pgm.s.apGCPaePDs[i]    += offDelta;
     
    25392539     * Iterate the page directory.
    25402540     */
    2541     for (unsigned iPD = 0; iPD < ELEMENTS(pPDSrc->a); iPD++)
     2541    for (unsigned iPD = 0; iPD < RT_ELEMENTS(pPDSrc->a); iPD++)
    25422542    {
    25432543        X86PDE PdeSrc = pPDSrc->a[iPD];
     
    34223422static int  pgmR3DumpHierarchyHCPaePT(PVM pVM, PX86PTPAE pPT, uint64_t u64Address, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp)
    34233423{
    3424     for (unsigned i = 0; i < ELEMENTS(pPT->a); i++)
     3424    for (unsigned i = 0; i < RT_ELEMENTS(pPT->a); i++)
    34253425    {
    34263426        X86PTEPAE Pte = pPT->a[i];
     
    34753475
    34763476    int rc = VINF_SUCCESS;
    3477     for (unsigned i = 0; i < ELEMENTS(pPD->a); i++)
     3477    for (unsigned i = 0; i < RT_ELEMENTS(pPD->a); i++)
    34783478    {
    34793479        X86PDEPAE Pde = pPD->a[i];
     
    35823582
    35833583    int rc = VINF_SUCCESS;
    3584     const unsigned c = fLongMode ? ELEMENTS(pPDPT->a) : X86_PG_PAE_PDPE_ENTRIES;
     3584    const unsigned c = fLongMode ? RT_ELEMENTS(pPDPT->a) : X86_PG_PAE_PDPE_ENTRIES;
    35853585    for (unsigned i = 0; i < c; i++)
    35863586    {
     
    36513651
    36523652    int rc = VINF_SUCCESS;
    3653     for (unsigned i = 0; i < ELEMENTS(pPML4->a); i++)
     3653    for (unsigned i = 0; i < RT_ELEMENTS(pPML4->a); i++)
    36543654    {
    36553655        X86PML4E Pml4e = pPML4->a[i];
     
    36973697int  pgmR3DumpHierarchyHC32BitPT(PVM pVM, PX86PT pPT, uint32_t u32Address, PCDBGFINFOHLP pHlp)
    36983698{
    3699     for (unsigned i = 0; i < ELEMENTS(pPT->a); i++)
     3699    for (unsigned i = 0; i < RT_ELEMENTS(pPT->a); i++)
    37003700    {
    37013701        X86PTE Pte = pPT->a[i];
     
    37433743
    37443744    int rc = VINF_SUCCESS;
    3745     for (unsigned i = 0; i < ELEMENTS(pPD->a); i++)
     3745    for (unsigned i = 0; i < RT_ELEMENTS(pPD->a); i++)
    37463746    {
    37473747        X86PDE Pde = pPD->a[i];
     
    38273827int pgmR3DumpHierarchyGC32BitPT(PVM pVM, PX86PT pPT, uint32_t u32Address, RTGCPHYS PhysSearch)
    38283828{
    3829     for (unsigned i = 0; i < ELEMENTS(pPT->a); i++)
     3829    for (unsigned i = 0; i < RT_ELEMENTS(pPT->a); i++)
    38303830    {
    38313831        X86PTE Pte = pPT->a[i];
     
    39053905         cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "Address"));
    39063906
    3907     for (unsigned i = 0; i < ELEMENTS(pPD->a); i++)
     3907    for (unsigned i = 0; i < RT_ELEMENTS(pPD->a); i++)
    39083908    {
    39093909        X86PDE Pde = pPD->a[i];
  • trunk/src/VBox/VMM/PGMMap.cpp

    r11299 r11311  
    894894     */
    895895    const unsigned  cPTs = pMapping->cPTs;
    896     unsigned        iPDNew = ELEMENTS(pPDSrc->a) - cPTs; /* (+ 1 - 1) */
     896    unsigned        iPDNew = RT_ELEMENTS(pPDSrc->a) - cPTs; /* (+ 1 - 1) */
    897897    while (iPDNew-- > 0)
    898898    {
     
    963963         */
    964964        const unsigned  cPTs = pMapping->cb >> X86_PD_PAE_SHIFT;
    965         unsigned        iPDNew = ELEMENTS(pPDSrc->a) - cPTs; /* (+ 1 - 1) */
     965        unsigned        iPDNew = RT_ELEMENTS(pPDSrc->a) - cPTs; /* (+ 1 - 1) */
    966966
    967967        while (iPDNew-- > 0)
     
    11501150            unsigned iPT  = off >> X86_PD_SHIFT;
    11511151            unsigned iPTE = (off >> PAGE_SHIFT) & X86_PT_MASK;
    1152             while (cb > 0 && iPTE < ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a))
     1152            while (cb > 0 && iPTE < RT_ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a))
    11531153            {
    11541154                if (!CTXALLSUFF(pCur->aPTs[iPT].paPaePTs)[iPTE / 512].a[iPTE % 512].n.u1Present)
  • trunk/src/VBox/VMM/PGMPool.cpp

    r10032 r11311  
    220220#endif
    221221#ifdef PGMPOOL_WITH_CACHE
    222     for (unsigned i = 0; i < ELEMENTS(pPool->aiHash); i++)
     222    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aiHash); i++)
    223223        pPool->aiHash[i] = NIL_PGMPOOL_IDX;
    224224    pPool->iAgeHead = NIL_PGMPOOL_IDX;
     
    259259        pPool->aPages[PGMPOOL_IDX_PAE_PD_0 + i].idx       = PGMPOOL_IDX_PAE_PD_0 + i;
    260260    }
    261  
     261
    262262    /* The Shadow PDPT. */
    263263    pPool->aPages[PGMPOOL_IDX_PDPT].Core.Key  = NIL_RTHCPHYS;
  • trunk/src/VBox/VMM/STAM.cpp

    r8155 r11311  
    148148{
    149149    /* pszCmd,      cArgsMin, cArgsMax, paArgDesc,          cArgDescs,                  pResultDesc,        fFlags,     pfnHandler          pszSyntax,          ....pszDescription */
    150     { "stats",      0,        1,        &g_aArgPat[0],      ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStats,     "[pattern]",        "Display statistics." },
    151     { "statsreset", 0,        1,        &g_aArgPat[0],      ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStatsReset,"[pattern]",        "Resets statistics." }
     150    { "stats",      0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStats,     "[pattern]",        "Display statistics." },
     151    { "statsreset", 0,        1,        &g_aArgPat[0],      RT_ELEMENTS(g_aArgPat),        NULL,               0,          stamR3CmdStatsReset,"[pattern]",        "Resets statistics." }
    152152};
    153153#endif
     
    221221    if (!fRegisteredCmds)
    222222    {
    223         int rc = DBGCRegisterCommands(&g_aCmds[0], ELEMENTS(g_aCmds));
     223        int rc = DBGCRegisterCommands(&g_aCmds[0], RT_ELEMENTS(g_aCmds));
    224224        if (VBOX_SUCCESS(rc))
    225225            fRegisteredCmds = true;
  • trunk/src/VBox/VMM/TM.cpp

    r11299 r11311  
    647647    uint64_t                au64Samples[5];
    648648    unsigned                i;
    649     for (i = 0; i < ELEMENTS(au64Samples); i++)
     649    for (i = 0; i < RT_ELEMENTS(au64Samples); i++)
    650650    {
    651651        unsigned    cMillies;
     
    674674    unsigned iHigh = 0;
    675675    unsigned iLow = 0;
    676     for (i = 1; i < ELEMENTS(au64Samples); i++)
     676    for (i = 1; i < RT_ELEMENTS(au64Samples); i++)
    677677    {
    678678        if (au64Samples[i] < au64Samples[iLow])
     
    685685
    686686    u64Hz = au64Samples[0];
    687     for (i = 1; i < ELEMENTS(au64Samples); i++)
     687    for (i = 1; i < RT_ELEMENTS(au64Samples); i++)
    688688        u64Hz += au64Samples[i];
    689     u64Hz /= ELEMENTS(au64Samples) - 2;
     689    u64Hz /= RT_ELEMENTS(au64Samples) - 2;
    690690
    691691    return u64Hz;
  • trunk/src/VBox/VMM/TRPM.cpp

    r11299 r11311  
    431431    AssertRelease(!(RT_OFFSETOF(VM, trpm.s.aIdt) & 15));
    432432    AssertRelease(sizeof(pVM->trpm.s) <= sizeof(pVM->trpm.padding));
    433     AssertRelease(ELEMENTS(pVM->trpm.s.aGuestTrapHandler) == sizeof(pVM->trpm.s.au32IdtPatched)*8);
     433    AssertRelease(RT_ELEMENTS(pVM->trpm.s.aGuestTrapHandler) == sizeof(pVM->trpm.s.au32IdtPatched)*8);
    434434
    435435    /*
     
    573573    PVBOXIDTE pIdte = &pVM->trpm.s.aIdt[0];
    574574    PVBOXIDTE_GENERIC pIdteTemplate = &g_aIdt[0];
    575     for (unsigned i = 0; i < ELEMENTS(pVM->trpm.s.aIdt); i++, pIdte++, pIdteTemplate++)
     575    for (unsigned i = 0; i < RT_ELEMENTS(pVM->trpm.s.aIdt); i++, pIdte++, pIdteTemplate++)
    576576    {
    577577        if (    pIdte->Gen.u1Present
     
    631631
    632632    /* Relocate IDT handlers for forwarding guest traps/interrupts. */
    633     for (uint32_t iTrap = 0; iTrap < ELEMENTS(pVM->trpm.s.aGuestTrapHandler); iTrap++)
     633    for (uint32_t iTrap = 0; iTrap < RT_ELEMENTS(pVM->trpm.s.aGuestTrapHandler); iTrap++)
    634634    {
    635635        if (pVM->trpm.s.aGuestTrapHandler[iTrap] != TRPM_INVALID_HANDLER)
     
    748748     * Save any trampoline gates.
    749749     */
    750     for (uint32_t iTrap = 0; iTrap < ELEMENTS(pTrpm->aGuestTrapHandler); iTrap++)
     750    for (uint32_t iTrap = 0; iTrap < RT_ELEMENTS(pTrpm->aGuestTrapHandler); iTrap++)
    751751    {
    752752        if (pTrpm->aGuestTrapHandler[iTrap])
     
    847847        if (iTrap == (uint32_t)~0)
    848848            break;
    849         if (    iTrap >= ELEMENTS(pTrpm->aIdt)
     849        if (    iTrap >= RT_ELEMENTS(pTrpm->aIdt)
    850850            ||  pTrpm->aGuestTrapHandler[iTrap])
    851851        {
     
    10601060
    10611061    if (    iTrap < TRPM_HANDLER_INT_BASE
    1062         ||  iTrap >= ELEMENTS(pVM->trpm.s.aIdt))
     1062        ||  iTrap >= RT_ELEMENTS(pVM->trpm.s.aIdt))
    10631063    {
    10641064        AssertMsg(iTrap < TRPM_HANDLER_INT_BASE, ("Illegal gate number %#x!\n", iTrap));
     
    11091109TRPMR3DECL(uint32_t) TRPMR3QueryGateByHandler(PVM pVM, RTRCPTR GCPtr)
    11101110{
    1111     for (uint32_t iTrap = 0; iTrap < ELEMENTS(pVM->trpm.s.aGuestTrapHandler); iTrap++)
     1111    for (uint32_t iTrap = 0; iTrap < RT_ELEMENTS(pVM->trpm.s.aGuestTrapHandler); iTrap++)
    11121112    {
    11131113        if (pVM->trpm.s.aGuestTrapHandler[iTrap] == GCPtr)
     
    11371137TRPMR3DECL(RTRCPTR) TRPMR3GetGuestTrapHandler(PVM pVM, unsigned iTrap)
    11381138{
    1139     AssertReturn(iTrap < ELEMENTS(pVM->trpm.s.aIdt), TRPM_INVALID_HANDLER);
     1139    AssertReturn(iTrap < RT_ELEMENTS(pVM->trpm.s.aIdt), TRPM_INVALID_HANDLER);
    11401140
    11411141    return pVM->trpm.s.aGuestTrapHandler[iTrap];
     
    11571157     * Validate.
    11581158     */
    1159     if (iTrap >= ELEMENTS(pVM->trpm.s.aIdt))
     1159    if (iTrap >= RT_ELEMENTS(pVM->trpm.s.aIdt))
    11601160    {
    11611161        AssertMsg(iTrap < TRPM_HANDLER_INT_BASE, ("Illegal gate number %d!\n", iTrap));
  • trunk/src/VBox/VMM/VMM.cpp

    r11141 r11311  
    225225     */
    226226    unsigned cbCoreCode = 0;
    227     for (unsigned iSwitcher = 0; iSwitcher < ELEMENTS(s_apSwitchers); iSwitcher++)
     227    for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++)
    228228    {
    229229        pVM->vmm.s.aoffSwitchers[iSwitcher] = cbCoreCode;
     
    298298         * copy the code.
    299299         */
    300         for (unsigned iSwitcher = 0; iSwitcher < ELEMENTS(s_apSwitchers); iSwitcher++)
     300        for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++)
    301301        {
    302302            PVMMSWITCHERDEF pSwitcher = s_apSwitchers[iSwitcher];
     
    817817     * All the switchers.
    818818     */
    819     for (unsigned iSwitcher = 0; iSwitcher < ELEMENTS(s_apSwitchers); iSwitcher++)
     819    for (unsigned iSwitcher = 0; iSwitcher < RT_ELEMENTS(s_apSwitchers); iSwitcher++)
    820820    {
    821821        PVMMSWITCHERDEF pSwitcher = s_apSwitchers[iSwitcher];
     
    26542654        { "cfgm",           NULL },
    26552655    };
    2656     for (unsigned i = 0; i < ELEMENTS(aInfo); i++)
     2656    for (unsigned i = 0; i < RT_ELEMENTS(aInfo); i++)
    26572657    {
    26582658        if (fDoneHyper && !strcmp(aInfo[i].pszInfo, "cpumhyper"))
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r11299 r11311  
    966966{
    967967    PCCPUMCPUID pCpuId;
    968     if (iLeaf < ELEMENTS(pVM->cpum.s.aGuestCpuIdStd))
     968    if (iLeaf < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdStd))
    969969        pCpuId = &pVM->cpum.s.aGuestCpuIdStd[iLeaf];
    970970    else if (iLeaf - UINT32_C(0x80000000) < RT_ELEMENTS(pVM->cpum.s.aGuestCpuIdExt))
  • trunk/src/VBox/VMM/VMMAll/DBGFAll.cpp

    r8155 r11311  
    4141    RTGCUINTREG uDr7 = X86_DR7_GD | X86_DR7_GE | X86_DR7_LE | X86_DR7_MB1_MASK;
    4242    PDBGFBP     pBp = &pVM->dbgf.s.aHwBreakpoints[0];
    43     unsigned    cLeft = ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
     43    unsigned    cLeft = RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
    4444    while (cLeft-- > 0)
    4545    {
  • trunk/src/VBox/VMM/VMMAll/MMAllHyper.cpp

    r8155 r11311  
    809809     * Check poison.
    810810     */
    811     unsigned i = ELEMENTS(pHeap->aDelayedFrees);
     811    unsigned i = RT_ELEMENTS(pHeap->aDelayedFrees);
    812812    while (i-- > 0)
    813813        if (pHeap->aDelayedFrees[i].offChunk)
     
    836836    pHeap->aDelayedFrees[pHeap->iDelayedFree].offChunk = (uintptr_t)pChunk - (uintptr_t)pHeap;
    837837    pHeap->aDelayedFrees[pHeap->iDelayedFree].uCaller = (uintptr_t)ASMReturnAddress();
    838     pHeap->iDelayedFree = (pHeap->iDelayedFree + 1) % ELEMENTS(pHeap->aDelayedFrees);
     838    pHeap->iDelayedFree = (pHeap->iDelayedFree + 1) % RT_ELEMENTS(pHeap->aDelayedFrees);
    839839
    840840#else   /* !MMHYPER_HEAP_FREE_POISON */
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r10822 r11311  
    16071607                        const unsigned  offPTSrc  = 0;
    16081608#  endif
    1609                         const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, ELEMENTS(pPTDst->a));
     1609                        const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, RT_ELEMENTS(pPTDst->a));
    16101610                        if (iPTDst < PGM_SYNC_NR_PAGES / 2)
    16111611                            iPTDst = 0;
     
    18081808         */
    18091809        unsigned        iPTDst    = (GCPtrPage >> SHW_PT_SHIFT) & SHW_PT_MASK;
    1810         const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, ELEMENTS(pPTDst->a));
     1810        const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, RT_ELEMENTS(pPTDst->a));
    18111811        if (iPTDst < PGM_SYNC_NR_PAGES / 2)
    18121812            iPTDst = 0;
     
    24082408                unsigned        iPTBase   = (GCPtrPage >> SHW_PT_SHIFT) & SHW_PT_MASK;
    24092409                unsigned        iPTDst    = iPTBase;
    2410                 const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, ELEMENTS(pPTDst->a));
     2410                const unsigned  iPTDstEnd = RT_MIN(iPTDst + PGM_SYNC_NR_PAGES / 2, RT_ELEMENTS(pPTDst->a));
    24112411                if (iPTDst <= PGM_SYNC_NR_PAGES / 2)
    24122412                    iPTDst = 0;
     
    24152415# else /* !PGM_SYNC_N_PAGES */
    24162416                unsigned        iPTDst    = 0;
    2417                 const unsigned  iPTDstEnd = ELEMENTS(pPTDst->a);
     2417                const unsigned  iPTDstEnd = RT_ELEMENTS(pPTDst->a);
    24182418# endif /* !PGM_SYNC_N_PAGES */
    24192419# if PGM_SHW_TYPE == PGM_TYPE_PAE && PGM_GST_TYPE == PGM_TYPE_32BIT
     
    25082508            PPGMRAMRANGE      pRam   = CTXALLSUFF(pVM->pgm.s.pRamRanges);
    25092509            unsigned          iPTDst = 0;
    2510             while (iPTDst < ELEMENTS(pPTDst->a))
     2510            while (iPTDst < RT_ELEMENTS(pPTDst->a))
    25112511            {
    25122512                /* Advance ram range list. */
     
    25732573                        iHCPage++;
    25742574                        iPTDst++;
    2575                     } while (   iPTDst < ELEMENTS(pPTDst->a)
     2575                    } while (   iPTDst < RT_ELEMENTS(pPTDst->a)
    25762576                             && GCPhys <= pRam->GCPhysLast);
    25772577                }
     
    25842584                        GCPhys += PAGE_SIZE;
    25852585                        iPTDst++;
    2586                     } while (   iPTDst < ELEMENTS(pPTDst->a)
     2586                    } while (   iPTDst < RT_ELEMENTS(pPTDst->a)
    25872587                             && GCPhys < pRam->GCPhys);
    25882588                }
     
    25902590                {
    25912591                    Log(("Invalid pages at %VGp (2)\n", GCPhys));
    2592                     for ( ; iPTDst < ELEMENTS(pPTDst->a); iPTDst++)
     2592                    for ( ; iPTDst < RT_ELEMENTS(pPTDst->a); iPTDst++)
    25932593                        pPTDst->a[iPTDst].u = 0; /* MMIO or invalid page, we must handle them manually. */
    25942594                }
     
    30213021    PGM_GST_NAME(HandlerVirtualUpdate)(pVM, cr4);
    30223022    STAM_PROFILE_STOP(&pVM->pgm.s.CTXMID(Stat,SyncCR3Handlers), h);
    3023 #endif 
     3023#endif
    30243024
    30253025#ifdef PGMPOOL_WITH_MONITORING
     
    31413141                    LogFlow(("SyncCR3: guest PDPE %d not present; clear shw pdpe\n", iPdpte));
    31423142                        /* for each page directory entry */
    3143                         for (unsigned iPD = 0; iPD < ELEMENTS(pPDSrc->a); iPD++)
     3143                        for (unsigned iPD = 0; iPD < RT_ELEMENTS(pPDSrc->a); iPD++)
    31443144                        {
    31453145                            if (   pPDEDst[iPD].n.u1Present
     
    31833183
    31843184            /* Fetch the pgm pool shadow descriptor if the shadow pdpte is present. */
    3185             if (!pPdpeDst->n.u1Present) 
     3185            if (!pPdpeDst->n.u1Present)
    31863186                continue;   /* next PDPTE */
    31873187
     
    31893189            GCPhysPdeSrc = PdpeSrc.u & X86_PDPE_PG_MASK;
    31903190
    3191             /* Anything significant changed? */           
     3191            /* Anything significant changed? */
    31923192            if (    PdpeSrc.n.u1Present != pPdpeDst->n.u1Present
    31933193                ||  GCPhysPdeSrc != pShwPde->GCPhys)
     
    32123212        {
    32133213#  endif /* PGM_GST_TYPE != PGM_TYPE_PAE && PGM_GST_TYPE != PGM_TYPE_AMD64 */
    3214             for (unsigned iPD = 0; iPD < ELEMENTS(pPDSrc->a); iPD++)
     3214            for (unsigned iPD = 0; iPD < RT_ELEMENTS(pPDSrc->a); iPD++)
    32153215            {
    32163216#  if PGM_SHW_TYPE == PGM_TYPE_32BIT
     
    36893689            pPdpeDst = &pPdptDst->a[iPdpte];
    36903690
    3691             if (!pPdpeDst->n.u1Present) 
     3691            if (!pPdpeDst->n.u1Present)
    36923692            {
    36933693                GCPtr += 512 * _2M;
     
    38913891# endif
    38923892                        for (unsigned iPT = 0, off = 0;
    3893                             iPT < ELEMENTS(pPTDst->a);
     3893                            iPT < RT_ELEMENTS(pPTDst->a);
    38943894                            iPT++, off += PAGE_SIZE)
    38953895                        {
     
    41334133                        /* iterate the page table. */
    41344134                        for (unsigned iPT = 0, off = 0;
    4135                             iPT < ELEMENTS(pPTDst->a);
     4135                            iPT < RT_ELEMENTS(pPTDst->a);
    41364136                            iPT++, off += PAGE_SIZE, GCPhysGst += PAGE_SIZE)
    41374137                        {
  • trunk/src/VBox/VMM/VMMAll/PGMAllMap.cpp

    r8856 r11311  
    189189                unsigned iPT  = off >> X86_PD_SHIFT;
    190190                unsigned iPTE = (off >> PAGE_SHIFT) & X86_PT_MASK;
    191                 while (cb > 0 && iPTE < ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a))
     191                while (cb > 0 && iPTE < RT_ELEMENTS(CTXALLSUFF(pCur->aPTs[iPT].pPT)->a))
    192192                {
    193193                    /* 32-Bit */
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r11299 r11311  
    326326                {
    327327                    const unsigned iShw2 = (off + cbWrite - 1) / sizeof(X86PTEPAE);
    328                     AssertReturnVoid(iShw2 < ELEMENTS(uShw.pPTPae->a));
     328                    AssertReturnVoid(iShw2 < RT_ELEMENTS(uShw.pPTPae->a));
    329329
    330330                    if (uShw.pPTPae->a[iShw2].n.u1Present)
     
    360360                    const unsigned iShw2 = (off + cbWrite - 1) / sizeof(X86PTE);
    361361                    if (    iShw2 != iShw
    362                         &&  iShw2 < ELEMENTS(uShw.pPD->a)
     362                        &&  iShw2 < RT_ELEMENTS(uShw.pPD->a)
    363363                        &&  uShw.pPD->a[iShw2].u & PGM_PDFLAGS_MAPPING)
    364364                    {
     
    400400                    {
    401401                        const unsigned iShw2 = iShw + 2;
    402                         if (    iShw2 < ELEMENTS(uShw.pPDPae->a)
     402                        if (    iShw2 < RT_ELEMENTS(uShw.pPDPae->a)
    403403                            &&  (uShw.pPDPae->a[iShw2].u & (PGM_PDFLAGS_MAPPING | X86_PDE_P)) == (PGM_PDFLAGS_MAPPING | X86_PDE_P))
    404404                        {
     
    458458                {
    459459                    const unsigned iShw2 = (off + cbWrite - 1) / sizeof(X86PDEPAE);
    460                     AssertReturnVoid(iShw2 < ELEMENTS(uShw.pPDPae->a));
     460                    AssertReturnVoid(iShw2 < RT_ELEMENTS(uShw.pPDPae->a));
    461461
    462462                    if (    iShw2 != iShw
     
    491491                 */
    492492                const unsigned iShw = off / sizeof(X86PDPE);
    493                 if (iShw < X86_PG_PAE_PDPE_ENTRIES)          /* don't use ELEMENTS(uShw.pPDPT->a), because that's for long mode only */
     493                if (iShw < X86_PG_PAE_PDPE_ENTRIES)          /* don't use RT_ELEMENTS(uShw.pPDPT->a), because that's for long mode only */
    494494                {
    495495                    if (uShw.pPDPT->a[iShw].u & PGM_PLXFLAGS_MAPPING)
     
    548548                {
    549549                    const unsigned iShw2 = (off + cbWrite - 1) / sizeof(X86PDEPAE);
    550                     AssertReturnVoid(iShw2 < ELEMENTS(uShw.pPDPae->a));
     550                    AssertReturnVoid(iShw2 < RT_ELEMENTS(uShw.pPDPae->a));
    551551
    552552                    if (    iShw2 != iShw
     
    23492349            const uint32_t  u32 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P;
    23502350            PX86PT          pPT = (PX86PT)PGMPOOL_PAGE_2_PTR(pVM, pPage);
    2351             for (unsigned i = pPage->iFirstPresent; i < ELEMENTS(pPT->a); i++)
     2351            for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pPT->a); i++)
    23522352                if ((pPT->a[i].u & (X86_PTE_PG_MASK | X86_PTE_P)) == u32)
    23532353                {
     
    23602360#if defined(DEBUG) && !defined(IN_RING0) ///@todo RTLogPrintf is missing in R0.
    23612361            RTLogPrintf("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent);
    2362             for (unsigned i = 0; i < ELEMENTS(pPT->a); i++)
     2362            for (unsigned i = 0; i < RT_ELEMENTS(pPT->a); i++)
    23632363                if ((pPT->a[i].u & (X86_PTE_PG_MASK | X86_PTE_P)) == u32)
    23642364                {
     
    23792379            const uint64_t  u64 = PGM_PAGE_GET_HCPHYS(pPhysPage) | X86_PTE_P;
    23802380            PX86PTPAE       pPT = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pVM, pPage);
    2381             for (unsigned i = pPage->iFirstPresent; i < ELEMENTS(pPT->a); i++)
     2381            for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pPT->a); i++)
    23822382                if ((pPT->a[i].u & (X86_PTE_PAE_PG_MASK | X86_PTE_P)) == u64)
    23832383                {
     
    23902390#if defined(DEBUG) && !defined(IN_RING0) ///@todo RTLogPrintf is missing in R0.
    23912391            RTLogPrintf("cRefs=%d iFirstPresent=%d cPresent=%d\n", cRefs, pPage->iFirstPresent, pPage->cPresent);
    2392             for (unsigned i = 0; i < ELEMENTS(pPT->a); i++)
     2392            for (unsigned i = 0; i < RT_ELEMENTS(pPT->a); i++)
    23932393                if ((pPT->a[i].u & (X86_PTE_PAE_PG_MASK | X86_PTE_P)) == u64)
    23942394                {
     
    24452445        Assert(iPhysExt < pPool->cMaxPhysExts);
    24462446        pPhysExt = &pPool->CTXSUFF(paPhysExts)[iPhysExt];
    2447         for (unsigned i = 0; i < ELEMENTS(pPhysExt->aidx); i++)
     2447        for (unsigned i = 0; i < RT_ELEMENTS(pPhysExt->aidx); i++)
    24482448            if (pPhysExt->aidx[i] != NIL_PGMPOOL_IDX)
    24492449            {
     
    25232523                    unsigned    cPresent = pPage->cPresent;
    25242524                    PX86PT      pPT = (PX86PT)PGMPOOL_PAGE_2_PTR(pVM, pPage);
    2525                     for (unsigned i = pPage->iFirstPresent; i < ELEMENTS(pPT->a); i++)
     2525                    for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pPT->a); i++)
    25262526                        if (pPT->a[i].n.u1Present)
    25272527                        {
     
    25452545                    unsigned  cPresent = pPage->cPresent;
    25462546                    PX86PTPAE pPT = (PX86PTPAE)PGMPOOL_PAGE_2_PTR(pVM, pPage);
    2547                     for (unsigned i = pPage->iFirstPresent; i < ELEMENTS(pPT->a); i++)
     2547                    for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pPT->a); i++)
    25482548                        if (pPT->a[i].n.u1Present)
    25492549                        {
     
    27302730    Assert(iPhysExt < pPool->cMaxPhysExts);
    27312731    PPGMPOOLPHYSEXT pPhysExt = &pPool->CTXSUFF(paPhysExts)[iPhysExt];
    2732     for (unsigned i = 0; i < ELEMENTS(pPhysExt->aidx); i++)
     2732    for (unsigned i = 0; i < RT_ELEMENTS(pPhysExt->aidx); i++)
    27332733        pPhysExt->aidx[i] = NIL_PGMPOOL_IDX;
    27342734    pPhysExt->iNext = pPool->iPhysExtFreeHead;
     
    27532753        Assert(iPhysExt < pPool->cMaxPhysExts);
    27542754        pPhysExt = &pPool->CTXSUFF(paPhysExts)[iPhysExt];
    2755         for (unsigned i = 0; i < ELEMENTS(pPhysExt->aidx); i++)
     2755        for (unsigned i = 0; i < RT_ELEMENTS(pPhysExt->aidx); i++)
    27562756            pPhysExt->aidx[i] = NIL_PGMPOOL_IDX;
    27572757
     
    27942794    {
    27952795        Assert(iPhysExt < pPool->cMaxPhysExts);
    2796         for (unsigned i = 0; i < ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
     2796        for (unsigned i = 0; i < RT_ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
    27972797            if (paPhysExts[iPhysExt].aidx[i] == NIL_PGMPOOL_IDX)
    27982798            {
     
    28932893             * Look for the shadow page and check if it's all freed.
    28942894             */
    2895             for (unsigned i = 0; i < ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
     2895            for (unsigned i = 0; i < RT_ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
    28962896            {
    28972897                if (paPhysExts[iPhysExt].aidx[i] == pPage->idx)
     
    28992899                    paPhysExts[iPhysExt].aidx[i] = NIL_PGMPOOL_IDX;
    29002900
    2901                     for (i = 0; i < ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
     2901                    for (i = 0; i < RT_ELEMENTS(paPhysExts[iPhysExt].aidx); i++)
    29022902                        if (paPhysExts[iPhysExt].aidx[i] != NIL_PGMPOOL_IDX)
    29032903                        {
     
    30593059DECLINLINE(void) pgmPoolTrackDerefPT32Bit32Bit(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PT pShwPT, PCX86PT pGstPT)
    30603060{
    3061     for (unsigned i = pPage->iFirstPresent; i < ELEMENTS(pShwPT->a); i++)
     3061    for (unsigned i = pPage->iFirstPresent; i < RT_ELEMENTS(pShwPT->a); i++)
    30623062        if (pShwPT->a[i].n.u1Present)
    30633063        {
     
    30813081DECLINLINE(void) pgmPoolTrackDerefPTPae32Bit(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PT pGstPT)
    30823082{
    3083     for (unsigned i = 0; i < ELEMENTS(pShwPT->a); i++)
     3083    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++)
    30843084        if (pShwPT->a[i].n.u1Present)
    30853085        {
     
    31013101DECLINLINE(void) pgmPoolTrackDerefPTPaePae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PTPAE pShwPT, PCX86PTPAE pGstPT)
    31023102{
    3103     for (unsigned i = 0; i < ELEMENTS(pShwPT->a); i++)
     3103    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++)
    31043104        if (pShwPT->a[i].n.u1Present)
    31053105        {
     
    31213121{
    31223122    RTGCPHYS GCPhys = pPage->GCPhys;
    3123     for (unsigned i = 0; i < ELEMENTS(pShwPT->a); i++, GCPhys += PAGE_SIZE)
     3123    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++, GCPhys += PAGE_SIZE)
    31243124        if (pShwPT->a[i].n.u1Present)
    31253125        {
     
    31413141{
    31423142    RTGCPHYS GCPhys = pPage->GCPhys;
    3143     for (unsigned i = 0; i < ELEMENTS(pShwPT->a); i++, GCPhys += PAGE_SIZE)
     3143    for (unsigned i = 0; i < RT_ELEMENTS(pShwPT->a); i++, GCPhys += PAGE_SIZE)
    31443144        if (pShwPT->a[i].n.u1Present)
    31453145        {
     
    31613161DECLINLINE(void) pgmPoolTrackDerefPDPae(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PDPAE pShwPD)
    31623162{
    3163     for (unsigned i = 0; i < ELEMENTS(pShwPD->a); i++)
     3163    for (unsigned i = 0; i < RT_ELEMENTS(pShwPD->a); i++)
    31643164    {
    31653165        if (pShwPD->a[i].n.u1Present)
     
    31853185DECLINLINE(void) pgmPoolTrackDerefPDPT64Bit(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PDPT pShwPDPT)
    31863186{
    3187     for (unsigned i = 0; i < ELEMENTS(pShwPDPT->a); i++)
     3187    for (unsigned i = 0; i < RT_ELEMENTS(pShwPDPT->a); i++)
    31883188    {
    31893189        if (pShwPDPT->a[i].n.u1Present)
     
    32083208DECLINLINE(void) pgmPoolTrackDerefPML464Bit(PPGMPOOL pPool, PPGMPOOLPAGE pPage, PX86PML4 pShwPML4)
    32093209{
    3210     for (unsigned i = 0; i < ELEMENTS(pShwPML4->a); i++)
     3210    for (unsigned i = 0; i < RT_ELEMENTS(pShwPML4->a); i++)
    32113211    {
    32123212        if (pShwPML4->a[i].n.u1Present)
     
    35063506     * Clear the GCPhys hash and the age list.
    35073507     */
    3508     for (unsigned i = 0; i < ELEMENTS(pPool->aiHash); i++)
     3508    for (unsigned i = 0; i < RT_ELEMENTS(pPool->aiHash); i++)
    35093509        pPool->aiHash[i] = NIL_PGMPOOL_IDX;
    35103510    pPool->iAgeHead = NIL_PGMPOOL_IDX;
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r9893 r11311  
    303303
    304304        unsigned iPTE = (GCPtr >> SHW_PT_SHIFT) & SHW_PT_MASK;
    305         while (iPTE < ELEMENTS(pPT->a))
     305        while (iPTE < RT_ELEMENTS(pPT->a))
    306306        {
    307307            if (pPT->a[iPTE].n.u1Present)
  • trunk/src/VBox/VMM/VMMAll/REMAll.cpp

    r10410 r11311  
    4646REMDECL(int) REMNotifyInvalidatePage(PVM pVM, RTGCPTR GCPtrPage)
    4747{
    48     if (pVM->rem.s.cInvalidatedPages < ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages))
     48    if (pVM->rem.s.cInvalidatedPages < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages))
    4949    {
    5050        /*
     
    9494REMDECL(void) REMNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
    9595{
    96     if (pVM->rem.s.cHandlerNotifications >= ELEMENTS(pVM->rem.s.aHandlerNotifications))
     96    if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    9797        remFlushHandlerNotifications(pVM);
    9898    PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
     
    118118REMDECL(void) REMNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
    119119{
    120     if (pVM->rem.s.cHandlerNotifications >= ELEMENTS(pVM->rem.s.aHandlerNotifications))
     120    if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    121121        remFlushHandlerNotifications(pVM);
    122122    PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
     
    144144REMDECL(void) REMNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
    145145{
    146     if (pVM->rem.s.cHandlerNotifications >= ELEMENTS(pVM->rem.s.aHandlerNotifications))
     146    if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
    147147        remFlushHandlerNotifications(pVM);
    148148    PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r10087 r11311  
    835835     * Validate.
    836836     */
    837     if (iTrap >= ELEMENTS(pVM->trpm.s.aIdt))
     837    if (iTrap >= RT_ELEMENTS(pVM->trpm.s.aIdt))
    838838    {
    839839        AssertMsg(iTrap < TRPM_HANDLER_INT_BASE, ("Illegal gate number %d!\n", iTrap));
  • trunk/src/VBox/VMM/VMMGC/PGMGC.cpp

    r8155 r11311  
    266266        ||  pVM->pgm.s.aHCPhysDynPageMapCache[iCache = 3] == HCPhys)
    267267    {
    268         static const uint8_t au8Trans[MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT][ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache)] =
     268        static const uint8_t au8Trans[MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT][RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache)] =
    269269        {
    270270            { 0, 5, 6, 7 },
     
    277277            { 4, 5, 6, 7 },
    278278        };
    279         Assert(ELEMENTS(au8Trans) == 8);
    280         Assert(ELEMENTS(au8Trans[0]) == 4);
     279        Assert(RT_ELEMENTS(au8Trans) == 8);
     280        Assert(RT_ELEMENTS(au8Trans[0]) == 4);
    281281        int iPage = au8Trans[pVM->pgm.s.iDynPageMapLast][iCache];
    282282        void *pv = pVM->pgm.s.pbDynPageMapBaseGC + (iPage << PAGE_SHIFT);
     
    286286        return VINF_SUCCESS;
    287287    }
    288     Assert(ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) == 4);
     288    Assert(RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) == 4);
    289289    STAM_COUNTER_INC(&pVM->pgm.s.StatDynMapCacheMisses);
    290290
     
    296296    Assert((MM_HYPER_DYNAMIC_SIZE >> PAGE_SHIFT) == 8);
    297297
    298     pVM->pgm.s.aHCPhysDynPageMapCache[iPage & (ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) - 1)] = HCPhys;
     298    pVM->pgm.s.aHCPhysDynPageMapCache[iPage & (RT_ELEMENTS(pVM->pgm.s.aHCPhysDynPageMapCache) - 1)] = HCPhys;
    299299    pVM->pgm.s.paDynPageMap32BitPTEsGC[iPage].u = (uint32_t)HCPhys | X86_PTE_P | X86_PTE_A | X86_PTE_D;
    300300    pVM->pgm.s.paDynPageMapPaePTEsGC[iPage].u   =           HCPhys | X86_PTE_P | X86_PTE_A | X86_PTE_D;
  • trunk/src/VBox/VMM/VMMGC/TRPMGC.cpp

    r9288 r11311  
    6060     * Validate input.
    6161     */
    62     if (iTrap >= ELEMENTS(pVM->trpm.s.aTmpTrapHandlers))
     62    if (iTrap >= RT_ELEMENTS(pVM->trpm.s.aTmpTrapHandlers))
    6363    {
    6464        AssertMsgFailed(("Trap handler iTrap=%u is out of range!\n", iTrap));
     
    120120    /** @note this causes problems in Windows XP as instructions following the update can be dangerous (str eax has been seen) */
    121121    /** @note not going back to ring 3 could make the code scanner miss them. */
    122     /* Check if we can handle the write here. */   
     122    /* Check if we can handle the write here. */
    123123    if (     iGate != 3                                         /* Gate 3 is handled differently; could do it here as well, but let ring 3 handle this case for now. */
    124124        &&  !ASMBitTest(&pVM->trpm.s.au32IdtPatched[0], iGate)) /* Passthru gates need special attention too. */
  • trunk/src/VBox/VMM/VMMR0/DBGFR0.cpp

    r9212 r11311  
    5454    {
    5555        Assert(X86_DR6_B0 == 1 && X86_DR6_B1 == 2 && X86_DR6_B2 == 4 && X86_DR6_B3 == 8);
    56         for (unsigned iBp = 0; iBp < ELEMENTS(pVM->dbgf.s.aHwBreakpoints); iBp++)
     56        for (unsigned iBp = 0; iBp < RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints); iBp++)
    5757        {
    5858            if (    (uDr6 & RT_BIT(iBp))
     
    113113        RTGCPTR pPc;
    114114        int rc = SELMValidateAndConvertCSAddr(pVM, pRegFrame->eflags, pRegFrame->ss, pRegFrame->cs, &pRegFrame->csHid,
    115                                               (RTGCPTR)((RTGCUINTPTR)pRegFrame->eip - 1),                                             
     115                                              (RTGCPTR)((RTGCUINTPTR)pRegFrame->eip - 1),
    116116                                              &pPc);
    117117        AssertRCReturn(rc, rc);
    118118
    119         for (unsigned iBp = 0; iBp < ELEMENTS(pVM->dbgf.s.aBreakpoints); iBp++)
     119        for (unsigned iBp = 0; iBp < RT_ELEMENTS(pVM->dbgf.s.aBreakpoints); iBp++)
    120120        {
    121121            if (    pVM->dbgf.s.aBreakpoints[iBp].GCPtr == (RTGCUINTPTR)pPc
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r11133 r11311  
    990990    char *psz = szEFlags;
    991991    uint32_t efl = pCtx->eflags.u32;
    992     for (unsigned i = 0; i < ELEMENTS(aFlags); i++)
     992    for (unsigned i = 0; i < RT_ELEMENTS(aFlags); i++)
    993993    {
    994994        const char *pszAdd = aFlags[i].fFlag & efl ? aFlags[i].pszSet : aFlags[i].pszClear;
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r11157 r11311  
    176176
    177177        rc = -1;
    178         for (unsigned i = 0; i < ELEMENTS(aVars); i++)
     178        for (unsigned i = 0; i < RT_ELEMENTS(aVars); i++)
    179179        {
    180180            if (!strcmp(psz, aVars[i].pszVar))
  • trunk/src/VBox/VMM/testcase/tstMMHyperHeap.cpp

    r8155 r11311  
    133133
    134134    /* allocate */
    135     for (i = 0; i < ELEMENTS(aOps); i++)
     135    for (i = 0; i < RT_ELEMENTS(aOps); i++)
    136136    {
    137137        rc = MMHyperAlloc(pVM, aOps[i].cb, aOps[i].uAlignment, MM_TAG_VM, &aOps[i].pvAlloc);
     
    150150
    151151    /* free and allocate the same node again. */
    152     for (i = 0; i < ELEMENTS(aOps); i++)
     152    for (i = 0; i < RT_ELEMENTS(aOps); i++)
    153153    {
    154154        if (    !aOps[i].pvAlloc
     
    188188    /* free it in a specific order. */
    189189    int cFreed = 0;
    190     for (i = 0; i < ELEMENTS(aOps); i++)
     190    for (i = 0; i < RT_ELEMENTS(aOps); i++)
    191191    {
    192192        unsigned j;
    193         for (j = 0; j < ELEMENTS(aOps); j++)
     193        for (j = 0; j < RT_ELEMENTS(aOps); j++)
    194194        {
    195195            if (    aOps[j].iFreeOrder != i
     
    212212        }
    213213    }
    214     Assert(cFreed == ELEMENTS(aOps));
     214    Assert(cFreed == RT_ELEMENTS(aOps));
    215215    RTPrintf("i=done free=%d\n", MMHyperHeapGetFreeSize(pVM));
    216216
  • trunk/src/VBox/VMM/testcase/tstVMREQ.cpp

    r8155 r11311  
    4949
    5050
    51 /** 
     51/**
    5252 * Testings va_list passing in VMSetRuntimeError.
    5353 */
     
    119119
    120120
    121 /** 
    122  * Functions that tests passing a va_list * argument in a request, 
     121/**
     122 * Functions that tests passing a va_list * argument in a request,
    123123 * similar to VMSetRuntimeError.
    124124 */
     
    129129#else
    130130    va_list va2;
    131     va_copy(va2, va); 
     131    va_copy(va2, va);
    132132    void *pvVA = va2;
    133 #endif 
     133#endif
    134134
    135135    PVMREQ pReq;
     
    142142#if 1
    143143    va_end(va2);
    144 #endif 
    145 }
    146 
    147 
    148 /** 
    149  * Functions that tests passing a va_list * argument in a request, 
     144#endif
     145}
     146
     147
     148/**
     149 * Functions that tests passing a va_list * argument in a request,
    150150 * similar to VMSetRuntimeError.
    151151 */
     
    181181    {
    182182        PVMREQ          apReq[17];
    183         const unsigned  cReqs = i % ELEMENTS(apReq);
     183        const unsigned  cReqs = i % RT_ELEMENTS(apReq);
    184184        unsigned        iReq;
    185185        for (iReq = 0; iReq < cReqs; iReq++)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette