# define BITSPERBYTE 32

/* In the code that accompanies this, "BYTE" should be replaced with "UINT" */
/* This code and the declarations for "nm" and "pm" in the front of "bv.c"  */
/* depend upon the size of a UINT, or "unsigned int".  Byte order is not
   important. */

/* ITOY(#bits) converts an allocation request of #bits into an
   allocation request for #bytes; that is, ITOY(n) returns enough
   bytes to hold n bits.
   YTOI(#bytes) tells how many bits are contained in #bytes.
*/
# define ITOY(x) (((x) + BITSPERBYTE - 1) >> 5)
# define YTOI(x) ((x) << 5)

/* BYTE(x) tells which byte contains the x'th bit */
/* BIT(x) tells which bit in the BYTE(x)'th byte corresponds to bit x */
/* these are used in a somewhat machine-independent way to set and
   clear bits in bit vectors (ordering of bits within the vector is not
   specified--see bv.c or macros below for details).
*/
# define BYTE(x) ((x) >> 5)
# define BIT(x) ((x) & 0x1f)

typedef unsigned int * BV;

extern BV bv_new(/* #bits */);
extern BV bv_copy();
extern BV bv_and();
extern VOID bv_free();
extern UINT bv_hash();
extern int  bv_eq();

extern BV bv_assign();
extern BV bv_andto();
extern BV bv_orto();
extern int bv_intersects();

extern VOID bv_init(/* # bits in a vector */);
extern UINT number_bits_set();

extern unsigned int pm[32];
extern unsigned int nm[32];

#define bv_in(s,i) ((s)[BYTE(i)]&pm[BIT(i)])
#define bv_ins(s,i) ((s)[BYTE(i)]|=pm[BIT(i)])
