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