1164Seric /* 262532Sbostic * Copyright (c) 1988, 1993 362532Sbostic * The Regents of the University of California. All rights reserved. 433781Sbostic * 542830Sbostic * %sccs.include.redist.c% 633781Sbostic * 7*64641Seric * @(#)useful.h 8.2 (Berkeley) 09/24/93 833781Sbostic */ 9164Seric 1011723Seric # include <sys/types.h> 114148Seric 124148Seric /* support for bool type */ 134148Seric typedef char bool; 14164Seric # define TRUE 1 15164Seric # define FALSE 0 16164Seric 17164Seric # ifndef NULL 18164Seric # define NULL 0 1956794Seric # endif /* NULL */ 202975Seric 214148Seric /* bit hacking */ 227113Seric # define bitset(bit, word) (((word) & (bit)) != 0) 234086Seric 2410120Seric /* some simple functions */ 2510120Seric # ifndef max 2610120Seric # define max(a, b) ((a) > (b) ? (a) : (b)) 2710120Seric # define min(a, b) ((a) < (b) ? (a) : (b)) 2858889Seric # endif 2910120Seric 305196Seric /* assertions */ 315196Seric # ifndef NASSERT 325196Seric # define ASSERT(expr, msg, parm)\ 335196Seric if (!(expr))\ 345196Seric {\ 355196Seric fprintf(stderr, "assertion botch: %s:%d: ", __FILE__, __LINE__);\ 365196Seric fprintf(stderr, msg, parm);\ 375196Seric } 3856794Seric # else /* NASSERT */ 395196Seric # define ASSERT(expr, msg, parm) 4056794Seric # endif /* NASSERT */ 415196Seric 425196Seric /* sccs id's */ 435196Seric # ifndef lint 44*64641Seric # ifdef __STDC__ 45*64641Seric # define SCCSID(arg) static char SccsId[] = #arg; 46*64641Seric # else 47*64641Seric # define SCCSID(arg) static char SccsId[] = "arg"; 48*64641Seric # endif 4958889Seric # else 50*64641Seric # define SCCSID(arg) 5158889Seric # endif 52