tstDeviceStructSize.cpp revision df3a016ea59e69ab2758221fd91e62a9782b144e
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * tstDeviceStructSize - testcase for check structure sizes/alignment
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * and to verify that HC and RC uses the same
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * representation of the structures.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * available from http://www.virtualbox.org. This file is free software;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * General Public License (GPL) as published by the Free Software
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * additional information or have any questions.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/*******************************************************************************
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync* Header Files *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync*******************************************************************************/
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include "../PC/DevPIC.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include "../PC/DevRTC.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# include "../PC/DevHPET.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# include "../PC/DevLPC.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# include "../PC/DevSMC.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# include "../USB/DevOHCI.cpp"
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# include "../USB/DevEHCI.cpp"
#ifdef VBOX_WITH_BUSLOGIC
# include "../Storage/DevBusLogic.cpp"
#ifdef VBOX_WITH_LSILOGIC
# include "../Storage/DevLsiLogicSCSI.cpp"
#include <stdio.h>
printf("tstDeviceStructSize: error! %#010x %s Off by %d!! (off=%#x)\n", RT_OFFSETOF(type, m), #type "." #m, off - RT_OFFSETOF(type, m), off); \
rc++; \
printf("tstDeviceStructSize: error! sizeof(%s): %#x (%d) Off by %d!!\n", #type, (int)sizeof(type), (int)sizeof(type), (int)(sizeof(type) - size)); \
rc++; \
printf("tstDeviceStructSize: info: sizeof(%s): %#x (%d)\n", #type, (int)sizeof(type), (int)sizeof(type)); \
printf("tstDeviceStructSize: error! %s::%s offset=%#x (%u) expected alignment %x, meaning %#x (%u) off\n", \
(unsigned)(align), \
rc++; \
#type, \
(unsigned)sizeof(type), \
(unsigned)sizeof(type), \
(align), \
rc++; \
strct *p; \
printf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d correct=%d\n", #strct, #member, \
(int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
rc++; \
printf("tstDeviceStructSize: error! padding of %s::%s is misaligned, padding=%d correct=%d\n", #strct, #member, \
rc++; \
strct *p; \
if (sizeof(p->s) > sizeof(p->padding)) \
printf("tstDeviceStructSize: error! padding of %s is too small, padding=%d struct=%d correct=%d\n", #strct, \
rc++; \
strct *p; \
printf("tstDeviceStructSize: error! padding of %s::%s is too small, padding=%d struct=%d\n", #strct, #member, \
rc++; \
printf("tstDeviceStructSize: info: %s::%s offset %d sizeof %d\n", #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
int main()
int rc = 0;
#ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_USB
# ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_USB
# ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_STATISTICS
#ifdef VBOX_WITH_VIRTIO
#ifdef VBOX_WITH_RAW_MODE
# include "tstDeviceStructSizeRC.h"
if (rc)
return rc;