]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* ;-*-C-*-; |
2 | ** Copyright (c) Massachusetts Institute of Technology 1994, 1995. | |
3 | ** All Rights Reserved. | |
4 | ** Unpublished rights reserved under the copyright laws of | |
5 | ** the United States. | |
6 | ** | |
7 | ** THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | |
8 | ** OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | |
9 | ** | |
10 | ** This code is distributed freely and may be used freely under the | |
11 | ** following conditions: | |
12 | ** | |
13 | ** 1. This notice may not be removed or altered. | |
14 | ** | |
15 | ** 2. This code may not be re-distributed or modified | |
16 | ** without permission from MIT (contact | |
17 | ** lclint-request@larch.lcs.mit.edu.) | |
18 | ** | |
19 | ** Modification and re-distribution are encouraged, | |
20 | ** but we want to keep track of changes and | |
21 | ** distribution sites. | |
22 | */ | |
23 | ||
24 | # ifndef LCLINTMACROS_H | |
25 | # define LCLINTMACROS_H | |
26 | ||
27 | ||
28 | /* | |
29 | ** This file contains notfunction macros (hence, the .nf extension to | |
30 | ** prevent it being skipped when +neverinclude is used.) | |
31 | */ | |
32 | ||
33 | #ifndef PARAMS | |
34 | #ifdef __STDC | |
35 | /*@notfunction@*/ | |
36 | #define PARAMS(P) P | |
37 | #else | |
38 | /*@notfunction@*/ | |
39 | #define PARAMS(P) () | |
40 | #endif | |
41 | #endif /* !PARAMS */ | |
42 | ||
43 | /*@notfunction@*/ | |
44 | # define BADEXIT \ | |
45 | /*@notreached@*/ do { llassertprint(FALSE, ("Reached dead code!")); \ | |
46 | exit(EXIT_FAILURE); } while (FALSE) | |
47 | ||
48 | /*@notfunction@*/ | |
49 | # define BADBRANCH \ | |
50 | /*@notreached@*/ BADBRANCHCONT | |
51 | ||
52 | /*@notfunction@*/ | |
53 | # define BADBRANCHCONT \ | |
54 | do { llassertprint (FALSE, ("Bad branch taken!")); } while (FALSE) | |
55 | ||
56 | /*@notfunction@*/ | |
57 | # define BADDEFAULT \ | |
58 | default: llassertprint (FALSE, ("Unexpected default case reached!")); \ | |
59 | exit (EXIT_FAILURE); | |
60 | ||
61 | /*@-namechecks@*/ | |
62 | /*@notfunction@*/ | |
63 | # define llassertprint(tst,p) \ | |
64 | do { \ | |
65 | if (!(tst)) { \ | |
66 | llbug (message("%q:%d: llassert failed: " #tst ": %q", \ | |
67 | cstring_makeLiteral (__FILE__), __LINE__,\ | |
68 | /*@-mustfree@*/ message p) /*@=mustfree@*/ ); \ | |
69 | }} while (FALSE) | |
70 | ||
71 | /*@notfunction@*/ | |
72 | # define llassertprintret(tst,p,r) \ | |
73 | do { if (!(tst)) \ | |
74 | { llbug (message("%q:%d: %q", cstring_makeLiteral (__FILE__), __LINE__, message p)); \ | |
75 | /*@-unreachable@*/ return (r); /*@=unreachable@*/ \ | |
76 | } } while (FALSE) | |
77 | ||
78 | /*@notfunction@*/ | |
79 | # define abst_typedef typedef /*@abstract@*/ | |
80 | ||
81 | /*@notfunction@*/ | |
82 | # define immut_typedef typedef /*@abstract@*/ /*@immutable@*/ | |
83 | ||
84 | /*@=namechecks@*/ | |
85 | ||
86 | /* | |
87 | ** SunOS4 can't handle bit fields correctly. | |
88 | */ | |
89 | ||
90 | # ifdef SYSSunOS | |
91 | /*@notfunction@*/ | |
92 | # define BOOLBITS | |
93 | # else | |
94 | /*@notfunction@*/ | |
95 | # define BOOLBITS : 1 | |
96 | # endif | |
97 | ||
98 | /* | |
99 | ** some stupid proprocessors replace the s in %s...had | |
100 | ** to change s to arg. | |
101 | */ | |
102 | ||
103 | /*@notfunction@*/ | |
104 | # define NOALIAS(s,t) (/*@ignore@*/ (s == NULL) || (s != t) /*@end@*/) | |
105 | ||
28bf4b0b | 106 | /*@i343434*/ /*fix this before release verion*/ |
107 | /* get rid of @-formatconst@ */ | |
108 | ||
885824d3 | 109 | /*@notfunction@*/ |
110 | # define TPRINTF(arg) \ | |
28bf4b0b | 111 | do { /*@-mustfree@*/ /*@-null@*/ /*@-formatconst@*/ (void) fflush (stderr); (void) fflush (stdout); \ |
885824d3 | 112 | printf ("%s:%d [%s]: >> ", __FILE__, __LINE__, cstring_toCharsSafe (fileloc_unparse(g_currentloc))); \ |
28bf4b0b | 113 | (void)printf arg; printf("\n"); /*@=formatconst@*/ /*@=mustfree@*/ /*@=null@*/ (void) fflush (stdout); \ |
885824d3 | 114 | } while (FALSE) |
115 | ||
ef2aa32a | 116 | |
885824d3 | 117 | # if DEBUGPRINT |
118 | /*@notfunction@*/ | |
119 | # define DPRINTF(s) /*@access cstring@*/ TPRINTF(s) /*@noaccess cstring@*/ | |
120 | # else | |
121 | /*@notfunction@*/ | |
122 | # define DPRINTF(s) | |
123 | # endif | |
124 | ||
125 | /*@notfunction@*/ | |
126 | # define INTCOMPARERETURN(x,y) \ | |
127 | do { if ((x) > (y)) { return 1; } \ | |
128 | else { if ((x) < (y)) { return -1; }}} while (FALSE); | |
129 | ||
130 | /*@notfunction@*/ | |
131 | # define COMPARERETURN(z) \ | |
132 | do { if (z != 0) { return z; } } while (FALSE); | |
133 | ||
134 | # else | |
135 | # error "Multiple include" | |
136 | # endif | |
137 | ||
138 |