Changeset 73097 in vbox for trunk/include
- Timestamp:
- Jul 12, 2018 9:06:33 PM (6 years ago)
- Location:
- trunk/include
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/Graphics/VBoxVideo.h
r71602 r73097 651 651 } VBOXVHWACMD_QUERYINFO2; 652 652 653 #define VBOXVHWAINFO2_SIZE(_cFourCC) RT_ OFFSETOF(VBOXVHWACMD_QUERYINFO2, FourCC[_cFourCC])653 #define VBOXVHWAINFO2_SIZE(_cFourCC) RT_UOFFSETOF_DYN(VBOXVHWACMD_QUERYINFO2, FourCC[_cFourCC]) 654 654 655 655 typedef struct VBOXVHWACMD_SURF_CANCREATE … … 1563 1563 } VBOXVDMACMD_SYSMEMEL, *PVBOXVDMACMD_SYSMEMEL; 1564 1564 1565 #define VBOXVDMACMD_SYSMEMEL_NEXT(_pEl) (((_pEl)->fFlags & VBOXVDMACMD_SYSMEMEL_F_PAGELIST) ? \ 1566 ((PVBOXVDMACMD_SYSMEMEL)(((uint8_t*)(_pEl))+RT_OFFSETOF(VBOXVDMACMD_SYSMEMEL, phBuf[(_pEl)->cPages]))) \ 1567 : \ 1568 ((_pEl)+1) 1565 #define VBOXVDMACMD_SYSMEMEL_NEXT(_pEl) ( ((_pEl)->fFlags & VBOXVDMACMD_SYSMEMEL_F_PAGELIST) \ 1566 ? ((PVBOXVDMACMD_SYSMEMEL)(((uint8_t*)(_pEl)) + RT_UOFFSETOF_DYN(VBOXVDMACMD_SYSMEMEL, phBuf[(_pEl)->cPages]))) \ 1567 : ((_pEl) + 1) ) 1569 1568 1570 1569 #define VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM 0x00000001 -
trunk/include/VBox/VMMDev.h
r72627 r73097 477 477 DECLINLINE(size_t) vmmdevGetMousePointerReqSize(uint32_t width, uint32_t height) 478 478 { 479 size_t cbBase = RT_ OFFSETOF(VMMDevReqMousePointer, pointerData[0]);479 size_t cbBase = RT_UOFFSETOF(VMMDevReqMousePointer, pointerData[0]); 480 480 size_t cbMask = (width + 7) / 8 * height; 481 481 size_t cbArgb = width * height * 4; -
trunk/include/VBox/com/microatl.h
r69107 r73097 110 110 111 111 #define COM_INTERFACE_ENTRY_AGGREGATE(iid, pUnk) \ 112 { &iid, (DWORD_PTR)RT_ OFFSETOF(_ComClass, pUnk), _Delegate},112 { &iid, (DWORD_PTR)RT_UOFFSETOF(_ComClass, pUnk), _Delegate}, 113 113 114 114 #define END_COM_MAP() \ -
trunk/include/VBox/intnet.h
r69107 r73097 170 170 Assert((pBuf)->u32Magic == INTNETBUF_MAGIC); \ 171 171 { \ 172 uint32_t const offRecvStart = (pBuf)->Recv.offStart + RT_ OFFSETOF(INTNETBUF, Recv); \173 uint32_t const offRecvEnd = (pBuf)->Recv.offStart + RT_ OFFSETOF(INTNETBUF, Recv); \174 uint32_t const offSendStart = (pBuf)->Send.offStart + RT_ OFFSETOF(INTNETBUF, Send); \175 uint32_t const offSendEnd = (pBuf)->Send.offStart + RT_ OFFSETOF(INTNETBUF, Send); \172 uint32_t const offRecvStart = (pBuf)->Recv.offStart + RT_UOFFSETOF(INTNETBUF, Recv); \ 173 uint32_t const offRecvEnd = (pBuf)->Recv.offStart + RT_UOFFSETOF(INTNETBUF, Recv); \ 174 uint32_t const offSendStart = (pBuf)->Send.offStart + RT_UOFFSETOF(INTNETBUF, Send); \ 175 uint32_t const offSendEnd = (pBuf)->Send.offStart + RT_UOFFSETOF(INTNETBUF, Send); \ 176 176 \ 177 177 Assert(offRecvEnd > offRecvStart); \ -
trunk/include/VBox/intnetinline.h
r69107 r73097 802 802 803 803 /* receive ring buffer. */ 804 uint32_t offBuf = RT_ALIGN_32(sizeof(INTNETBUF), INTNETRINGBUF_ALIGNMENT) - RT_ OFFSETOF(INTNETBUF, Recv);804 uint32_t offBuf = RT_ALIGN_32(sizeof(INTNETBUF), INTNETRINGBUF_ALIGNMENT) - RT_UOFFSETOF(INTNETBUF, Recv); 805 805 pIntBuf->Recv.offStart = offBuf; 806 806 pIntBuf->Recv.offReadX = offBuf; … … 810 810 811 811 /* send ring buffer. */ 812 offBuf += cbRecv + RT_ OFFSETOF(INTNETBUF, Recv) - RT_OFFSETOF(INTNETBUF, Send);812 offBuf += cbRecv + RT_UOFFSETOF(INTNETBUF, Recv) - RT_UOFFSETOF(INTNETBUF, Send); 813 813 pIntBuf->Send.offStart = offBuf; 814 814 pIntBuf->Send.offReadX = offBuf; -
trunk/include/VBox/vmm/pdmdev.h
r71764 r73097 4119 4119 4120 4120 /** Converts a pointer to the PDMDEVINS::IBase to a pointer to PDMDEVINS. */ 4121 #define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_ OFFSETOF(PDMDEVINS, IBase)) )4121 #define PDMIBASE_2_PDMDEV(pInterface) ( (PPDMDEVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDEVINS, IBase)) ) 4122 4122 4123 4123 /** … … 4225 4225 * Converts a PDM Device instance pointer a RC PDM Device instance pointer. 4226 4226 */ 4227 #define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RT GCUINTPTR)(pDevIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDEVINS, achInstanceData)) )4227 #define PDMDEVINS_2_RCPTR(pDevIns) ( (RCPTRTYPE(PPDMDEVINS))((RTRCUINTPTR)(pDevIns)->pvInstanceDataRC - (RTRCUINTPTR)RT_UOFFSETOF(PDMDEVINS, achInstanceData)) ) 4228 4228 4229 4229 /** @def PDMDEVINS_2_R3PTR 4230 4230 * Converts a PDM Device instance pointer a R3 PDM Device instance pointer. 4231 4231 */ 4232 #define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_ OFFSETOF(PDMDEVINS, achInstanceData)) )4232 #define PDMDEVINS_2_R3PTR(pDevIns) ( (R3PTRTYPE(PPDMDEVINS))((RTHCUINTPTR)(pDevIns)->pvInstanceDataR3 - RT_UOFFSETOF(PDMDEVINS, achInstanceData)) ) 4233 4233 4234 4234 /** @def PDMDEVINS_2_R0PTR 4235 4235 * Converts a PDM Device instance pointer a R0 PDM Device instance pointer. 4236 4236 */ 4237 #define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_ OFFSETOF(PDMDEVINS, achInstanceData)) )4237 #define PDMDEVINS_2_R0PTR(pDevIns) ( (R0PTRTYPE(PPDMDEVINS))((RTR0UINTPTR)(pDevIns)->pvInstanceDataR0 - RT_UOFFSETOF(PDMDEVINS, achInstanceData)) ) 4238 4238 4239 4239 -
trunk/include/VBox/vmm/pdmdrv.h
r69475 r73097 413 413 414 414 /** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */ 415 #define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_ OFFSETOF(PDMDRVINS, IBase)) )415 #define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDRVINS, IBase)) ) 416 416 417 417 /** @def PDMDRVINS_2_RCPTR 418 418 * Converts a PDM Driver instance pointer a RC PDM Driver instance pointer. 419 419 */ 420 #define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RT GCUINTPTR)(pDrvIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDRVINS, achInstanceData)) )420 #define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RTRCUINTPTR)(pDrvIns)->pvInstanceDataRC - (RTRCUINTPTR)RT_UOFFSETOF(PDMDRVINS, achInstanceData)) ) 421 421 422 422 /** @def PDMDRVINS_2_R3PTR 423 423 * Converts a PDM Driver instance pointer a R3 PDM Driver instance pointer. 424 424 */ 425 #define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_ OFFSETOF(PDMDRVINS, achInstanceData)) )425 #define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) ) 426 426 427 427 /** @def PDMDRVINS_2_R0PTR 428 428 * Converts a PDM Driver instance pointer a R0 PDM Driver instance pointer. 429 429 */ 430 #define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_ OFFSETOF(PDMDRVINS, achInstanceData)) )430 #define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) ) 431 431 432 432 -
trunk/include/VBox/vmm/pdmsrv.h
r69475 r73097 285 285 286 286 /** Converts a pointer to the PDMSRVINS::IBase to a pointer to PDMSRVINS. */ 287 #define PDMIBASE_2_PDMSRV(pInterface) ( (PPDMSRVINS)((char *)(pInterface) - RT_ OFFSETOF(PDMSRVINS, IBase)) )287 #define PDMIBASE_2_PDMSRV(pInterface) ( (PPDMSRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMSRVINS, IBase)) ) 288 288 289 289 -
trunk/include/VBox/vmm/pdmusb.h
r70322 r73097 842 842 843 843 /** Converts a pointer to the PDMUSBINS::IBase to a pointer to PDMUSBINS. */ 844 #define PDMIBASE_2_PDMUSB(pInterface) ( (PPDMUSBINS)((char *)(pInterface) - RT_ OFFSETOF(PDMUSBINS, IBase)) )844 #define PDMIBASE_2_PDMUSB(pInterface) ( (PPDMUSBINS)((char *)(pInterface) - RT_UOFFSETOF(PDMUSBINS, IBase)) ) 845 845 846 846 -
trunk/include/VBox/vmm/ssm.h
r69107 r73097 239 239 * @internal */ 240 240 #define SSMFIELD_ENTRY_TF_INT(Type, Field, enmTransformer, uFirstVer) \ 241 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_ OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), enmTransformer, uFirstVer)241 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_UOFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), enmTransformer, uFirstVer) 242 242 /** Emit a SSMFIELD array entry for an old field. 243 243 * @internal */ … … 247 247 * @internal */ 248 248 #define SSMFIELD_ENTRY_PAD_INT(Type, Field, cb32, cb64, enmTransformer) \ 249 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_ OFFSETOF(Type, Field), \249 SSMFIELD_ENTRY_INT(#Type "::" #Field, RT_UOFFSETOF(Type, Field), \ 250 250 (RT_SIZEOFMEMB(Type, Field) << 16) | (cb32) | ((cb64) << 8), enmTransformer, 0) 251 251 /** Emit a SSMFIELD array entry for an alignment padding. … … 369 369 /** Emit a SSMFIELD array entry for a field with a custom callback. */ 370 370 #define SSMFIELD_ENTRY_CALLBACK(Type, Field, pfnGetPut) \ 371 { (pfnGetPut), RT_ OFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), 0, #Type "::" #Field }371 { (pfnGetPut), RT_UOFFSETOF(Type, Field), RT_SIZEOFMEMB(Type, Field), 0, #Type "::" #Field } 372 372 /** Emit the terminating entry of a SSMFIELD array. */ 373 373 #define SSMFIELD_ENTRY_TERM() \ -
trunk/include/iprt/cdefs.h
r72774 r73097 2265 2265 * Our own special offsetof() variant, returns a signed result. 2266 2266 * 2267 * This differs from the usual offsetof() in that it's not relying on builtin2268 * compiler stuff and thus can use variables in arrays the structure may2269 * contain. This is useful to determine the sizes of structures ending2270 * with a variable length field. For gcc >= 4.4 see @bugref{7775}.2271 *2272 2267 * @returns offset into the structure of the specified member. signed. 2273 2268 * @param type Structure type. 2274 2269 * @param member Member. 2275 */ 2276 #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4) 2277 # define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 ) 2278 #else 2279 # define RT_OFFSETOF(type, member) ( (int)(uintptr_t)&( ((type *)(void *)0)->member) ) 2270 * 2271 * @remarks Only use this for static offset calculations. Please 2272 * use RT_UOFFSETOF_DYN for dynamic ones (i.e. involves 2273 * non-constant array indexing). 2274 * 2275 */ 2276 #if RT_GNUC_PREREQ(4, 0) 2277 # define RT_OFFSETOF(type, member) ( (int)__builtin_offsetof(type, member) ) 2278 #else 2279 # define RT_OFFSETOF(type, member) ( (int)(intptr_t)&( ((type *)(void *)0)->member) ) 2280 2280 #endif 2281 2281 2282 2282 /** @def RT_UOFFSETOF 2283 * Our own special offsetof() variant, returns an unsigned result. 2284 * 2285 * This differs from the usual offsetof() in that it's not relying on builtin 2286 * compiler stuff and thus can use variables in arrays the structure may 2287 * contain. This is useful to determine the sizes of structures ending 2288 * with a variable length field. For gcc >= 4.4 see @bugref{7775}. 2283 * Our own offsetof() variant, returns an unsigned result. 2289 2284 * 2290 2285 * @returns offset into the structure of the specified member. unsigned. 2291 2286 * @param type Structure type. 2292 2287 * @param member Member. 2293 */ 2294 #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4) 2295 # define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0x1000)->member) - 0x1000 ) 2288 * 2289 * @remarks Only use this for static offset calculations. Please 2290 * use RT_UOFFSETOF_DYN for dynamic ones (i.e. involves 2291 * non-constant array indexing). 2292 */ 2293 #if RT_GNUC_PREREQ(4, 0) 2294 # define RT_UOFFSETOF(type, member) ( (uintptr_t)__builtin_offsetof(type, member) ) 2296 2295 #else 2297 2296 # define RT_UOFFSETOF(type, member) ( (uintptr_t)&( ((type *)(void *)0)->member) ) … … 2305 2304 * @param member Member. 2306 2305 * @param addend The addend to add to the offset. 2306 * 2307 * @remarks Only use this for static offset calculations. 2307 2308 */ 2308 2309 #define RT_OFFSETOF_ADD(type, member, addend) ( (int)RT_UOFFSETOF_ADD(type, member, addend) ) … … 2315 2316 * @param member Member. 2316 2317 * @param addend The addend to add to the offset. 2317 */ 2318 #define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) ) 2318 * 2319 * @remarks Only use this for static offset calculations. 2320 */ 2321 #if RT_GNUC_PREREQ(4, 0) 2322 # define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)(__builtin_offsetof(type, member) + (addend))) 2323 #else 2324 # define RT_UOFFSETOF_ADD(type, member, addend) ( (uintptr_t)&( ((type *)(void *)(uintptr_t)(addend))->member) ) 2325 #endif 2326 2327 /** @def RT_UOFFSETOF_DYN 2328 * Dynamic (runtime) structure offset calculations, involving 2329 * indexing of array members via variable. 2330 * 2331 * @returns offset into the structure of the specified member. signed. 2332 * @param type Structure type. 2333 * @param memberarray Member. 2334 */ 2335 #if defined(__cplusplus) && RT_GNUC_PREREQ(4, 4) 2336 # define RT_UOFFSETOF_DYN(type, memberarray) ( (uintptr_t)&( ((type *)(void *)0x1000)->memberarray) - 0x1000 ) 2337 #else 2338 # define RT_UOFFSETOF_DYN(type, memberarray) ( (uintptr_t)&( ((type *)(void *)0)->memberarray) ) 2339 #endif 2340 2319 2341 2320 2342 /** @def RT_SIZEOFMEMB -
trunk/include/iprt/nt/nt.h
r72639 r73097 1494 1494 #if !defined(NtCurrentTeb) && !defined(IPRT_NT_HAVE_CURRENT_TEB_MACRO) 1495 1495 # ifdef RT_ARCH_X86 1496 DECL_FORCE_INLINE(PTEB) RTNtCurrentTeb(void) { return (PTEB)__readfsdword(RT_ OFFSETOF(TEB_COMMON, NtTib.Self)); }1497 DECL_FORCE_INLINE(PPEB) RTNtCurrentPeb(void) { return (PPEB)__readfsdword(RT_ OFFSETOF(TEB_COMMON, ProcessEnvironmentBlock)); }1498 DECL_FORCE_INLINE(uint32_t) RTNtCurrentThreadId(void) { return __readfsdword(RT_ OFFSETOF(TEB_COMMON, ClientId.UniqueThread)); }1499 DECL_FORCE_INLINE(NTSTATUS) RTNtLastStatusValue(void) { return (NTSTATUS)__readfsdword(RT_ OFFSETOF(TEB_COMMON, LastStatusValue)); }1500 DECL_FORCE_INLINE(uint32_t) RTNtLastErrorValue(void) { return __readfsdword(RT_ OFFSETOF(TEB_COMMON, LastErrorValue)); }1496 DECL_FORCE_INLINE(PTEB) RTNtCurrentTeb(void) { return (PTEB)__readfsdword(RT_UOFFSETOF(TEB_COMMON, NtTib.Self)); } 1497 DECL_FORCE_INLINE(PPEB) RTNtCurrentPeb(void) { return (PPEB)__readfsdword(RT_UOFFSETOF(TEB_COMMON, ProcessEnvironmentBlock)); } 1498 DECL_FORCE_INLINE(uint32_t) RTNtCurrentThreadId(void) { return __readfsdword(RT_UOFFSETOF(TEB_COMMON, ClientId.UniqueThread)); } 1499 DECL_FORCE_INLINE(NTSTATUS) RTNtLastStatusValue(void) { return (NTSTATUS)__readfsdword(RT_UOFFSETOF(TEB_COMMON, LastStatusValue)); } 1500 DECL_FORCE_INLINE(uint32_t) RTNtLastErrorValue(void) { return __readfsdword(RT_UOFFSETOF(TEB_COMMON, LastErrorValue)); } 1501 1501 # elif defined(RT_ARCH_AMD64) 1502 DECL_FORCE_INLINE(PTEB) RTNtCurrentTeb(void) { return (PTEB)__readgsqword(RT_ OFFSETOF(TEB_COMMON, NtTib.Self)); }1503 DECL_FORCE_INLINE(PPEB) RTNtCurrentPeb(void) { return (PPEB)__readgsqword(RT_ OFFSETOF(TEB_COMMON, ProcessEnvironmentBlock)); }1504 DECL_FORCE_INLINE(uint32_t) RTNtCurrentThreadId(void) { return __readgsdword(RT_ OFFSETOF(TEB_COMMON, ClientId.UniqueThread)); }1505 DECL_FORCE_INLINE(NTSTATUS) RTNtLastStatusValue(void) { return (NTSTATUS)__readgsdword(RT_ OFFSETOF(TEB_COMMON, LastStatusValue)); }1506 DECL_FORCE_INLINE(uint32_t) RTNtLastErrorValue(void) { return __readgsdword(RT_ OFFSETOF(TEB_COMMON, LastErrorValue)); }1502 DECL_FORCE_INLINE(PTEB) RTNtCurrentTeb(void) { return (PTEB)__readgsqword(RT_UOFFSETOF(TEB_COMMON, NtTib.Self)); } 1503 DECL_FORCE_INLINE(PPEB) RTNtCurrentPeb(void) { return (PPEB)__readgsqword(RT_UOFFSETOF(TEB_COMMON, ProcessEnvironmentBlock)); } 1504 DECL_FORCE_INLINE(uint32_t) RTNtCurrentThreadId(void) { return __readgsdword(RT_UOFFSETOF(TEB_COMMON, ClientId.UniqueThread)); } 1505 DECL_FORCE_INLINE(NTSTATUS) RTNtLastStatusValue(void) { return (NTSTATUS)__readgsdword(RT_UOFFSETOF(TEB_COMMON, LastStatusValue)); } 1506 DECL_FORCE_INLINE(uint32_t) RTNtLastErrorValue(void) { return __readgsdword(RT_UOFFSETOF(TEB_COMMON, LastErrorValue)); } 1507 1507 # else 1508 1508 # error "Port me"
Note:
See TracChangeset
for help on using the changeset viewer.