VirtualBox

Changeset 37400 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 9, 2011 8:38:21 PM (14 years ago)
Author:
vboxsync
Message:

tracebuf.cpp: Attempt to fix the windows builds. Use defines for the config.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/log/tracebuf.cpp

    r37398 r37400  
    2525/** Alignment used to place the trace buffer members, this should be a multiple
    2626 * of the cache line size if possible.  (We should dynamically determine it.) */
    27 #define RTTRACEBUF_ALIGNMENT    64
     27#define RTTRACEBUF_ALIGNMENT        64
    2828AssertCompile(RTTRACEBUF_ALIGNMENT >= sizeof(uint64_t) * 2);
    2929
     30/** The maximum number of entries. */
     31#define RTTRACEBUF_MAX_ENTRIES      _64K
     32/** The minimum number of entries. */
     33#define RTTRACEBUF_MIN_ENTRIES      4
     34/** The default number of entries. */
     35#define RTTRACEBUF_DEF_ENTRIES      256
     36
     37/** The maximum entry size. */
     38#define RTTRACEBUF_MAX_ENTRY_SIZE   _1M
     39/** The minimum entry size. */
     40#define RTTRACEBUF_MIN_ENTRY_SIZE   RTTRACEBUF_ALIGNMENT
     41/** The default entry size. */
     42#define RTTRACEBUF_DEF_ENTRY_SIZE   256
     43AssertCompile(!(RTTRACEBUF_DEF_ENTRY_SIZE & (RTTRACEBUF_DEF_ENTRY_SIZE - 1)));
    3044
    3145/**
     
    240254    AssertPtrReturn(phTraceBuf, VERR_INVALID_POINTER);
    241255    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
    242     AssertMsgReturn(cbEntry <= _64K, ("%#x\n", cbEntry), VERR_OUT_OF_RANGE);
    243     AssertMsgReturn(cEntries <= _1M, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);
     256    AssertMsgReturn(cbEntry  <= RTTRACEBUF_MAX_ENTRIES,    ("%#x\n", cbEntry), VERR_OUT_OF_RANGE);
     257    AssertMsgReturn(cEntries <= RTTRACEBUF_MAX_ENTRY_SIZE, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);
    244258
    245259    /*
     
    247261     */
    248262    if (!cbEntry)
    249         cbEntry = RT_ALIGN_Z(256, RTTRACEBUF_ALIGNMENT);
     263        cbEntry = RTTRACEBUF_DEF_ENTRY_SIZE;
    250264    else
    251         cbEntry = RT_ALIGN_Z(cbEntry, RTTRACEBUF_ALIGNMENT);
     265        cbEntry = RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT);
    252266
    253267    if (!cEntries)
    254         cEntries = 64;
    255     else if (cEntries < 4)
    256         cEntries = 4;
     268        cEntries = RTTRACEBUF_DEF_ENTRIES;
     269    else if (cEntries < RTTRACEBUF_MIN_ENTRIES)
     270        cEntries = RTTRACEBUF_MIN_ENTRIES;
    257271
    258272    /*
     
    288302    AssertPtrReturn(phTraceBuf, VERR_INVALID_POINTER);
    289303    AssertReturn(!(fFlags & ~RTTRACEBUF_FLAGS_MASK), VERR_INVALID_PARAMETER);
    290     AssertMsgReturn(cbEntry <= _64K, ("%#x\n", cbEntry), VERR_OUT_OF_RANGE);
    291     AssertMsgReturn(cEntries <= _1M, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);
     304    AssertMsgReturn(cbEntry  <= RTTRACEBUF_MAX_ENTRIES,    ("%#x\n", cbEntry), VERR_OUT_OF_RANGE);
     305    AssertMsgReturn(cEntries <= RTTRACEBUF_MAX_ENTRY_SIZE, ("%#x\n", cEntries), VERR_OUT_OF_RANGE);
    292306    AssertPtrReturn(pvBlock, VERR_INVALID_POINTER);
    293307    AssertPtrReturn(pcbBlock, VERR_INVALID_POINTER);
     
    302316    size_t const cbEntryBuf = cbBlock > cbHdr ? cbBlock - cbHdr : 0;
    303317    if (cbEntry)
    304         cbEntry = RT_ALIGN_Z(cbEntry, RTTRACEBUF_ALIGNMENT);
     318        cbEntry = RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT);
    305319    else
    306320    {
    307321        if (!cbEntryBuf)
    308             cbEntry = RT_ALIGN_Z(256, RTTRACEBUF_ALIGNMENT);
     322        {
     323            cbEntry  = RTTRACEBUF_DEF_ENTRY_SIZE;
     324            cEntries = RTTRACEBUF_DEF_ENTRIES;
     325        }
    309326        else if (cEntries)
    310327        {
    311             cbEntry = cbBlock / cEntries;
    312             cbEntry &= ~(RTTRACEBUF_ALIGNMENT - 1);
    313             if (cbEntry > _64K)
    314                 cbEntry = _64K;
     328            size_t cbEntryZ = cbBlock / cEntries;
     329            cbEntryZ &= ~(RTTRACEBUF_ALIGNMENT - 1);
     330            if (cbEntryZ > RTTRACEBUF_MAX_ENTRIES)
     331                cbEntryZ = RTTRACEBUF_MAX_ENTRIES;
     332            cbEntry = (uint32_t)cbEntryZ;
    315333        }
    316         else if (cbBlock >= RT_ALIGN_Z(512, RTTRACEBUF_ALIGNMENT) * 256)
    317             cbEntry = RT_ALIGN_Z(512, RTTRACEBUF_ALIGNMENT);
    318         else if (cbBlock >= RT_ALIGN_Z(256, RTTRACEBUF_ALIGNMENT) * 64)
    319             cbEntry = RT_ALIGN_Z(256, RTTRACEBUF_ALIGNMENT);
    320         else if (cbBlock >= RT_ALIGN_Z(128, RTTRACEBUF_ALIGNMENT) * 32)
    321             cbEntry = RT_ALIGN_Z(128, RTTRACEBUF_ALIGNMENT);
     334        else if (cbBlock >= RT_ALIGN_32(512, RTTRACEBUF_ALIGNMENT) * 256)
     335            cbEntry = RT_ALIGN_32(512, RTTRACEBUF_ALIGNMENT);
     336        else if (cbBlock >= RT_ALIGN_32(256, RTTRACEBUF_ALIGNMENT) * 64)
     337            cbEntry = RT_ALIGN_32(256, RTTRACEBUF_ALIGNMENT);
     338        else if (cbBlock >= RT_ALIGN_32(128, RTTRACEBUF_ALIGNMENT) * 32)
     339            cbEntry = RT_ALIGN_32(128, RTTRACEBUF_ALIGNMENT);
    322340        else
    323341            cbEntry = sizeof(RTTRACEBUFENTRY);
    324342    }
    325     Assert(RT_ALIGN_Z(cbEntry, RTTRACEBUF_ALIGNMENT) == cbEntry);
     343    Assert(RT_ALIGN_32(cbEntry, RTTRACEBUF_ALIGNMENT) == cbEntry);
    326344
    327345    if (!cEntries)
    328         cEntries = cbEntry / cbEntryBuf;
    329     if (cEntries < 4)
    330         cEntries = 4;
     346    {
     347        size_t cEntriesZ = cbEntryBuf / cbEntry;
     348        if (cEntriesZ > RTTRACEBUF_MAX_ENTRIES)
     349            cEntriesZ = RTTRACEBUF_MAX_ENTRIES;
     350        cEntries = (uint32_t)cEntriesZ;
     351    }
     352    if (cEntries < RTTRACEBUF_MIN_ENTRIES)
     353        cEntries = RTTRACEBUF_MIN_ENTRIES;
    331354
    332355    uint32_t offVolatile = RTTRACEBUF_ALIGNMENT - ((uintptr_t)pvBlock & (RTTRACEBUF_ALIGNMENT - 1));
     
    376399    AssertReturnVoid(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTTRACEBUF_MAGIC_DEAD, RTTRACEBUF_MAGIC));
    377400    if (pThis->fFlags & RTTRACEBUF_FLAGS_FREE_ME)
     401    {
    378402#ifdef IN_RC
    379403        AssertReleaseFailed();
     
    381405        RTMemFree(pThis);
    382406#endif
     407    }
    383408}
    384409
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