]> andersk Git - splint.git/blob - src/Headers/lclintMacros.nf
Initial revision
[splint.git] / src / Headers / lclintMacros.nf
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
106 /*@notfunction@*/
107 # define TPRINTF(arg) \
108   do { /*@-mustfree@*/ /*@-null@*/ (void) fflush (stderr); (void) fflush (stdout); \
109         printf ("%s:%d [%s]: >> ", __FILE__, __LINE__, cstring_toCharsSafe (fileloc_unparse(g_currentloc))); \
110         (void)printf arg; printf("\n"); /*@=mustfree@*/ /*@=null@*/ (void) fflush (stdout); \
111         } while (FALSE)
112
113 # if DEBUGPRINT
114 /*@notfunction@*/
115 # define DPRINTF(s) /*@access cstring@*/ TPRINTF(s) /*@noaccess cstring@*/
116 # else
117 /*@notfunction@*/
118 # define DPRINTF(s)   
119 # endif
120
121 /*@notfunction@*/
122 # define INTCOMPARERETURN(x,y) \
123    do { if ((x) > (y)) { return 1; } \
124         else { if ((x) < (y)) { return -1; }}} while (FALSE);
125
126 /*@notfunction@*/
127 # define COMPARERETURN(z) \
128    do { if (z != 0) { return z; } } while (FALSE);
129
130 # else
131 # error "Multiple include"
132 # endif
133
134
This page took 0.047144 seconds and 5 git commands to generate.