• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  **	Filename:    bitvec.h
3  **	Purpose:     Routines for manipulating bit vectors
4  **	Author:      Dan Johnson
5  **	History:     Wed Mar  7 17:52:45 1990, DSJ, Created.
6  **
7  **	(c) Copyright Hewlett-Packard Company, 1988.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  ******************************************************************************/
18 #ifndef   BITVEC_H
19 #define   BITVEC_H
20 
21 #include "host.h"
22 
23 /**----------------------------------------------------------------------------
24           Include Files and Type Defines
25 ----------------------------------------------------------------------------**/
26 #define BITSINLONG      32       /*no of bits in a long */
27 typedef uinT32 *BIT_VECTOR;
28 
29 /**----------------------------------------------------------------------------
30           Public Function Prototypes
31 ----------------------------------------------------------------------------**/
32 #define zero_all_bits(array,length) \
33 {\
34 	register int			index;						/*temporary index*/\
35 \
36 for (index=0;index<length;index++)\
37 	array[index]=0;										/*zero all bits*/\
38 }
39 
40 #define set_all_bits(array,length) \
41 {\
42 	register int			index;						/*temporary index*/\
43 \
44 for (index=0;index<length;index++)\
45 	array[index]= ~0;									/*set all bits*/\
46 }
47 
48 #define copy_all_bits(source,dest,length) \
49 {\
50 	register int			index;						/*temporary index*/\
51 \
52 for (index=0;index<length;index++)\
53 	dest[index]=source[index];							/*copy all bits*/\
54 }
55 
56 #define SET_BIT(array,bit) (array[bit/BITSINLONG]|=1<<(bit&(BITSINLONG-1)))
57 
58 #define reset_bit(array,bit) (array[bit/BITSINLONG]&=~(1<<(bit&(BITSINLONG-1))))
59 
60 #define test_bit(array,bit) (array[bit/BITSINLONG] & (1<<(bit&(BITSINLONG-1))))
61 
62 #define WordsInVectorOfSize(NumBits) \
63 (((NumBits) + BITSINLONG - 1) / BITSINLONG)
64 
65 /*--------------------------------------------------------------------------
66         Public Function Prototypes
67 --------------------------------------------------------------------------*/
68 BIT_VECTOR ExpandBitVector(BIT_VECTOR Vector, int NewNumBits);
69 
70 void FreeBitVector(BIT_VECTOR BitVector);
71 
72 int hamming_distance(uinT32* array1, uinT32* array2, int length);
73 
74 BIT_VECTOR NewBitVector(int NumBits);
75 /*
76 #if defined(__STDC__) || defined(__cplusplus)
77 # define _ARGS(s) s
78 #else
79 # define _ARGS(s) ()
80 #endif*/
81 
82 /* bitvec.c
83 BIT_VECTOR ExpandBitVector
84   _ARGS((BIT_VECTOR Vector,
85   int NewNumBits));
86 
87 void FreeBitVector
88   _ARGS((BIT_VECTOR BitVector));
89 
90 int hamming_distance
91   _ARGS((unsigned long *array1,
92   unsigned long *array2,
93   int length));
94 
95 BIT_VECTOR NewBitVector
96   _ARGS((int NumBits));
97 
98 #undef _ARGS
99 */
100 #endif
101