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.6 (Berkeley) 05/17/93 8 */ 9 10 # include <sys/types.h> 11 12 /* support for bool type */ 13 typedef char 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 # define SCCSID(arg) static char SccsId[] = "arg"; 45 # else 46 # define SCCSID(arg) 47 # endif 48