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/HostServices/SharedOpenGL/crserverlib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.cpp

    r71607 r73097  
    2929//#define CR_SERVER_WITH_CLIENT_CALLOUTS
    3030
    31 #define PCR_FBTEX_FROM_TEX(_pTex) ((CR_FBTEX*)((uint8_t*)(_pTex) - RT_OFFSETOF(CR_FBTEX, Tex)))
    32 #define PCR_FRAMEBUFFER_FROM_COMPOSITOR(_pCompositor) ((CR_FRAMEBUFFER*)((uint8_t*)(_pCompositor) - RT_OFFSETOF(CR_FRAMEBUFFER, Compositor)))
    33 #define PCR_FBENTRY_FROM_ENTRY(_pEntry) ((CR_FRAMEBUFFER_ENTRY*)((uint8_t*)(_pEntry) - RT_OFFSETOF(CR_FRAMEBUFFER_ENTRY, Entry)))
     31#define PCR_FBTEX_FROM_TEX(_pTex) ((CR_FBTEX*)((uint8_t*)(_pTex) - RT_UOFFSETOF(CR_FBTEX, Tex)))
     32#define PCR_FRAMEBUFFER_FROM_COMPOSITOR(_pCompositor) ((CR_FRAMEBUFFER*)((uint8_t*)(_pCompositor) - RT_UOFFSETOF(CR_FRAMEBUFFER, Compositor)))
     33#define PCR_FBENTRY_FROM_ENTRY(_pEntry) ((CR_FRAMEBUFFER_ENTRY*)((uint8_t*)(_pEntry) - RT_UOFFSETOF(CR_FRAMEBUFFER_ENTRY, Entry)))
    3434
    3535
     
    33893389    uint32_t cRects;
    33903390    const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;
    3391     if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) % sizeof (VBOXCMDVBVA_RECT))
     3391    if ((cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) % sizeof (VBOXCMDVBVA_RECT))
    33923392    {
    33933393        WARN(("invalid argument size"));
     
    33953395    }
    33963396
    3397     cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) / sizeof (VBOXCMDVBVA_RECT);
     3397    cRects = (cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_PRIMARY, aRects)) / sizeof (VBOXCMDVBVA_RECT);
    33983398
    33993399    RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);
     
    36503650    uint32_t cRects;
    36513651    const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;
    3652     if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects)) % sizeof (VBOXCMDVBVA_RECT))
     3652    if ((cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects)) % sizeof (VBOXCMDVBVA_RECT))
    36533653    {
    36543654        WARN(("invalid argument size"));
     
    36563656    }
    36573657
    3658     cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects)) / sizeof (VBOXCMDVBVA_RECT);
     3658    cRects = (cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects)) / sizeof (VBOXCMDVBVA_RECT);
    36593659
    36603660    RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);
     
    36983698    uint32_t cRects;
    36993699    const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;
    3700     if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
     3700    if ((cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
    37013701    {
    37023702        WARN(("invalid argument size"));
     
    37043704    }
    37053705
    3706     cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
     3706    cRects = (cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
    37073707
    37083708    RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);
     
    37673767    uint32_t cRects;
    37683768    const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;
    3769     if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
     3769    if ((cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
    37703770    {
    37713771        WARN(("invalid argument size"));
     
    37733773    }
    37743774
    3775     cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
     3775    cRects = (cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
    37763776
    37773777    RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);
     
    38623862    uint32_t cRects;
    38633863    const VBOXCMDVBVA_RECT *pPRects = pCmd->aRects;
    3864     if ((cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
     3864    if ((cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, aRects)) % sizeof (VBOXCMDVBVA_RECT))
    38653865    {
    38663866        WARN(("invalid argument size"));
     
    38683868    }
    38693869
    3870     cRects = (cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
     3870    cRects = (cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, aRects)) / sizeof (VBOXCMDVBVA_RECT);
    38713871
    38723872    RTRECT *pRects = crVBoxServerCrCmdBltRecsUnpack(pPRects, cRects);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r71680 r73097  
    935935    CRASSERT(rc == VINF_SUCCESS);
    936936
    937     rc = SSMR3PutMem(pSSM, pMI, RT_OFFSETOF(CRMuralInfo, CreateInfo));
     937    rc = SSMR3PutMem(pSSM, pMI, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
    938938    CRASSERT(rc == VINF_SUCCESS);
    939939
     
    13871387    } Data;
    13881388
    1389     Assert(sizeof (Data) >= RT_OFFSETOF(CRFBData, aElements[4]));
     1389    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
    13901390
    13911391    pCtxInfo = cr_server.currentCtxInfo;
     
    19381938        rc = crServerLsrDataGetMem(pReader, &key, sizeof(key));
    19391939        AssertLogRelRCReturn(rc, rc);
    1940         rc = crServerLsrDataGetMem(pReader, &muralInfo, RT_OFFSETOF(CRMuralInfo, CreateInfo));
     1940        rc = crServerLsrDataGetMem(pReader, &muralInfo, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
    19411941        AssertLogRelRCReturn(rc, rc);
    19421942
     
    19521952                CR_SERVER_BUGGY_MURAL_DATA Data;
    19531953                /* need to chak spuWindow, so taking the offset of filed following it*/
    1954                 uint8_t au8[RT_OFFSETOF(CRMuralInfo, screenId)];
     1954                uint8_t au8[RT_UOFFSETOF(CRMuralInfo, screenId)];
    19551955                RTRECT aVisRects[sizeof (CR_SERVER_BUGGY_MURAL_DATA) / sizeof (RTRECT)];
    19561956            } LaBuf;
     
    20912091    } Data;
    20922092
    2093     Assert(sizeof (Data) >= RT_OFFSETOF(CRFBData, aElements[4]));
     2093    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
    20942094
    20952095    if (version >= SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
     
    21772177        if (Data.data.cElements)
    21782178        {
    2179             CRFBData *pLazyData = crAlloc(RT_OFFSETOF(CRFBData, aElements[Data.data.cElements]));
     2179            CRFBData *pLazyData = crAlloc(RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
    21802180            if (!RT_SUCCESS(rc))
    21812181            {
     
    21852185            }
    21862186
    2187             crMemcpy(pLazyData, &Data.data, RT_OFFSETOF(CRFBData, aElements[Data.data.cElements]));
     2187            crMemcpy(pLazyData, &Data.data, RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
    21882188            pBuf->pFrontImg = pLazyData;
    21892189        }
     
    29022902    cParams = cBuffers-1;
    29032903
    2904     if (cbCmd < RT_OFFSETOF(VBOXCMDVBVA_CRCMD_CMD, aBuffers[cBuffers]))
     2904    if (cbCmd < RT_UOFFSETOF_DYN(VBOXCMDVBVA_CRCMD_CMD, aBuffers[cBuffers]))
    29052905    {
    29062906        WARN(("invalid buffer size"));
     
    33253325                    VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *p3DCmd
    33263326                        = (VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *)pbCmd;
    3327                     return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd));
     3327                    return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd));
    33283328                }
    33293329
     
    35433543                    = (VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd;
    35443544                VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmd = &pCrCmdDr->Cmd;
    3545                 int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd));
     3545                int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_CRCMD, Cmd));
    35463546                ASSERT_GUEST_LOGREL_RC_RETURN(rc, -1);
    35473547                return 0;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c

    r71468 r73097  
    433433    }
    434434
    435     pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(cbMsg + RT_OFFSETOF(CR_SERVER_PENDING_MSG, Msg));
     435    pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(cbMsg + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
    436436    if (!pMsg)
    437437    {
     
    524524                break;
    525525
    526             pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(u32 + RT_OFFSETOF(CR_SERVER_PENDING_MSG, Msg));
     526            pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(u32 + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
    527527            if (!pMsg)
    528528            {
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