1164Seric /* 2*68839Seric * Copyright (c) 1995 Eric P. Allman 362532Sbostic * Copyright (c) 1988, 1993 462532Sbostic * The Regents of the University of California. All rights reserved. 533781Sbostic * 642830Sbostic * %sccs.include.redist.c% 733781Sbostic * 8*68839Seric * @(#)useful.h 8.4 (Berkeley) 04/21/95 933781Sbostic */ 10164Seric 1111723Seric # include <sys/types.h> 124148Seric 134148Seric /* support for bool type */ 1468701Seric typedef int bool; 15164Seric # define TRUE 1 16164Seric # define FALSE 0 17164Seric 18164Seric # ifndef NULL 19164Seric # define NULL 0 2056794Seric # endif /* NULL */ 212975Seric 224148Seric /* bit hacking */ 237113Seric # define bitset(bit, word) (((word) & (bit)) != 0) 244086Seric 2510120Seric /* some simple functions */ 2610120Seric # ifndef max 2710120Seric # define max(a, b) ((a) > (b) ? (a) : (b)) 2810120Seric # define min(a, b) ((a) < (b) ? (a) : (b)) 2958889Seric # endif 3010120Seric 315196Seric /* assertions */ 325196Seric # ifndef NASSERT 335196Seric # define ASSERT(expr, msg, parm)\ 345196Seric if (!(expr))\ 355196Seric {\ 365196Seric fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ 375196Seric fprintf(stderr, msg, parm);\ 385196Seric } 3956794Seric # else /* NASSERT */ 405196Seric # define ASSERT(expr, msg, parm) 4156794Seric # endif /* NASSERT */ 425196Seric 435196Seric /* sccs id's */ 445196Seric # ifndef lint 4564641Seric # ifdef __STDC__ 4664641Seric # define SCCSID(arg) static char SccsId[] = #arg; 4764641Seric # else 4864641Seric # define SCCSID(arg) static char SccsId[] = "arg"; 4964641Seric # endif 5058889Seric # else 5164641Seric # define SCCSID(arg) 5258889Seric # endif 53