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