VirtualBox

Changeset 73097 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (6 years ago)
Author:
vboxsync
Message:

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

Location:
trunk/src/VBox/Devices/Storage
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r71775 r73097  
    844844
    845845#define PCIDEV_2_PAHCI(pPciDev)                  ( (PAHCI)(pPciDev) )
    846 #define PDMIBASE_2_PAHCIPORT(pInterface)         ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IBase)) )
    847 #define PDMIMEDIAPORT_2_PAHCIPORT(pInterface)    ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IPort)) )
    848 #define PDMIBASE_2_PAHCI(pInterface)             ( (PAHCI)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCI, IBase)) )
    849 #define PDMILEDPORTS_2_PAHCI(pInterface)         ( (PAHCI)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCI, ILeds)) )
     846#define PDMIBASE_2_PAHCIPORT(pInterface)         ( (PAHCIPort)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCIPort, IBase)) )
     847#define PDMIMEDIAPORT_2_PAHCIPORT(pInterface)    ( (PAHCIPort)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCIPort, IPort)) )
     848#define PDMIBASE_2_PAHCI(pInterface)             ( (PAHCI)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCI, IBase)) )
     849#define PDMILEDPORTS_2_PAHCI(pInterface)         ( (PAHCI)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCI, ILeds)) )
    850850
    851851#define AHCI_RTGCPHYS_FROM_U32(Hi, Lo)             ( (RTGCPHYS)RT_MAKE_U64(Lo, Hi) )
     
    38083808                u32PRDBC = (uint32_t)pAhciReq->cbTransfer;
    38093809
    3810             PDMDevHlpPCIPhysWrite(pAhciPort->CTX_SUFF(pDevIns), pAhciReq->GCPhysCmdHdrAddr + RT_OFFSETOF(CmdHdr, u32PRDBC),
     3810            PDMDevHlpPCIPhysWrite(pAhciPort->CTX_SUFF(pDevIns), pAhciReq->GCPhysCmdHdrAddr + RT_UOFFSETOF(CmdHdr, u32PRDBC),
    38113811                                  &u32PRDBC, sizeof(u32PRDBC));
    38123812
  • trunk/src/VBox/Devices/Storage/DevBusLogic.cpp

    r71775 r73097  
    12401240        /* Rewrite CCB up to the CDB; perhaps more than necessary. */
    12411241        PDMDevHlpPCIPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB,
    1242                               pCCBGuest, RT_OFFSETOF(CCBC, abCDB));
     1242                              pCCBGuest, RT_UOFFSETOF(CCBC, abCDB));
    12431243    }
    12441244
  • trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp

    r73091 r73097  
    923923            if (pThis->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX)
    924924            {
    925                 PLSILOGICMEMREGN pRegionNew = (PLSILOGICMEMREGN)RTMemRealloc(pRegion, RT_OFFSETOF(LSILOGICMEMREGN, au32Data[cRegionSizeNew]));
    926 
     925                PLSILOGICMEMREGN pRegionNew;
     926                pRegionNew = (PLSILOGICMEMREGN)RTMemRealloc(pRegion, RT_UOFFSETOF_DYN(LSILOGICMEMREGN, au32Data[cRegionSizeNew]));
    927927                if (pRegionNew)
    928928                {
     
    48684868
    48694869                uint32_t         cRegion = u32AddrEnd - u32AddrStart + 1;
    4870                 PLSILOGICMEMREGN pRegion = (PLSILOGICMEMREGN)RTMemAllocZ(RT_OFFSETOF(LSILOGICMEMREGN, au32Data[cRegion]));
     4870                PLSILOGICMEMREGN pRegion = (PLSILOGICMEMREGN)RTMemAllocZ(RT_UOFFSETOF_DYN(LSILOGICMEMREGN, au32Data[cRegion]));
    48714871                if (pRegion)
    48724872                {
  • trunk/src/VBox/Devices/Storage/DrvDiskIntegrity.cpp

    r73094 r73097  
    363363
    364364            /* Create new segment */
    365             pSeg = (PDRVDISKSEGMENT)RTMemAllocZ(RT_OFFSETOF(DRVDISKSEGMENT, apIoLog[cbRange / 512]));
     365            pSeg = (PDRVDISKSEGMENT)RTMemAllocZ(RT_UOFFSETOF_DYN(DRVDISKSEGMENT, apIoLog[cbRange / 512]));
    366366            if (pSeg)
    367367            {
     
    601601                    for (unsigned idx = (uint32_t)(cbPreLeft / 512); idx < pSeg->cIoLogEntries; idx++)
    602602                        drvdiskintIoLogEntryRelease(pSeg->apIoLog[idx]);
    603                     pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_OFFSETOF(DRVDISKSEGMENT, apIoLog[cbPreLeft / 512]));
     603                    pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_UOFFSETOF_DYN(DRVDISKSEGMENT, apIoLog[cbPreLeft / 512]));
    604604                    pSeg->Core.KeyLast = pSeg->Core.Key + cbPreLeft - 1;
    605605                    pSeg->cbSeg = cbPreLeft;
     
    617617                    for (unsigned idx = 0; idx < cbPostLeft /512; idx++)
    618618                        pSeg->apIoLog[idx] = pSeg->apIoLog[(cbRange / 512) + idx];
    619                     pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_OFFSETOF(DRVDISKSEGMENT, apIoLog[cbPostLeft / 512]));
     619                    pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_UOFFSETOF_DYN(DRVDISKSEGMENT, apIoLog[cbPostLeft / 512]));
    620620                    pSeg->pbSeg = (uint8_t *)RTMemRealloc(pSeg->pbSeg, cbPostLeft);
    621621                    pSeg->Core.Key += cbRange;
     
    629629                    /* Split the segment into 2 new segments. */
    630630                    LogFlowFunc(("Split segment pSeg=%#p\n", pSeg));
    631                     PDRVDISKSEGMENT pSegPost = (PDRVDISKSEGMENT)RTMemAllocZ(RT_OFFSETOF(DRVDISKSEGMENT, apIoLog[cbPostLeft / 512]));
     631                    PDRVDISKSEGMENT pSegPost = (PDRVDISKSEGMENT)RTMemAllocZ(RT_UOFFSETOF_DYN(DRVDISKSEGMENT, apIoLog[cbPostLeft / 512]));
    632632                    if (pSegPost)
    633633                    {
     
    654654                    for (unsigned idx = (uint32_t)(cbPreLeft / 512); idx < (uint32_t)((cbPreLeft + cbRange) / 512); idx++)
    655655                        drvdiskintIoLogEntryRelease(pSeg->apIoLog[idx]);
    656                     pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_OFFSETOF(DRVDISKSEGMENT, apIoLog[cbPreLeft / 512]));
     656                    pSeg = (PDRVDISKSEGMENT)RTMemRealloc(pSeg, RT_UOFFSETOF_DYN(DRVDISKSEGMENT, apIoLog[cbPreLeft / 512]));
    657657                    pSeg->Core.KeyLast = pSeg->Core.Key + cbPreLeft - 1;
    658658                    pSeg->cbSeg = cbPreLeft;
     
    860860
    861861/** Makes a PDRVDISKINTEGRITY out of a PPDMIMEDIA. */
    862 #define PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface)        ( (PDRVDISKINTEGRITY)((uintptr_t)pInterface - RT_OFFSETOF(DRVDISKINTEGRITY, IMedia)) )
     862#define PDMIMEDIA_2_DRVDISKINTEGRITY(pInterface)        ( (PDRVDISKINTEGRITY)((uintptr_t)pInterface - RT_UOFFSETOF(DRVDISKINTEGRITY, IMedia)) )
    863863
    864864
     
    10661066
    10671067/** Makes a PDRVBLOCK out of a PPDMIMEDIAPORT. */
    1068 #define PDMIMEDIAPORT_2_DRVDISKINTEGRITY(pInterface)    ( (PDRVDISKINTEGRITY((uintptr_t)pInterface - RT_OFFSETOF(DRVDISKINTEGRITY, IMediaPort))) )
     1068#define PDMIMEDIAPORT_2_DRVDISKINTEGRITY(pInterface)    ( (PDRVDISKINTEGRITY((uintptr_t)pInterface - RT_UOFFSETOF(DRVDISKINTEGRITY, IMediaPort))) )
    10691069
    10701070/**
  • trunk/src/VBox/Devices/Storage/DrvHostBase-win.cpp

    r69500 r73097  
    287287    Assert(cbSense <= sizeof(Req.aSense));
    288288    Req.spt.SenseInfoLength = (UCHAR)RT_MIN(sizeof(Req.aSense), cbSense);
    289     Req.spt.SenseInfoOffset = RT_OFFSETOF(struct _REQ, aSense);
     289    Req.spt.SenseInfoOffset = RT_UOFFSETOF(struct _REQ, aSense);
    290290    if (DeviceIoControl((HANDLE)RTFileToNative(pThis->Os.hFileDevice), IOCTL_SCSI_PASS_THROUGH_DIRECT,
    291291                        &Req, sizeof(Req), &Req, sizeof(Req), &cbReturned, NULL))
    292292    {
    293         if (cbReturned > RT_OFFSETOF(struct _REQ, aSense))
     293        if (cbReturned > RT_UOFFSETOF(struct _REQ, aSense))
    294294            memcpy(pbSense, Req.aSense, cbSense);
    295295        else
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r71807 r73097  
    506506    PDRVHOSTBASE pThis = RT_FROM_MEMBER(pInterface, DRVHOSTBASE, IMediaEx);
    507507
    508     pThis->cbIoReqAlloc = RT_OFFSETOF(DRVHOSTBASEREQ, abAlloc[cbIoReqAlloc]);
     508    pThis->cbIoReqAlloc = RT_UOFFSETOF_DYN(DRVHOSTBASEREQ, abAlloc[cbIoReqAlloc]);
    509509    return VINF_SUCCESS;
    510510}
  • trunk/src/VBox/Devices/Storage/DrvSCSI.cpp

    r71807 r73097  
    776776    PDRVSCSI pThis = RT_FROM_MEMBER(pInterface, DRVSCSI, IMediaEx);
    777777
    778     pThis->cbIoReqAlloc = RT_OFFSETOF(DRVSCSIREQ, abAlloc[cbIoReqAlloc]);
     778    pThis->cbIoReqAlloc = RT_UOFFSETOF_DYN(DRVSCSIREQ, abAlloc[cbIoReqAlloc]);
    779779    return VINF_SUCCESS;
    780780}
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r71775 r73097  
    9696/** Converts a pointer to VBOXDISK::IMedia to a PVBOXDISK. */
    9797#define PDMIMEDIA_2_VBOXDISK(pInterface) \
    98     ( (PVBOXDISK)((uintptr_t)pInterface - RT_OFFSETOF(VBOXDISK, IMedia)) )
     98    ( (PVBOXDISK)((uintptr_t)pInterface - RT_UOFFSETOF(VBOXDISK, IMedia)) )
    9999
    100100/** Saved state version of an I/O request .*/
  • trunk/src/VBox/Devices/Storage/HBDMgmt-win.cpp

    r69500 r73097  
    451451                        LogFlowFunc(("Volume %u: %ls\n", i, papwszVolumes[i]));
    452452#endif
    453                     pDev = (PHBDMGRDEV)RTMemAllocZ(RT_OFFSETOF(HBDMGRDEV, ahVolumes[cVolumes]));
     453                    pDev = (PHBDMGRDEV)RTMemAllocZ(RT_UOFFSETOF_DYN(HBDMGRDEV, ahVolumes[cVolumes]));
    454454                    if (pDev)
    455455                    {
  • trunk/src/VBox/Devices/Storage/IOBufMgmt.cpp

    r69500 r73097  
    334334    unsigned cBins = iobufMgrGetBinCount(IOBUFMGR_BIN_SIZE_MIN, IOBUFMGR_BIN_SIZE_MAX);
    335335    uint32_t cObjs = iobufMgrGetObjCount(cbMax, cBins, IOBUFMGR_BIN_SIZE_MIN);
    336     PIOBUFMGRINT pThis = (PIOBUFMGRINT)RTMemAllocZ(RT_OFFSETOF(IOBUFMGRINT, apvObj[cObjs]) + cBins * sizeof(IOBUFMGRBIN));
     336    PIOBUFMGRINT pThis = (PIOBUFMGRINT)RTMemAllocZ(RT_UOFFSETOF_DYN(IOBUFMGRINT, apvObj[cObjs]) + cBins * sizeof(IOBUFMGRBIN));
    337337    if (RT_LIKELY(pThis))
    338338    {
     
    344344        pThis->u32OrderMin     = ASMBitLastSetU32(IOBUFMGR_BIN_SIZE_MIN) - 1;
    345345        pThis->u32OrderMax     = ASMBitLastSetU32(IOBUFMGR_BIN_SIZE_MAX) - 1;
    346         pThis->paBins = (PIOBUFMGRBIN)((uint8_t *)pThis + RT_OFFSETOF(IOBUFMGRINT, apvObj[cObjs]));
     346        pThis->paBins = (PIOBUFMGRBIN)((uint8_t *)pThis + RT_UOFFSETOF_DYN(IOBUFMGRINT, apvObj[cObjs]));
    347347
    348348#ifdef IOBUFMGR_VERIFY_ALLOCATIONS
  • trunk/src/VBox/Devices/Storage/UsbMsd.cpp

    r71964 r73097  
    887887{
    888888    /* Copy the CBW */
    889     size_t cbCopy = RT_OFFSETOF(USBCBW, CBWCB[pCbw->bCBWCBLength]);
     889    size_t cbCopy = RT_UOFFSETOF_DYN(USBCBW, CBWCB[pCbw->bCBWCBLength]);
    890890    memcpy(&pReq->Cbw, pCbw, cbCopy);
    891891    memset((uint8_t *)&pReq->Cbw + cbCopy, 0, sizeof(pReq->Cbw) - cbCopy);
     
    16251625                return usbMsdCompleteStall(pThis, NULL, pUrb, "Bad CBW");
    16261626            }
    1627             if (pUrb->cbData < RT_UOFFSETOF(USBCBW, CBWCB[pCbw->bCBWCBLength]))
     1627            if (pUrb->cbData < RT_UOFFSETOF_DYN(USBCBW, CBWCB[pCbw->bCBWCBLength]))
    16281628            {
    16291629                Log(("usbMsd: CBW: Mismatching cbData and bCBWCBLength values: %#x vs. %#x (%#x)\n",
    1630                      pUrb->cbData, RT_UOFFSETOF(USBCBW, CBWCB[pCbw->bCBWCBLength]), pCbw->bCBWCBLength));
     1630                     pUrb->cbData, RT_UOFFSETOF_DYN(USBCBW, CBWCB[pCbw->bCBWCBLength]), pCbw->bCBWCBLength));
    16311631                return usbMsdCompleteStall(pThis, NULL, pUrb, "Bad CBW");
    16321632            }
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIVpdPagePool.cpp

    r69500 r73097  
    8484    }
    8585
    86     pPage = (PVSCSIVPDPAGE)RTMemAllocZ(RT_OFFSETOF(VSCSIVPDPAGE, abPage[cbPage]));
     86    pPage = (PVSCSIVPDPAGE)RTMemAllocZ(RT_UOFFSETOF_DYN(VSCSIVPDPAGE, abPage[cbPage]));
    8787    if (pPage)
    8888    {
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