Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / src / Headers / splintMacros.nf
blobfa1ca0ce30619a044a593b145cb3a5af79cddf07
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:
13 **     1. This notice may not be removed or altered.
15 **     2. This code may not be re-distributed or modified
16 **        without permission from MIT (contact 
17 **        lclint-request@larch.lcs.mit.edu.)  
19 **        Modification and re-distribution are encouraged,
20 **        but we want to keep track of changes and
21 **        distribution sites.
24 # ifndef LCLINTMACROS_H
25 # define LCLINTMACROS_H
29 ** This file contains notfunction macros (hence, the .nf extension to
30 ** prevent it being skipped when +neverinclude is used.)
33 /*@notfunction@*/
34 # define BADEXIT \
35  /*@notreached@*/ do { llassertprint(FALSE, ("Reached dead code!")); \
36                        exit(EXIT_FAILURE); } while (FALSE) 
38 /*@notfunction@*/
39 # define BADBRANCH \
40   /*@notreached@*/ BADBRANCHCONT
42 /*@notfunction@*/
43 # define BADBRANCHNULL \
44   /*@notreached@*/ BADBRANCHCONT ; /*@notreached@*/ /*@-mustfree@*/ /*@-globstate@*/ return NULL; /*@=mustfree@*/ /*@=globstate@*/
46 /*@notfunction@*/
47 # define BADBRANCHCONT \
48   do { llassertprint (FALSE, ("Bad branch taken!")); } while (FALSE) 
50 /*@notfunction@*/
51 # define BADBRANCHRET(r) \
52   /*@notreached@*/ BADBRANCHCONT ; /*@notreached@*/ /*@-mustfree@*/ /*@-globstate@*/ return (r); /*@=mustfree@*/ /*@=globstate@*/
54 /*@notfunction@*/
55 # define BADDEFAULT \
56   default: llassertprint (FALSE, ("Unexpected default case reached!")); \
57            exit (EXIT_FAILURE);
59 /*@-namechecks@*/
60 /*@notfunction@*/
61 # define llassertprint(tst,p) \
62    do { \
63      if (!(tst)) { \
64       llbug (message("%q:%d: llassert failed: " #tst ": %q", \
65                      cstring_makeLiteral (__FILE__), __LINE__,\
66                      /*@-mustfree@*/ message p) /*@=mustfree@*/ ); \
67      }} while (FALSE)
69 /*@notfunction@*/
70 # define abst_typedef typedef /*@abstract@*/ 
72 /*@notfunction@*/
73 # define immut_typedef typedef /*@abstract@*/ /*@immutable@*/
75 /*@=namechecks@*/
78 ** SunOS4 can't handle bit fields correctly.
81 # ifdef SYSSunOS
82 /*@notfunction@*/
83 # define BOOLBITS
84 # else 
85 /*@notfunction@*/
86 # define BOOLBITS : 1
87 # endif
90 ** some stupid proprocessors replace the s in %s...had
91 ** to change s to arg.
94 /*@notfunction@*/
95 # define NOALIAS(s,t) (/*@ignore@*/ (s == NULL) || (s != t) /*@end@*/)
97 /* evans 2002-02-24: got rid of -formatconst */
99 /*@notfunction@*/
100 # define TPRINTF(arg) \
101   do { /*@-mustfree@*/ /*@-null@*/ (void) fflush (stderr); (void) fflush (stdout); \
102         printf ("%s:%d [%s]: >> ", __FILE__, __LINE__, cstring_toCharsSafe (fileloc_unparse(g_currentloc))); \
103         (void)printf arg; printf("\n"); /*@=mustfree@*/ /*@=null@*/ (void) fflush (stdout); \
104         } while (FALSE)
107 ** DPRINTF does nothing, just a marker to save TPRINTF's
110 /*@notfunction@*/
111 # define DPRINTF(s)
113 /*@notfunction@*/
114 # define INTCOMPARERETURN(x,y) \
115    do { if ((x) > (y)) { return 1; } \
116         else { if ((x) < (y)) { return -1; }}} while (FALSE);
118 /*@notfunction@*/
119 # define COMPARERETURN(z) \
120    do { if (z != 0) { return z; } } while (FALSE);
122 # else
123 # error "Multiple include"
124 # endif