bitv.h 1.04 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */


	/*
	 *  bitv.h  -  Definitions for bit vector primitives
	 *
	 *	Jim Bennett
	 *	1994
	 */

typedef int *	BITVEC;

#define	BITS_IN_WORD		(8 * sizeof (int))
#define	BITS_TO_WORDS(n)	((((n)-1) / BITS_IN_WORD) + 1)
#define	BIT_TO_INDEX(n)		((n) / BITS_IN_WORD)
#define	INDEX_TO_BIT(n)		((n) * BITS_IN_WORD)

#define	bv_free(p)	free((void *)(p))

extern	BITVEC	bv_alloc (int nbits);
extern	void	bv_null (BITVEC bv, int nbits);
extern	void	setbit (BITVEC bv, int bitno);
extern	void	clrbit (BITVEC bv, int bitno);
extern	void	bv_union (BITVEC bv, BITVEC newbits, int nbits);
extern	void	bv_diff (BITVEC bv, BITVEC newbits, int nbits);
extern	void	bv_assign (BITVEC bv, BITVEC newbits, int nbits);
extern	int	bv_is_equal (BITVEC bv, BITVEC newbits, int nbits);
extern	int	bit_is_set (BITVEC bv, int bitno);
extern	int	bv_nxtbit (BITVEC bv, int bitno, int nbits);