aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Kistruck2006-12-13 14:45:49 +0000
committerRichard Kistruck2006-12-13 14:45:49 +0000
commit445b3e6f517aaa3b805847e35549bd96533f72b6 (patch)
tree4a391e7433f27adaed7fa6347155f0323b6a9b0a /mps/code
parentce9caabcf847a8a5ba96e551bba5e1098074bb27 (diff)
downloademacs-445b3e6f517aaa3b805847e35549bd96533f72b6.tar.gz
emacs-445b3e6f517aaa3b805847e35549bd96533f72b6.zip
Mps sort out baroque check macros (mainly config.h and check.h)
See job001248. Should be source-only change. Details: CheckNONE,SHALLOW,DEEP -->> CheckLevelMINIMAL,SHALLOW,DEEP [PROD_]CHECK_DEFAULT -->> [PROD_]CHECKLEVEL_INITIAL CHECK[_NONE] -->> AVER_AND_CHECK[_NONE] And add some comments. Copied from Perforce Change: 161210 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/check.h61
-rw-r--r--mps/code/config.h28
-rw-r--r--mps/code/mpm.c6
-rw-r--r--mps/code/splay.c4
-rw-r--r--mps/code/testlib.h2
5 files changed, 59 insertions, 42 deletions
diff --git a/mps/code/check.h b/mps/code/check.h
index 6fbc609a0cf..f5681e0bb71 100644
--- a/mps/code/check.h
+++ b/mps/code/check.h
@@ -32,9 +32,12 @@
32extern unsigned CheckLevel; 32extern unsigned CheckLevel;
33 33
34enum { 34enum {
35 CheckNONE = 0, 35 CheckLevelMINIMAL = 0, /* local sig check only */
36 CheckSHALLOW = 1, 36 CheckLevelSHALLOW = 1, /* local invariants, */
37 CheckDEEP = 2 37 /* and adjacent (up, down) sig checks */
38 CheckLevelDEEP = 2 /* local invariants, */
39 /* and adjacent up sig checks */
40 /* and recursive down full type checks */
38}; 41};
39 42
40 43
@@ -43,25 +46,25 @@ enum {
43 * AVER and AVERT are used to assert conditions in the code. 46 * AVER and AVERT are used to assert conditions in the code.
44 */ 47 */
45 48
46#if defined(CHECK_NONE) 49#if defined(AVER_AND_CHECK_NONE)
47 50
48#define AVER(cond) DISCARD(cond) 51#define AVER(cond) DISCARD(cond)
49#define AVERT(type, val) DISCARD(type ## Check(val)) 52#define AVERT(type, val) DISCARD(type ## Check(val))
50#define AVER_CRITICAL(cond) DISCARD(cond) 53#define AVER_CRITICAL(cond) DISCARD(cond)
51#define AVERT_CRITICAL(type, val) DISCARD(type ## Check(val)) 54#define AVERT_CRITICAL(type, val) DISCARD(type ## Check(val))
52 55
53#elif defined(CHECK) 56#elif defined(AVER_AND_CHECK)
54 57
55#define AVER(cond) ASSERT(cond, #cond) 58#define AVER(cond) ASSERT(cond, #cond)
56#define AVERT(type, val) ASSERT(type ## Check(val), \ 59#define AVERT(type, val) ASSERT(type ## Check(val), \
57 "TypeCheck " #type ": " #val) 60 "TypeCheck " #type ": " #val)
58#define AVER_CRITICAL(cond) \ 61#define AVER_CRITICAL(cond) \
59 BEGIN \ 62 BEGIN \
60 if (CheckLevel != CheckNONE) ASSERT(cond, #cond); \ 63 if (CheckLevel != CheckLevelMINIMAL) ASSERT(cond, #cond); \
61 END 64 END
62#define AVERT_CRITICAL(type, val) \ 65#define AVERT_CRITICAL(type, val) \
63 BEGIN \ 66 BEGIN \
64 if (CheckLevel != CheckNONE) \ 67 if (CheckLevel != CheckLevelMINIMAL) \
65 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \ 68 ASSERT(type ## Check(val), "TypeCheck " #type ": " #val); \
66 END 69 END
67 70
@@ -82,8 +85,9 @@ enum {
82 85
83 86
84/* NOTREACHED -- control should never reach this statement */ 87/* NOTREACHED -- control should never reach this statement */
88/* This is a sort of AVER; it is equivalent to AVER(FALSE). */
85 89
86#if defined(CHECK) 90#if defined(AVER_AND_CHECK)
87 91
88#define NOTREACHED \ 92#define NOTREACHED \
89 BEGIN \ 93 BEGIN \
@@ -101,12 +105,15 @@ enum {
101 * 105 *
102 * Must be thread safe. See <design/interface-c/#thread-safety> 106 * Must be thread safe. See <design/interface-c/#thread-safety>
103 * and <design/interface-c/#check.space>. 107 * and <design/interface-c/#check.space>.
108 *
109 * @@@@ This is a test, not a CHECK macro -- it does not assert.
110 * It should be renamed MATCHSIG. RHSK 2006-12-13.
104 */ 111 */
105 112
106#define CHECKT(type, val) ((val) != NULL && (val)->sig == type ## Sig) 113#define CHECKT(type, val) ((val) != NULL && (val)->sig == type ## Sig)
107 114
108 115
109#if defined(CHECK_NONE) 116#if defined(AVER_AND_CHECK_NONE)
110 117
111 118
112#define CHECKS(type, val) DISCARD(CHECKT(type, val)) 119#define CHECKS(type, val) DISCARD(CHECKT(type, val))
@@ -121,6 +128,7 @@ enum {
121 128
122 129
123/* CHECKS -- Check Signature */ 130/* CHECKS -- Check Signature */
131/* (if CheckLevel == CheckLevelMINIMAL, this is all we check) */
124 132
125#define CHECKS(type, val) ASSERT(CHECKT(type, val), \ 133#define CHECKS(type, val) ASSERT(CHECKT(type, val), \
126 "SigCheck " #type ": " #val) 134 "SigCheck " #type ": " #val)
@@ -134,11 +142,11 @@ enum {
134#define CHECKL(cond) \ 142#define CHECKL(cond) \
135 BEGIN \ 143 BEGIN \
136 switch(CheckLevel) { \ 144 switch(CheckLevel) { \
137 case CheckNONE: \ 145 case CheckLevelMINIMAL: \
138 NOOP; \ 146 NOOP; \
139 break; \ 147 break; \
140 case CheckSHALLOW: \ 148 case CheckLevelSHALLOW: \
141 case CheckDEEP: \ 149 case CheckLevelDEEP: \
142 ASSERT(cond, #cond); \ 150 ASSERT(cond, #cond); \
143 break; \ 151 break; \
144 } \ 152 } \
@@ -150,14 +158,14 @@ enum {
150#define CHECKD(type, val) \ 158#define CHECKD(type, val) \
151 BEGIN \ 159 BEGIN \
152 switch(CheckLevel) { \ 160 switch(CheckLevel) { \
153 case CheckNONE: \ 161 case CheckLevelMINIMAL: \
154 NOOP; \ 162 NOOP; \
155 break; \ 163 break; \
156 case CheckSHALLOW: \ 164 case CheckLevelSHALLOW: \
157 ASSERT(CHECKT(type, val), \ 165 ASSERT(CHECKT(type, val), \
158 "SigCheck " #type ": " #val); \ 166 "SigCheck " #type ": " #val); \
159 break; \ 167 break; \
160 case CheckDEEP: \ 168 case CheckLevelDEEP: \
161 ASSERT(type ## Check(val), \ 169 ASSERT(type ## Check(val), \
162 "TypeCheck " #type ": " #val); \ 170 "TypeCheck " #type ": " #val); \
163 break; \ 171 break; \
@@ -170,14 +178,14 @@ enum {
170#define CHECKD_NOSIG(type, val) \ 178#define CHECKD_NOSIG(type, val) \
171 BEGIN \ 179 BEGIN \
172 switch(CheckLevel) { \ 180 switch(CheckLevel) { \
173 case CheckNONE: \ 181 case CheckLevelMINIMAL: \
174 NOOP; \ 182 NOOP; \
175 break; \ 183 break; \
176 case CheckSHALLOW: \ 184 case CheckLevelSHALLOW: \
177 ASSERT((val) != NULL, \ 185 ASSERT((val) != NULL, \
178 "NullCheck " #type ": " #val); \ 186 "NullCheck " #type ": " #val); \
179 break; \ 187 break; \
180 case CheckDEEP: \ 188 case CheckLevelDEEP: \
181 ASSERT(type ## Check(val), \ 189 ASSERT(type ## Check(val), \
182 "TypeCheck " #type ": " #val); \ 190 "TypeCheck " #type ": " #val); \
183 break; \ 191 break; \
@@ -190,11 +198,11 @@ enum {
190#define CHECKU(type, val) \ 198#define CHECKU(type, val) \
191 BEGIN \ 199 BEGIN \
192 switch(CheckLevel) { \ 200 switch(CheckLevel) { \
193 case CheckNONE: \ 201 case CheckLevelMINIMAL: \
194 NOOP; \ 202 NOOP; \
195 break; \ 203 break; \
196 case CheckSHALLOW: \ 204 case CheckLevelSHALLOW: \
197 case CheckDEEP: \ 205 case CheckLevelDEEP: \
198 ASSERT(CHECKT(type, val), \ 206 ASSERT(CHECKT(type, val), \
199 "SigCheck " #type ": " #val); \ 207 "SigCheck " #type ": " #val); \
200 break; \ 208 break; \
@@ -207,11 +215,11 @@ enum {
207#define CHECKU_NOSIG(type, val) \ 215#define CHECKU_NOSIG(type, val) \
208 BEGIN \ 216 BEGIN \
209 switch(CheckLevel) { \ 217 switch(CheckLevel) { \
210 case CheckNONE: \ 218 case CheckLevelMINIMAL: \
211 NOOP; \ 219 NOOP; \
212 break; \ 220 break; \
213 case CheckSHALLOW: \ 221 case CheckLevelSHALLOW: \
214 case CheckDEEP: \ 222 case CheckLevelDEEP: \
215 ASSERT((val) != NULL, \ 223 ASSERT((val) != NULL, \
216 "NullCheck " #type ": " #val); \ 224 "NullCheck " #type ": " #val); \
217 break; \ 225 break; \
@@ -230,11 +238,16 @@ enum {
230 * in knowing that <code/mps.h> matches the MPM. See also 238 * in knowing that <code/mps.h> matches the MPM. See also
231 * mail.richard.1996-08-07.09-49. [This paragraph is intended to 239 * mail.richard.1996-08-07.09-49. [This paragraph is intended to
232 * satisfy rule.impl.trick.] 240 * satisfy rule.impl.trick.]
241 *
242 * @@@@ These are tests, not CHECK macros -- they do not assert.
243 * They should be renamed MATCHTYPE etc. RHSK 2006-12-13.
233 */ 244 */
234 245
246/* compile-time check */
235#define CHECKLVALUE(lv1, lv2) \ 247#define CHECKLVALUE(lv1, lv2) \
236 ((void)sizeof((lv1) = (lv2)), (void)sizeof((lv2) = (lv1)), TRUE) 248 ((void)sizeof((lv1) = (lv2)), (void)sizeof((lv2) = (lv1)), TRUE)
237 249
250/* aims to test whether t1 and t2 are assignment-compatible */
238#define CHECKTYPE(t1, t2) \ 251#define CHECKTYPE(t1, t2) \
239 (sizeof(t1) == sizeof(t2) && \ 252 (sizeof(t1) == sizeof(t2) && \
240 CHECKLVALUE(*((t1 *)0), *((t2 *)0))) 253 CHECKLVALUE(*((t1 *)0), *((t2 *)0)))
diff --git a/mps/code/config.h b/mps/code/config.h
index 971b2da8fe0..64f83b66c75 100644
--- a/mps/code/config.h
+++ b/mps/code/config.h
@@ -31,7 +31,7 @@
31 31
32#if defined(CONFIG_VAR_HI) || defined(CONFIG_VAR_HE) /* Hot varieties */ 32#if defined(CONFIG_VAR_HI) || defined(CONFIG_VAR_HE) /* Hot varieties */
33#define CONFIG_DEBUG 33#define CONFIG_DEBUG
34#define CHECK_DEFAULT CheckNONE 34#define CHECKLEVEL_INITIAL CheckLevelMINIMAL
35#elif defined(CONFIG_VAR_CI) || defined(CONFIG_VAR_CE) /* Cool varieties */ 35#elif defined(CONFIG_VAR_CI) || defined(CONFIG_VAR_CE) /* Cool varieties */
36#define CONFIG_DEBUG 36#define CONFIG_DEBUG
37#define CONFIG_ASSERT 37#define CONFIG_ASSERT
@@ -42,21 +42,23 @@
42#elif defined(CONFIG_VAR_II) /* Ice, Internal; variety.ii */ 42#elif defined(CONFIG_VAR_II) /* Ice, Internal; variety.ii */
43#define CONFIG_LOG 43#define CONFIG_LOG
44#define CONFIG_DEBUG 44#define CONFIG_DEBUG
45#define CHECK_DEFAULT CheckNONE 45#define CHECKLEVEL_INITIAL CheckLevelMINIMAL
46/* also CONFIG_VAR_WI and CONFIG_VAR_WE, for which all switches are off. */ 46/* also CONFIG_VAR_WI and CONFIG_VAR_WE, for which all switches are off. */
47#endif 47#endif
48 48
49 49
50#if defined(CONFIG_ASSERT) 50#if defined(CONFIG_ASSERT)
51#define CHECK 51/* AVER, AVERT, NOTREACHED, CHECKx */
52#define AVER_AND_CHECK
52#define MPS_ASSERT_STRING "asserted" 53#define MPS_ASSERT_STRING "asserted"
53#else 54#else
54#define CHECK_NONE 55#define AVER_AND_CHECK_NONE
55#define MPS_ASSERT_STRING "nonasserted" 56#define MPS_ASSERT_STRING "nonasserted"
56#endif 57#endif
57 58
58 59
59#if defined(CONFIG_LOG) 60#if defined(CONFIG_LOG)
61/* TELEMETRY = LOG = EVENTs */
60#define EVENT 62#define EVENT
61#define MPS_LOG_STRING "logging" 63#define MPS_LOG_STRING "logging"
62#else 64#else
@@ -66,6 +68,8 @@
66 68
67 69
68#if defined(CONFIG_DEBUG) 70#if defined(CONFIG_DEBUG)
71/* DEBUG = DIAGNOSTICS = STATISTICs = METERs */
72/* WARNING: this changes the size and fields of MPS structs */
69#define DIAGNOSTICS 73#define DIAGNOSTICS
70#define MPS_DEBUG_STRING "debug" 74#define MPS_DEBUG_STRING "debug"
71#else 75#else
@@ -125,7 +129,7 @@
125 * are suddenly unused, etc. We aren't interested in these 129 * are suddenly unused, etc. We aren't interested in these
126 */ 130 */
127 131
128#if defined(CHECK_NONE) 132#if defined(AVER_AND_CHECK_NONE)
129 133
130/* "unreferenced formal parameter" */ 134/* "unreferenced formal parameter" */
131#pragma warning(disable: 4100) 135#pragma warning(disable: 4100)
@@ -133,7 +137,7 @@
133/* "unreferenced local function has been removed" */ 137/* "unreferenced local function has been removed" */
134#pragma warning(disable: 4505) 138#pragma warning(disable: 4505)
135 139
136#endif /* CHECK_NONE */ 140#endif /* AVER_AND_CHECK_NONE */
137 141
138#endif /* MPS_BUILD_MV */ 142#endif /* MPS_BUILD_MV */
139 143
@@ -267,7 +271,7 @@
267#define THREAD_SINGLE 271#define THREAD_SINGLE
268#define PROTECTION_NONE 272#define PROTECTION_NONE
269#define DONGLE_NONE 273#define DONGLE_NONE
270#define PROD_CHECK_DEFAULT CheckNONE /* CheckSHALLOW is too slow for SW */ 274#define PROD_CHECKLEVEL_INITIAL CheckLevelMINIMAL /* CheckLevelSHALLOW is too slow for SW */
271 275
272#elif defined(CONFIG_PROD_DYLAN) 276#elif defined(CONFIG_PROD_DYLAN)
273#define MPS_PROD_STRING "dylan" 277#define MPS_PROD_STRING "dylan"
@@ -276,7 +280,7 @@
276#define THREAD_MULTI 280#define THREAD_MULTI
277#define PROTECTION 281#define PROTECTION
278#define DONGLE_NONE 282#define DONGLE_NONE
279#define PROD_CHECK_DEFAULT CheckSHALLOW 283#define PROD_CHECKLEVEL_INITIAL CheckLevelSHALLOW
280 284
281#elif defined(CONFIG_PROD_MPS) 285#elif defined(CONFIG_PROD_MPS)
282#define MPS_PROD_STRING "mps" 286#define MPS_PROD_STRING "mps"
@@ -285,7 +289,7 @@
285#define THREAD_MULTI 289#define THREAD_MULTI
286#define PROTECTION 290#define PROTECTION
287#define DONGLE_NONE 291#define DONGLE_NONE
288#define PROD_CHECK_DEFAULT CheckSHALLOW 292#define PROD_CHECKLEVEL_INITIAL CheckLevelSHALLOW
289 293
290#else 294#else
291#error "No target product configured." 295#error "No target product configured."
@@ -299,11 +303,11 @@
299 */ 303 */
300#define ARENA_SIZE ((Size)1<<30) 304#define ARENA_SIZE ((Size)1<<30)
301 305
302/* if CHECK_DEFAULT hasn't been defined already (e.g. by a variety, or 306/* if CHECKLEVEL_INITIAL hasn't been defined already (e.g. by a variety, or
303 * in a makefile), take the value from the product. */ 307 * in a makefile), take the value from the product. */
304 308
305#ifndef CHECK_DEFAULT 309#ifndef CHECKLEVEL_INITIAL
306#define CHECK_DEFAULT PROD_CHECK_DEFAULT 310#define CHECKLEVEL_INITIAL PROD_CHECKLEVEL_INITIAL
307#endif 311#endif
308 312
309 313
diff --git a/mps/code/mpm.c b/mps/code/mpm.c
index 247cbd05a56..3ce1aefe7ce 100644
--- a/mps/code/mpm.c
+++ b/mps/code/mpm.c
@@ -18,7 +18,7 @@
18SRCID(mpm, "$Id$"); 18SRCID(mpm, "$Id$");
19 19
20 20
21#if defined(CHECK) 21#if defined(AVER_AND_CHECK)
22 22
23 23
24/* CheckLevel -- Control check level 24/* CheckLevel -- Control check level
@@ -26,7 +26,7 @@ SRCID(mpm, "$Id$");
26 * This controls the behaviour of Check methods (see impl.h.check). 26 * This controls the behaviour of Check methods (see impl.h.check).
27 */ 27 */
28 28
29unsigned CheckLevel = CHECK_DEFAULT; 29unsigned CheckLevel = CHECKLEVEL_INITIAL;
30 30
31 31
32/* MPMCheck -- test MPM assumptions */ 32/* MPMCheck -- test MPM assumptions */
@@ -123,7 +123,7 @@ Bool AlignCheck(Align align)
123} 123}
124 124
125 125
126#endif /* defined(CHECK) */ 126#endif /* defined(AVER_AND_CHECK) */
127 127
128 128
129/* WordIsAligned -- test whether a word is aligned */ 129/* WordIsAligned -- test whether a word is aligned */
diff --git a/mps/code/splay.c b/mps/code/splay.c
index 388353b0849..7979af342c4 100644
--- a/mps/code/splay.c
+++ b/mps/code/splay.c
@@ -763,7 +763,7 @@ static Res SplayNodeDescribe(SplayNode node, mps_lib_FILE *stream,
763 SplayNodeDescribeMethod nodeDescribe) { 763 SplayNodeDescribeMethod nodeDescribe) {
764 Res res; 764 Res res;
765 765
766#if defined(CHECK) 766#if defined(AVER_AND_CHECK)
767 if (!SplayNodeCheck(node)) return ResFAIL; 767 if (!SplayNodeCheck(node)) return ResFAIL;
768 /* stream and nodeDescribe checked by SplayTreeDescribe */ 768 /* stream and nodeDescribe checked by SplayTreeDescribe */
769#endif 769#endif
@@ -1005,7 +1005,7 @@ Res SplayTreeDescribe(SplayTree tree, mps_lib_FILE *stream,
1005 SplayNodeDescribeMethod nodeDescribe) { 1005 SplayNodeDescribeMethod nodeDescribe) {
1006 Res res; 1006 Res res;
1007 1007
1008#if defined(CHECK) 1008#if defined(AVER_AND_CHECK)
1009 if (!SplayTreeCheck(tree)) return ResFAIL; 1009 if (!SplayTreeCheck(tree)) return ResFAIL;
1010 if (stream == NULL) return ResFAIL; 1010 if (stream == NULL) return ResFAIL;
1011 if (!FUNCHECK(nodeDescribe)) return ResFAIL; 1011 if (!FUNCHECK(nodeDescribe)) return ResFAIL;
diff --git a/mps/code/testlib.h b/mps/code/testlib.h
index 415aaaa8ded..94161adb58d 100644
--- a/mps/code/testlib.h
+++ b/mps/code/testlib.h
@@ -61,7 +61,7 @@
61 * are suddenly unused, etc. We aren't interested in these. 61 * are suddenly unused, etc. We aren't interested in these.
62 */ 62 */
63 63
64#if defined(CHECK_NONE) 64#if defined(AVER_AND_CHECK_NONE)
65 65
66/* "unreferenced formal parameter" */ 66/* "unreferenced formal parameter" */
67#pragma warning(disable: 4100) 67#pragma warning(disable: 4100)