sanity.h revision 5380a17599aa35855e4c2cefe9ecbae879a4da58
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/* $Id$ */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** @file
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * innotek Portable Runtime - Setup Sanity Checks, C and C++.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Copyright (C) 2007 innotek GmbH
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * available from http://www.virtualbox.org. This file is free software;
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * you can redistribute it and/or modify it under the terms of the GNU
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * General Public License (GPL) as published by the Free Software
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * The contents of this file may alternatively be used under the terms
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * of the Common Development and Distribution License Version 1.0
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * VirtualBox OSE distribution, in which case the provisions of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * CDDL are applicable instead of those of the GPL.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * You may elect to license modified versions of this file under the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * terms and conditions of either the GPL or the CDDL or both.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#include <iprt/cdefs.h>
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#include <iprt/types.h>
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#include <iprt/assert.h>
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Check that the IN_[RING3|RING0|GC] and [|R3_|R0_|GC_]ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * match up correctly.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * IPRT assumes r0 and r3 to has the same bit count.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if defined(IN_RING3) && ARCH_BITS != R3_ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync# error "defined(IN_RING3) && ARCH_BITS != R3_ARCH_BITS"
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if defined(IN_RING0) && ARCH_BITS != R0_ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync# error "defined(IN_RING0) && ARCH_BITS != R0_ARCH_BITS"
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if defined(IN_GC) && ARCH_BITS != GC_ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync# error "defined(IN_GC) && ARCH_BITS != GC_ARCH_BITS"
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if (defined(IN_RING0) || defined(IN_RING3)) && HC_ARCH_BITS != ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync# error "(defined(IN_RING0) || defined(IN_RING3)) && HC_ARCH_BITS != ARCH_BITS"
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if defined(IN_GC) && GC_ARCH_BITS != ARCH_BITS
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync# error "defined(IN_GC) && GC_ARCH_BITS != ARCH_BITS"
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Check basic host (hc/r0/r3) types.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#if HC_ARCH_BITS == 64
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCPTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCINT, 4);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCUINT, 4);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCINTPTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCUINTPTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTHCINTREG, 8);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCUINTREG, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTR0PTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR0INT, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR0UINT, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTR0INTPTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTR0UINTPTR, 8);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR3PTR, 8);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR3INT, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR3UINT, 4);*/
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTR3INTPTR, 8);
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTR3UINTPTR, 8);
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTUINTPTR, 8);
caee579e589670f6a9444912e548b74ed0764439vboxsync
caee579e589670f6a9444912e548b74ed0764439vboxsync# if defined(IN_RING3) || defined(IN_RING0)
caee579e589670f6a9444912e548b74ed0764439vboxsync/*AssertCompileSize(RTCCINTREG, 8);*/
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTCCUINTREG, 8);
caee579e589670f6a9444912e548b74ed0764439vboxsync# endif
caee579e589670f6a9444912e548b74ed0764439vboxsync
caee579e589670f6a9444912e548b74ed0764439vboxsync#else
caee579e589670f6a9444912e548b74ed0764439vboxsync
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTHCPTR, 4);
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTHCINT, 4);
caee579e589670f6a9444912e548b74ed0764439vboxsyncAssertCompileSize(RTHCUINT, 4);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTHCINTPTR, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTHCUINTPTR, 4);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTR0PTR, 4);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR0INT, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*AssertCompileSize(RTR0UINT, 4);*/
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncAssertCompileSize(RTR0INTPTR, 4);
AssertCompileSize(RTR0UINTPTR, 4);
/*AssertCompileSize(RTR3PTR, 4);*/
/*AssertCompileSize(RTR3INT, 4);*/
/*AssertCompileSize(RTR3UINT, 4);*/
AssertCompileSize(RTR3INTPTR, 4);
AssertCompileSize(RTR3UINTPTR, 4);
# if GC_ARCH_BITS == 64
AssertCompileSize(RTUINTPTR, 8);
# else
AssertCompileSize(RTUINTPTR, 4);
# endif
# if defined(IN_RING3) || defined(IN_RING0)
/*AssertCompileSize(RTCCINTREG, 4);*/
AssertCompileSize(RTCCUINTREG, 4);
# endif
#endif
AssertCompileSize(RTHCPHYS, 8);
/*
* Check basic guest context types.
*/
#if GC_ARCH_BITS == 64
AssertCompileSize(RTGCINT, 4);
AssertCompileSize(RTGCUINT, 4);
AssertCompileSize(RTGCINTPTR, 8);
AssertCompileSize(RTGCUINTPTR, 8);
/*AssertCompileSize(RTGCINTREG, 8);*/
AssertCompileSize(RTGCUINTREG, 8);
# ifdef IN_GC
/*AssertCompileSize(RTCCINTREG, 8);*/
AssertCompileSize(RTCCUINTREG, 8);
# endif
#else
AssertCompileSize(RTGCINT, 4);
AssertCompileSize(RTGCUINT, 4);
AssertCompileSize(RTGCINTPTR, 4);
AssertCompileSize(RTGCUINTPTR, 4);
/*AssertCompileSize(RTGCINTREG, 4);*/
AssertCompileSize(RTGCUINTREG, 4);
# ifdef IN_GC
/*AssertCompileSize(RTCCINTREG, 4);*/
AssertCompileSize(RTCCUINTREG, 4);
# endif
#endif
AssertCompileSize(RTGCPHYS, 4);
/*
* Check basic current context types.
*/
#if ARCH_BITS == 64
AssertCompileSize(void *, 8);
#else
AssertCompileSize(void *, 4);
#endif