VirtualBox

Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (7 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/Additions/common/VBoxGuest/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibHGCMInternal.cpp

    r72627 r73097  
    235235                    pPgLst = (HGCMPageListInfo *)((uint8_t *)pCallInfo + off);
    236236                    cPages = pPgLst->cPages;
    237                     u32    = RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]) + off;
     237                    u32    = RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]) + off;
    238238                    AssertMsgReturn(u32 <= cbCallInfo,
    239239                                    ("u32=%#x (cPages=%#x offset=%#x) cbCallInfo=%#x\n", u32, cPages, off, cbCallInfo),
     
    254254                    }
    255255
    256                     *pcbExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[pPgLst->cPages]);
     256                    *pcbExtra += RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[pPgLst->cPages]);
    257257                }
    258258                else
     
    407407                    {
    408408                        size_t const cPages = RTR0MemObjSize(hObj) >> PAGE_SHIFT;
    409                         *pcbExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
     409                        *pcbExtra += RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]);
    410410                    }
    411411                }
     
    541541                        pDstPgLst->aPages[iPage] = pSrcPgLst->aPages[iPage];
    542542
    543                     offExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
     543                    offExtra += RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]);
    544544                }
    545545                else
     
    592592                        }
    593593
    594                         offExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
     594                        offExtra += RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]);
    595595                    }
    596596                    else
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibSharedFolders.c

    r72627 r73097  
    325325{
    326326    uint32_t            cbToRead  = *pcbBuffer;
    327     uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFRead) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]));
     327    uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFRead) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
    328328    VBoxSFRead         *pData     = (VBoxSFRead *)RTMemTmpAlloc(cbData);
    329329    HGCMPageListInfo   *pPgLst    = (HGCMPageListInfo *)(pData + 1);
     
    403403    uint32_t            cbToWrite = *pcbBuffer;
    404404    uint32_t            cPages    = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
    405     uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]));
     405    uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
    406406    VBoxSFWrite        *pData     = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
    407407    HGCMPageListInfo   *pPgLst    = (HGCMPageListInfo *)(pData + 1);
     
    451451{
    452452    uint32_t            cbToWrite = *pcbBuffer;
    453     uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]));
     453    uint32_t            cbData    = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
    454454    VBoxSFWrite        *pData     = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
    455455    HGCMPageListInfo   *pPgLst    = (HGCMPageListInfo *)(pData + 1);
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestUser.cpp

    r69500 r73097  
    8787         *       without altering this code. Don't try this at home.
    8888         */
    89         uint32_t cbOffDynamic = RT_OFFSETOF(VBoxGuestUserStatus, szUser);
     89        uint32_t cbOffDynamic = RT_UOFFSETOF(VBoxGuestUserStatus, szUser);
    9090
    9191        /* pDynamic marks the beginning for the dynamically allocated areas. */
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibModule.cpp

    r69500 r73097  
    5454    AssertReturn(cRegions < VMMDEVSHAREDREGIONDESC_MAX, VERR_INVALID_PARAMETER);
    5555
    56     pReq = (VMMDevSharedModuleRegistrationRequest *)RTMemAllocZ(RT_OFFSETOF(VMMDevSharedModuleRegistrationRequest, aRegions[cRegions]));
     56    pReq = (VMMDevSharedModuleRegistrationRequest *)RTMemAllocZ(RT_UOFFSETOF_DYN(VMMDevSharedModuleRegistrationRequest,
     57                                                                                 aRegions[cRegions]));
    5758    AssertReturn(pReq, VERR_NO_MEMORY);
    5859
    5960    vmmdevInitRequest(&pReq->header, VMMDevReq_RegisterSharedModule);
    60     pReq->header.size   = RT_OFFSETOF(VMMDevSharedModuleRegistrationRequest, aRegions[cRegions]);
     61    pReq->header.size   = RT_UOFFSETOF_DYN(VMMDevSharedModuleRegistrationRequest, aRegions[cRegions]);
    6162    pReq->GCBaseAddr    = GCBaseAddr;
    6263    pReq->cbModule      = cbModule;
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibVideo.cpp

    r72354 r73097  
    102102    size_t cbReq = vmmdevGetMousePointerReqSize(cx, cy);
    103103    AssertReturn(   !pvImg
    104                  || cbReq == RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg,
     104                 || cbReq == RT_UOFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg,
    105105                 VERR_INVALID_PARAMETER);
    106106    int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, cbReq, VMMDevReq_SetPointerShape);
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