1 | /* $Id: sanity.h 13832 2008-11-05 02:01:12Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Setup Sanity Checks, C and C++.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | *
|
---|
26 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
27 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
28 | * additional information or have any questions.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #include <iprt/cdefs.h>
|
---|
32 | #include <iprt/types.h>
|
---|
33 | #include <iprt/assert.h>
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * Check that the IN_[RING3|RING0|GC] and [|R3_|R0_|GC_]ARCH_BITS
|
---|
37 | * match up correctly.
|
---|
38 | *
|
---|
39 | * IPRT assumes r0 and r3 to has the same bit count.
|
---|
40 | */
|
---|
41 |
|
---|
42 | #if defined(IN_RING3) && ARCH_BITS != R3_ARCH_BITS
|
---|
43 | # error "defined(IN_RING3) && ARCH_BITS != R3_ARCH_BITS"
|
---|
44 | #endif
|
---|
45 | #if defined(IN_RING0) && ARCH_BITS != R0_ARCH_BITS
|
---|
46 | # error "defined(IN_RING0) && ARCH_BITS != R0_ARCH_BITS"
|
---|
47 | #endif
|
---|
48 | #if defined(IN_RC) && ARCH_BITS != 32
|
---|
49 | # error "defined(IN_RC) && ARCH_BITS != 32"
|
---|
50 | #endif
|
---|
51 | #if (defined(IN_RING0) || defined(IN_RING3)) && HC_ARCH_BITS != ARCH_BITS
|
---|
52 | # error "(defined(IN_RING0) || defined(IN_RING3)) && HC_ARCH_BITS != ARCH_BITS"
|
---|
53 | #endif
|
---|
54 | #if defined(IN_RC) && GC_ARCH_BITS != 64 && GC_ARCH_BITS != ARCH_BITS
|
---|
55 | # error "defined(IN_RC) && GC_ARCH_BITS != ARCH_BITS"
|
---|
56 | #endif
|
---|
57 |
|
---|
58 |
|
---|
59 | /*
|
---|
60 | * Check basic host (hc/r0/r3) types.
|
---|
61 | */
|
---|
62 | #if HC_ARCH_BITS == 64
|
---|
63 |
|
---|
64 | AssertCompileSize(RTHCPTR, 8);
|
---|
65 | AssertCompileSize(RTHCINT, 4);
|
---|
66 | AssertCompileSize(RTHCUINT, 4);
|
---|
67 | AssertCompileSize(RTHCINTPTR, 8);
|
---|
68 | AssertCompileSize(RTHCUINTPTR, 8);
|
---|
69 | /*AssertCompileSize(RTHCINTREG, 8);*/
|
---|
70 | AssertCompileSize(RTHCUINTREG, 8);
|
---|
71 | AssertCompileSize(RTR0PTR, 8);
|
---|
72 | /*AssertCompileSize(RTR0INT, 4);*/
|
---|
73 | /*AssertCompileSize(RTR0UINT, 4);*/
|
---|
74 | AssertCompileSize(RTR0INTPTR, 8);
|
---|
75 | AssertCompileSize(RTR0UINTPTR, 8);
|
---|
76 | /*AssertCompileSize(RTR3PTR, 8);*/
|
---|
77 | /*AssertCompileSize(RTR3INT, 4);*/
|
---|
78 | /*AssertCompileSize(RTR3UINT, 4);*/
|
---|
79 | AssertCompileSize(RTR3INTPTR, 8);
|
---|
80 | AssertCompileSize(RTR3UINTPTR, 8);
|
---|
81 | AssertCompileSize(RTUINTPTR, 8);
|
---|
82 |
|
---|
83 | # if defined(IN_RING3) || defined(IN_RING0)
|
---|
84 | /*AssertCompileSize(RTCCINTREG, 8);*/
|
---|
85 | AssertCompileSize(RTCCUINTREG, 8);
|
---|
86 | # endif
|
---|
87 |
|
---|
88 | #else
|
---|
89 |
|
---|
90 | AssertCompileSize(RTHCPTR, 4);
|
---|
91 | AssertCompileSize(RTHCINT, 4);
|
---|
92 | AssertCompileSize(RTHCUINT, 4);
|
---|
93 | /*AssertCompileSize(RTHCINTPTR, 4);*/
|
---|
94 | AssertCompileSize(RTHCUINTPTR, 4);
|
---|
95 | AssertCompileSize(RTR0PTR, 4);
|
---|
96 | /*AssertCompileSize(RTR0INT, 4);*/
|
---|
97 | /*AssertCompileSize(RTR0UINT, 4);*/
|
---|
98 | AssertCompileSize(RTR0INTPTR, 4);
|
---|
99 | AssertCompileSize(RTR0UINTPTR, 4);
|
---|
100 | /*AssertCompileSize(RTR3PTR, 4);*/
|
---|
101 | /*AssertCompileSize(RTR3INT, 4);*/
|
---|
102 | /*AssertCompileSize(RTR3UINT, 4);*/
|
---|
103 | AssertCompileSize(RTR3INTPTR, 4);
|
---|
104 | AssertCompileSize(RTR3UINTPTR, 4);
|
---|
105 | # if GC_ARCH_BITS == 64
|
---|
106 | AssertCompileSize(RTUINTPTR, 8);
|
---|
107 | # else
|
---|
108 | AssertCompileSize(RTUINTPTR, 4);
|
---|
109 | # endif
|
---|
110 |
|
---|
111 | # if defined(IN_RING3) || defined(IN_RING0)
|
---|
112 | /*AssertCompileSize(RTCCINTREG, 4);*/
|
---|
113 | AssertCompileSize(RTCCUINTREG, 4);
|
---|
114 | # endif
|
---|
115 |
|
---|
116 | #endif
|
---|
117 |
|
---|
118 | AssertCompileSize(RTHCPHYS, 8);
|
---|
119 |
|
---|
120 |
|
---|
121 | /*
|
---|
122 | * Check basic guest context types.
|
---|
123 | */
|
---|
124 | #if GC_ARCH_BITS == 64
|
---|
125 |
|
---|
126 | AssertCompileSize(RTGCINT, 8);
|
---|
127 | AssertCompileSize(RTGCUINT, 8);
|
---|
128 | AssertCompileSize(RTGCINTPTR, 8);
|
---|
129 | AssertCompileSize(RTGCUINTPTR, 8);
|
---|
130 | /*AssertCompileSize(RTGCINTREG, 8);*/
|
---|
131 | AssertCompileSize(RTGCUINTREG, 8);
|
---|
132 |
|
---|
133 | # ifdef IN_RC
|
---|
134 | /*AssertCompileSize(RTCCINTREG, 8);*/
|
---|
135 | /* Hack alert: there is no such thing as a GC context when GC_ARCH_BITS == 64; it's still 32 bits */
|
---|
136 | AssertCompileSize(RTCCUINTREG, 4);
|
---|
137 | # endif
|
---|
138 |
|
---|
139 | #else
|
---|
140 |
|
---|
141 | AssertCompileSize(RTGCINT, 4);
|
---|
142 | AssertCompileSize(RTGCUINT, 4);
|
---|
143 | AssertCompileSize(RTGCINTPTR, 4);
|
---|
144 | AssertCompileSize(RTGCUINTPTR, 4);
|
---|
145 | /*AssertCompileSize(RTGCINTREG, 4);*/
|
---|
146 | AssertCompileSize(RTGCUINTREG, 4);
|
---|
147 |
|
---|
148 | # ifdef IN_RC
|
---|
149 | /*AssertCompileSize(RTCCINTREG, 4);*/
|
---|
150 | AssertCompileSize(RTCCUINTREG, 4);
|
---|
151 | # endif
|
---|
152 |
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | AssertCompileSize(RTGCPHYS64, 8);
|
---|
156 | AssertCompileSize(RTGCPHYS32, 4);
|
---|
157 | AssertCompileSize(RTGCPHYS, 8);
|
---|
158 |
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * Check basic current context types.
|
---|
162 | */
|
---|
163 | #if ARCH_BITS == 64
|
---|
164 |
|
---|
165 | AssertCompileSize(void *, 8);
|
---|
166 |
|
---|
167 | #else
|
---|
168 |
|
---|
169 | AssertCompileSize(void *, 4);
|
---|
170 |
|
---|
171 | #endif
|
---|