blob: 779a66ae598e65bbc99548aa644b36cf2a1e0ada (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
|
/*-------------------------------------------------------------------------
*
* bit.c--
* Standard bit array code.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/lib/Attic/bit.c,v 1.3 1996/11/06 06:47:53 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
/*
* utils/memutils.h contains declarations of the functions in this file
*/
#include "postgres.h"
#include "utils/bit.h"
#include "utils/memutils.h"
void
BitArraySetBit(BitArray bitArray, BitIndex bitIndex)
{
bitArray[bitIndex/BitsPerByte]
|= (1 << (BitsPerByte - (bitIndex % BitsPerByte) - 1));
return;
}
void
BitArrayClearBit(BitArray bitArray, BitIndex bitIndex)
{
bitArray[bitIndex/BitsPerByte]
&= ~(1 << (BitsPerByte - (bitIndex % BitsPerByte) - 1));
return;
}
bool
BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex)
{
return( (bool) (((bitArray[bitIndex / BitsPerByte] &
(1 << (BitsPerByte - (bitIndex % BitsPerByte)
- 1)
)
) != 0 ) ? 1 : 0) );
}
|