1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)useful.h 6.5 (Berkeley) 04/18/93 8 */ 9 10 # include <sys/types.h> 11 12 /* support for ANSI prototypes (or not, as the case may be) */ 13 #ifndef __P 14 # if defined(__STDC__) && defined(_FORGIVING_CC_) 15 # define __P(protos) protos 16 # else 17 # define __P(protos) () 18 # endif 19 #endif 20 21 /* support for bool type */ 22 typedef char bool; 23 # define TRUE 1 24 # define FALSE 0 25 26 # ifndef NULL 27 # define NULL 0 28 # endif /* NULL */ 29 30 /* bit hacking */ 31 # define bitset(bit, word) (((word) & (bit)) != 0) 32 33 /* some simple functions */ 34 # ifndef max 35 # define max(a, b) ((a) > (b) ? (a) : (b)) 36 # define min(a, b) ((a) < (b) ? (a) : (b)) 37 # endif 38 39 /* assertions */ 40 # ifndef NASSERT 41 # define ASSERT(expr, msg, parm)\ 42 if (!(expr))\ 43 {\ 44 fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ 45 fprintf(stderr, msg, parm);\ 46 } 47 # else /* NASSERT */ 48 # define ASSERT(expr, msg, parm) 49 # endif /* NASSERT */ 50 51 /* sccs id's */ 52 # ifndef lint 53 # define SCCSID(arg) static char SccsId[] = "arg"; 54 # else 55 # define SCCSID(arg) 56 # endif 57