bitv.h
1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* 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);