VirtualBox

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


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/Devices/VirtIO
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VirtIO/Virtio.cpp

    r71788 r73097  
    2828
    2929#define INSTANCE(pState) pState->szInstance
    30 #define IFACE_TO_STATE(pIface, ifaceName) ((VPCISTATE *)((char*)pIface - RT_OFFSETOF(VPCISTATE, ifaceName)))
     30#define IFACE_TO_STATE(pIface, ifaceName) ((VPCISTATE *)((char*)(pIface) - RT_UOFFSETOF(VPCISTATE, ifaceName)))
    3131
    3232#ifdef LOG_ENABLED
     
    5858        + sizeof(VRINGDESC) * pQueue->VRing.uSize;
    5959    pQueue->VRing.addrUsed        = RT_ALIGN(
    60         pQueue->VRing.addrAvail + RT_OFFSETOF(VRINGAVAIL, auRing[pQueue->VRing.uSize]),
     60        pQueue->VRing.addrAvail + RT_UOFFSETOF_DYN(VRINGAVAIL, auRing[pQueue->VRing.uSize]),
    6161        PAGE_SIZE); /* The used ring must start from the next page. */
    6262    pQueue->uNextAvailIndex       = 0;
     
    8181
    8282    PDMDevHlpPhysRead(pState->CTX_SUFF(pDevIns),
    83                       pVRing->addrAvail + RT_OFFSETOF(VRINGAVAIL, auRing[uIndex % pVRing->uSize]),
     83                      pVRing->addrAvail + RT_UOFFSETOF_DYN(VRINGAVAIL, auRing[uIndex % pVRing->uSize]),
    8484                      &tmp, sizeof(tmp));
    8585    return tmp;
     
    9191
    9292    PDMDevHlpPhysRead(pState->CTX_SUFF(pDevIns),
    93                       pVRing->addrAvail + RT_OFFSETOF(VRINGAVAIL, uFlags),
     93                      pVRing->addrAvail + RT_UOFFSETOF(VRINGAVAIL, uFlags),
    9494                      &tmp, sizeof(tmp));
    9595    return tmp;
     
    101101
    102102    PDMDevHlpPhysRead(pState->CTX_SUFF(pDevIns),
    103                       pVRing->addrUsed + RT_OFFSETOF(VRINGUSED, uFlags),
     103                      pVRing->addrUsed + RT_UOFFSETOF(VRINGUSED, uFlags),
    104104                      &tmp, sizeof(tmp));
    105105
     
    110110
    111111    PDMDevHlpPCIPhysWrite(pState->CTX_SUFF(pDevIns),
    112                           pVRing->addrUsed + RT_OFFSETOF(VRINGUSED, uFlags),
     112                          pVRing->addrUsed + RT_UOFFSETOF(VRINGUSED, uFlags),
    113113                          &tmp, sizeof(tmp));
    114114}
     
    197197    uint16_t tmp;
    198198    PDMDevHlpPhysRead(pState->CTX_SUFF(pDevIns),
    199                       pVRing->addrUsed + RT_OFFSETOF(VRINGUSED, uIndex),
     199                      pVRing->addrUsed + RT_UOFFSETOF(VRINGUSED, uIndex),
    200200                      &tmp, sizeof(tmp));
    201201    return tmp;
     
    205205{
    206206    PDMDevHlpPCIPhysWrite(pState->CTX_SUFF(pDevIns),
    207                           pVRing->addrUsed + RT_OFFSETOF(VRINGUSED, uIndex),
     207                          pVRing->addrUsed + RT_UOFFSETOF(VRINGUSED, uIndex),
    208208                          &u16Value, sizeof(u16Value));
    209209}
     
    216216    elem.uLen = uLen;
    217217    PDMDevHlpPCIPhysWrite(pState->CTX_SUFF(pDevIns),
    218                           pVRing->addrUsed + RT_OFFSETOF(VRINGUSED, aRing[uIndex % pVRing->uSize]),
     218                          pVRing->addrUsed + RT_UOFFSETOF_DYN(VRINGUSED, aRing[uIndex % pVRing->uSize]),
    219219                          &elem, sizeof(elem));
    220220}
  • trunk/src/VBox/Devices/VirtIO/Virtio.h

    r69500 r73097  
    299299
    300300    PDMDevHlpPhysRead(pState->CTX_SUFF(pDevIns),
    301                       pVRing->addrAvail + RT_OFFSETOF(VRINGAVAIL, uNextFreeIndex),
     301                      pVRing->addrAvail + RT_UOFFSETOF(VRINGAVAIL, uNextFreeIndex),
    302302                      &tmp, sizeof(tmp));
    303303    return tmp;
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