VirtualBox

Ignore:
Timestamp:
Jun 9, 2010 12:14:59 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62505
Message:

iprt/asm.h,*: Revised the ASMAtomic*Ptr functions and macros. The new saves lots of unsafe (void * volatile *) casts as well as adding some type safety when using GCC (typeof rulez).

Location:
trunk/src/VBox/HostDrivers/Support
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r28800 r30111  
    508508        if (g_pSUPGlobalInfoPage)
    509509        {
    510             ASMAtomicXchgPtr((void * volatile *)&g_pSUPGlobalInfoPage, NULL);
    511             ASMAtomicXchgPtr((void * volatile *)&g_pSUPGlobalInfoPageR0, NULL);
    512             ASMAtomicXchgSize(&g_HCPhysSUPGlobalInfoPage, NIL_RTHCPHYS);
     510            ASMAtomicWritePtr((void * volatile *)&g_pSUPGlobalInfoPage, NULL);
     511            ASMAtomicWritePtr((void * volatile *)&g_pSUPGlobalInfoPageR0, NULL);
     512            ASMAtomicWriteSize(&g_HCPhysSUPGlobalInfoPage, NIL_RTHCPHYS);
    513513            /* just a little safe guard against threads using the page. */
    514514            RTThreadSleep(50);
  • trunk/src/VBox/HostDrivers/Support/SUPR0IdcClient.c

    r29261 r30111  
    125125            &&  (Req.u.Out.uSessionVersion & UINT32_C(0xffff0000)) == (SUPDRV_IDC_VERSION & UINT32_C(0xffff0000)))
    126126        {
    127             ASMAtomicCmpXchgPtr((void * volatile *)&g_pMainHandle, pHandle, NULL);
     127            ASMAtomicCmpXchgPtr(&g_pMainHandle, pHandle, NULL);
    128128            return rc;
    129129        }
     
    167167    {
    168168        pHandle->s.pSession = NULL;
    169         ASMAtomicCmpXchgPtr((void * volatile *)&g_pMainHandle, NULL, pHandle);
     169        ASMAtomicCmpXchgPtr(&g_pMainHandle, NULL, pHandle);
    170170    }
    171171    return rc;
     
    203203PSUPDRVIDCHANDLE supR0IdcGetHandleFromSession(PSUPDRVSESSION pSession)
    204204{
    205     PSUPDRVIDCHANDLE pHandle = (PSUPDRVIDCHANDLE)ASMAtomicUoReadPtr((void * volatile *)&g_pMainHandle);
     205    PSUPDRVIDCHANDLE pHandle = ASMAtomicUoReadPtrT(&g_pMainHandle, PSUPDRVIDCHANDLE);
    206206    if (    VALID_PTR(pHandle)
    207207        &&  pHandle->s.pSession == pSession)
  • trunk/src/VBox/HostDrivers/Support/SUPSvcGrant.cpp

    r28800 r30111  
    179179     * Clean up the session.
    180180     */
    181     PSUPSVCGRANT pParent = (PSUPSVCGRANT)ASMAtomicReadPtr((void * volatile *)&pThis->pParent);
     181    PSUPSVCGRANT pParent = ASMAtomicReadPtrT(&pThis->pParent, PSUPSVCGRANT);
    182182    if (pParent)
    183183        RTCritSectEnter(&pParent->CritSect);
     
    975975    unsigned cSessions = 0;
    976976    for (PSUPSVCGRANTSESSION pCur = pThis->pSessionHead; pCur; pCur = pCur->pNext)
    977         ASMAtomicWritePtr((void * volatile *)&pCur->pParent, NULL);
     977        ASMAtomicWritePtr(&pCur->pParent, NULL);
    978978
    979979    RTCritSectLeave(&pThis->CritSect);
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