1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /* Bit vector functions */
|
---|
8 |
|
---|
9 | #ifndef CR_BITS_H
|
---|
10 | #define CR_BITS_H
|
---|
11 |
|
---|
12 |
|
---|
13 | #include "cr_compiler.h"
|
---|
14 |
|
---|
15 |
|
---|
16 | #define CR_MAX_CONTEXTS 512
|
---|
17 | #define CR_MAX_BITARRAY (CR_MAX_CONTEXTS / 32) /* 32 contexts per uint */
|
---|
18 |
|
---|
19 | #ifdef __cplusplus
|
---|
20 | extern "C" {
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | static INLINE void RESET( unsigned int *b, const unsigned int *d )
|
---|
24 | {
|
---|
25 | int j;
|
---|
26 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
27 | b[j] |= d[j];
|
---|
28 | }
|
---|
29 | static INLINE void DIRTY( unsigned int *b, const unsigned int *d )
|
---|
30 | {
|
---|
31 | int j;
|
---|
32 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
33 | b[j] = d[j];
|
---|
34 | }
|
---|
35 | static INLINE void FILLDIRTY( unsigned int *b )
|
---|
36 | {
|
---|
37 | int j;
|
---|
38 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
39 | b[j] = 0xffffffff;
|
---|
40 | }
|
---|
41 | static INLINE void CLEARDIRTY( unsigned int *b, const unsigned int *d )
|
---|
42 | {
|
---|
43 | int j;
|
---|
44 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
45 | b[j] &= d[j];
|
---|
46 | }
|
---|
47 |
|
---|
48 | /* As above, but complement the bits here instead of in the calling code */
|
---|
49 | static INLINE void CLEARDIRTY2( unsigned int *b, const unsigned int *d )
|
---|
50 | {
|
---|
51 | int j;
|
---|
52 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
53 | b[j] &= ~d[j];
|
---|
54 | }
|
---|
55 |
|
---|
56 | static INLINE int CHECKDIRTY( const unsigned int *b, const unsigned int *d )
|
---|
57 | {
|
---|
58 | int j;
|
---|
59 |
|
---|
60 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
61 | if (b[j] & d[j])
|
---|
62 | return 1;
|
---|
63 |
|
---|
64 | return 0;
|
---|
65 | }
|
---|
66 |
|
---|
67 | #ifdef __cplusplus
|
---|
68 | }
|
---|
69 | #endif
|
---|
70 |
|
---|
71 |
|
---|
72 | #endif /* CR_BITS_H */
|
---|