VirtualBox

Changeset 37209 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 25, 2011 9:33:12 AM (14 years ago)
Author:
vboxsync
Message:

circbuf: Use ASMAtomic*Z instead of ASMAtomic*Size because the latter is causing trouble on recent microsoft compilers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/circbuf.cpp

    r37208 r37209  
    8787    AssertPtrReturn(pBuf, 0);
    8888
    89     size_t cbSize = 0;
    90     ASMAtomicReadSize(&pBuf->cbBufUsed, &cbSize);
    91     return pBuf->cbBufSize - cbSize;
     89    return pBuf->cbBufSize - ASMAtomicReadZ(&pBuf->cbBufUsed);
    9290}
    9391
     
    9896    AssertPtrReturn(pBuf, 0);
    9997
    100     size_t cbSize = 0;
    101     ASMAtomicReadSize(&pBuf->cbBufUsed, &cbSize);
    102     return cbSize;
     98    return ASMAtomicReadZ(&pBuf->cbBufUsed);
    10399}
    104100
     
    121117    AssertPtr(pcbSize);
    122118
    123     size_t uUsed = 0;
    124     size_t uSize = 0;
    125 
    126119    *ppvStart = 0;
    127120    *pcbSize = 0;
    128121
    129122    /* How much is in use? */
    130     ASMAtomicReadSize(&pBuf->cbBufUsed, &uUsed);
    131     if (uUsed > 0)
     123    size_t cbUsed = ASMAtomicReadZ(&pBuf->cbBufUsed);
     124    if (cbUsed > 0)
    132125    {
    133126        /* Get the size out of the requested size, the read block till the end
    134127         * of the buffer & the currently used size. */
    135         uSize = RT_MIN(cbReqSize, RT_MIN(pBuf->cbBufSize - pBuf->uReadPos, uUsed));
    136         if (uSize > 0)
     128        size_t cbSize = RT_MIN(cbReqSize, RT_MIN(pBuf->cbBufSize - pBuf->uReadPos, cbUsed));
     129        if (cbSize > 0)
    137130        {
    138131            /* Return the pointer address which point to the current read
    139132             * position. */
    140133            *ppvStart = (char *)pBuf->pvBuf + pBuf->uReadPos;
    141             *pcbSize = uSize;
     134            *pcbSize = cbSize;
    142135        }
    143136    }
     
    153146    pBuf->uReadPos = (pBuf->uReadPos + cbSize) % pBuf->cbBufSize;
    154147
    155     size_t cbOld = 0;
    156     ASMAtomicSubSize(&pBuf->cbBufUsed, cbSize, &cbOld);
     148    ASMAtomicSubZ(&pBuf->cbBufUsed, cbSize);
    157149}
    158150
     
    170162
    171163    /* How much is free? */
    172     size_t cbSize = 0;
    173     ASMAtomicReadSize(&pBuf->cbBufUsed, &cbSize);
    174     size_t uFree = pBuf->cbBufSize - cbSize;
    175     if (uFree > 0)
     164    size_t cbFree = pBuf->cbBufSize - ASMAtomicReadZ(&pBuf->cbBufUsed);
     165    if (cbFree > 0)
    176166    {
    177167        /* Get the size out of the requested size, the write block till the end
    178168         * of the buffer & the currently free size. */
    179         size_t uSize = RT_MIN(cbReqSize, RT_MIN(pBuf->cbBufSize - pBuf->uWritePos, uFree));
    180         if (uSize > 0)
     169        size_t cbSize = RT_MIN(cbReqSize, RT_MIN(pBuf->cbBufSize - pBuf->uWritePos, cbFree));
     170        if (cbSize > 0)
    181171        {
    182172            /* Return the pointer address which point to the current write
    183173             * position. */
    184174            *ppvStart = (char*)pBuf->pvBuf + pBuf->uWritePos;
    185             *pcbSize = uSize;
     175            *pcbSize = cbSize;
    186176        }
    187177    }
     
    198188
    199189    size_t cbOldIgnored = 0;
    200     ASMAtomicAddSize(&pBuf->cbBufUsed, cbSize, &cbOldIgnored);
     190    ASMAtomicAddZ(&pBuf->cbBufUsed, cbSize);
    201191}
    202192
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