|
1 |
| -/********************************************************************** |
2 |
| -
|
3 |
| - F I L E I N F O R M A T I O N |
4 |
| -
|
5 |
| -***********************************************************************/ |
6 |
| -/* |
7 |
| - Author: Ryan Rozanski |
8 |
| - Created: 1/21/17 |
9 |
| - Edited: 1/21/17 |
10 |
| -*/ |
| 1 | +/****************************************************************************** |
| 2 | + * FILE: bits.h * |
| 3 | + * AUTHOR: Ryan Rozanski * |
| 4 | + * CREATED: 1/21/17 * |
| 5 | + * EDITED: 4/25/17 * |
| 6 | + * INFO: A library for bit diddling with pointers. * |
| 7 | + * * |
| 8 | + ******************************************************************************/ |
11 | 9 |
|
12 | 10 | #ifndef BIT_DIDDLING_DEFS
|
13 | 11 | #define BIT_DIDDLING_DEFS
|
14 | 12 |
|
15 |
| -/********************************************************************** |
| 13 | +/****************************************************************************** |
| 14 | + * * |
| 15 | + * F U N C T I O N P R O T O T Y P E S * |
| 16 | + * * |
| 17 | + ******************************************************************************/ |
16 | 18 |
|
17 |
| - F U N C T I O N P R O T O T Y P E S |
18 |
| -
|
19 |
| -***********************************************************************/ |
| 19 | +/****************************************************************************** |
| 20 | + * * |
| 21 | + * PURPOSE: To set a specific bit in an arbitrary pointer. * |
| 22 | + * * |
| 23 | + * ARGUMENT DESCRIPTION * |
| 24 | + * -------- ----------- * |
| 25 | + * ptr the pointer to modify * |
| 26 | + * bit the specific bit to set * |
| 27 | + * * |
| 28 | + * RETURNS: N/A * |
| 29 | + * * |
| 30 | + ******************************************************************************/ |
20 | 31 | void setBit(void **ptr, int bit);
|
| 32 | + |
| 33 | +/****************************************************************************** |
| 34 | + * * |
| 35 | + * PURPOSE: To clear a specific bit in an arbitrary pointer. * |
| 36 | + * * |
| 37 | + * ARGUMENT DESCRIPTION * |
| 38 | + * -------- ----------- * |
| 39 | + * ptr the pointer to modify * |
| 40 | + * bit the specific bit to clear * |
| 41 | + * * |
| 42 | + * RETURNS: N/A * |
| 43 | + * * |
| 44 | + ******************************************************************************/ |
21 | 45 | void clrBit(void **ptr, int bit);
|
| 46 | + |
| 47 | +/****************************************************************************** |
| 48 | + * * |
| 49 | + * PURPOSE: To flip a specific bit in an arbitrary pointer. * |
| 50 | + * * |
| 51 | + * ARGUMENT DESCRIPTION * |
| 52 | + * -------- ----------- * |
| 53 | + * ptr the pointer to modify * |
| 54 | + * bit the specific bit to flip * |
| 55 | + * * |
| 56 | + * RETURNS: N/A * |
| 57 | + * * |
| 58 | + ******************************************************************************/ |
22 | 59 | void flpBit(void **ptr, int bit);
|
| 60 | + |
| 61 | +/****************************************************************************** |
| 62 | + * * |
| 63 | + * PURPOSE: To determine if a specific bit is set in an arbitrary pointer. * |
| 64 | + * * |
| 65 | + * ARGUMENT DESCRIPTION * |
| 66 | + * -------- ----------- * |
| 67 | + * ptr the pointer to modify * |
| 68 | + * bit the specific bit in question * |
| 69 | + * * |
| 70 | + * RETURNS: 1 if the specified bit is set, 0 otherwise. * |
| 71 | + * * |
| 72 | + ******************************************************************************/ |
23 | 73 | int getBit(void **ptr, int bit);
|
| 74 | + |
| 75 | +/****************************************************************************** |
| 76 | + * * |
| 77 | + * PURPOSE: To display an integer in its binary representation. * |
| 78 | + * * |
| 79 | + * ARGUMENT DESCRIPTION * |
| 80 | + * -------- ----------- * |
| 81 | + * n the integer to display in binary * |
| 82 | + * * |
| 83 | + * RETURNS: N/A * |
| 84 | + * * |
| 85 | + ******************************************************************************/ |
24 | 86 | void printBin(unsigned int n);
|
25 | 87 |
|
26 | 88 | #endif
|
0 commit comments