xref: /petsc/include/petscbt.h (revision 6d84be18fbb99ba69be7b8bdde5411a66955b7ea)
1 /* $Id: bitarray.h,v 1.4 1996/02/01 15:43:21 balay Exp balay $ */
2 
3 /*
4       BT_LOOKUP - Expexts a charecter array -'array' as input, and
5       treats it as  an array of bits. It Checks if a given bit location
6       ( specified by 'index') is marked, and later marks that location.
7 
8       Input:
9       array  - an array of char. Initially all bits are to be set to zero
10                by using PetscMemzero().
11       index  - specifies the index of the required bit in the bit array.
12 
13       Output:
14       return val - 0 if the bit is not found,
15                  - nonzero if found.
16 
17       Usage :
18       BT_LOOKUP(char * array,  int index) ;
19 
20       Summary:
21           The bit operations are euivalent to:
22               1: retval = array[idx];
23               2: array[index] = 1;
24               3: return retval;
25 */
26 #if !defined(BITSPERBYTE)
27 #define BITSPERBYTE 8
28 #endif
29 
30 static char _mask, _BT_c;
31 static int  _BT_idx;
32 #define BT_LOOKUP( array,  index) (_BT_idx         = index/BITSPERBYTE, \
33                                    _BT_c           = array[_BT_idx], \
34                                    _BT_idx         = index/BITSPERBYTE, \
35                                    _mask           = (char)1 << (index%BITSPERBYTE), \
36                                    array[_BT_idx]  = _BT_c|_mask, \
37                                    _BT_c & _mask )
38 
39 
40