Line | Count | Source |
1 | | // This file was extracted from the TCG Published |
2 | | // Trusted Platform Module Library |
3 | | // Part 4: Supporting Routines |
4 | | // Family "2.0" |
5 | | // Level 00 Revision 01.16 |
6 | | // October 30, 2014 |
7 | | |
8 | | #include "InternalRoutines.h" |
9 | | // |
10 | | // |
11 | | // Functions |
12 | | // |
13 | | // BitIsSet() |
14 | | // |
15 | | // This function is used to check the setting of a bit in an array of bits. |
16 | | // |
17 | | // Return Value Meaning |
18 | | // |
19 | | // TRUE bit is set |
20 | | // FALSE bit is not set |
21 | | // |
22 | | BOOL |
23 | | BitIsSet( |
24 | | unsigned int bitNum, // IN: number of the bit in 'bArray' |
25 | | BYTE *bArray, // IN: array containing the bit |
26 | | unsigned int arraySize // IN: size in bytes of 'bArray' |
27 | | ) |
28 | 153 | { |
29 | 153 | pAssert(arraySize > (bitNum >> 3)); |
30 | 153 | return((bArray[bitNum >> 3] & (1 << (bitNum & 7))) != 0); |
31 | 153 | } |
32 | | // |
33 | | // |
34 | | // BitSet() |
35 | | // |
36 | | // This function will set the indicated bit in bArray. |
37 | | // |
38 | | void |
39 | | BitSet( |
40 | | unsigned int bitNum, // IN: number of the bit in 'bArray' |
41 | | BYTE *bArray, // IN: array containing the bit |
42 | | unsigned int arraySize // IN: size in bytes of 'bArray' |
43 | | ) |
44 | 6.83k | { |
45 | 6.83k | pAssert(arraySize > bitNum/8); |
46 | 6.83k | bArray[bitNum >> 3] |= (1 << (bitNum & 7)); |
47 | 6.83k | } |
48 | | // |
49 | | // |
50 | | // BitClear() |
51 | | // |
52 | | // This function will clear the indicated bit in bArray. |
53 | | // |
54 | | void |
55 | | BitClear( |
56 | | unsigned int bitNum, // IN: number of the bit in 'bArray'. |
57 | | BYTE *bArray, // IN: array containing the bit |
58 | | unsigned int arraySize // IN: size in bytes of 'bArray' |
59 | | ) |
60 | 77 | { |
61 | 77 | pAssert(arraySize > bitNum/8); |
62 | 77 | bArray[bitNum >> 3] &= ~(1 << (bitNum & 7)); |
63 | 77 | } |