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