bitfields operations on bitfields of arbitrary length More...
bitfields operations on bitfields of arbitrary length
Definition in file bitfield.h.
 Include dependency graph for bitfield.h:
 This graph shows which files directly or indirectly include this file:Go to the source code of this file.
| #define | BITFIELD(NAME, SIZE) uint8_t NAME[((SIZE) + 7) / 8] | 
| Declare a bitfield of a given size.  More... | |
| static void | bf_set (uint8_t field[], size_t idx) | 
| Set the bit to 1.  More... | |
| static void | bf_set_atomic (uint8_t field[], size_t idx) | 
| Atomically set the bit to 1.  More... | |
| static void | bf_unset (uint8_t field[], size_t idx) | 
| Clear the bit.  More... | |
| static void | bf_unset_atomic (uint8_t field[], size_t idx) | 
| Atomically clear the bit.  More... | |
| static void | bf_toggle (uint8_t field[], size_t idx) | 
| Toggle the bit.  More... | |
| static void | bf_toggle_atomic (uint8_t field[], size_t idx) | 
| Atomically toggle the bit.  More... | |
| static bool | bf_isset (const uint8_t field[], size_t idx) | 
| Check if the bet is set.  More... | |
| static void | bf_or (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Perform a bitwise OR operation on two bitfields out = a | b  More... | |
| static void | bf_or_atomic (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Atomically perform a bitwise OR operation on two bitfields out = a | b  More... | |
| static void | bf_and (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Perform a bitwise AND operation on two bitfields out = a & b  More... | |
| static void | bf_and_atomic (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Atomically perform a bitwise AND operation on two bitfields out = a & b  More... | |
| static void | bf_xor (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Perform a bitwise XOR operation on two bitfields out = a ^ b  More... | |
| static void | bf_xor_atomic (uint8_t out[], const uint8_t a[], const uint8_t b[], size_t len) | 
Atomically perform a bitwise XOR operation on two bitfields out = a ^ b  More... | |
| static void | bf_inv (uint8_t out[], const uint8_t a[], size_t len) | 
Perform a bitwise NOT operation on a bitfield out = ~a  More... | |
| static void | bf_inv_atomic (uint8_t out[], const uint8_t a[], size_t len) | 
Atomically perform a bitwise NOT operation on a bitfield out = ~a  More... | |
| int | bf_get_unset (uint8_t field[], size_t len) | 
| Atomically get the number of an unset bit and set it.  More... | |
| int | bf_find_first_set (const uint8_t field[], size_t size) | 
| Get the index of the first set bit in the field.  More... | |
| int | bf_find_first_unset (const uint8_t field[], size_t size) | 
| Get the index of the zero bit in the field.  More... | |
| void | bf_set_all (uint8_t field[], size_t size) | 
| Set all bits in the bitfield to 1.  More... | |
| static void | bf_set_all_atomic (uint8_t field[], size_t size) | 
| Atomically set all bits in the bitfield to 1.  More... | |
| void | bf_clear_all (uint8_t field[], size_t size) | 
| Clear all bits in the bitfield to 0.  More... | |
| static void | bf_clear_all_atomic (uint8_t field[], size_t size) | 
| Atomically clear all bits in the bitfield to 0.  More... | |
| unsigned | bf_popcnt (const uint8_t field[], size_t size) | 
| Count set bits in the bitfield.  More... | |
| #define BITFIELD | ( | NAME, | |
| SIZE | |||
| ) | uint8_t NAME[((SIZE) + 7) / 8] | 
Declare a bitfield of a given size.
Definition at line 47 of file bitfield.h.
      
  | 
  inlinestatic | 
Perform a bitwise AND operation on two bitfields out = a & b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 190 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically perform a bitwise AND operation on two bitfields out = a & b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 212 of file bitfield.h.
| void bf_clear_all | ( | uint8_t | field[], | 
| size_t | size | ||
| ) | 
Clear all bits in the bitfield to 0.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
      
  | 
  inlinestatic | 
Atomically clear all bits in the bitfield to 0.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
Definition at line 375 of file bitfield.h.
| int bf_find_first_set | ( | const uint8_t | field[], | 
| size_t | size | ||
| ) | 
Get the index of the first set bit in the field.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
| int bf_find_first_unset | ( | const uint8_t | field[], | 
| size_t | size | ||
| ) | 
Get the index of the zero bit in the field.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
| int bf_get_unset | ( | uint8_t | field[], | 
| size_t | len | ||
| ) | 
Atomically get the number of an unset bit and set it.
This function can be used to record e.g., empty entries in an array.
| [in,out] | field | The bitfield | 
| [in] | len | The number of bits in the bitfield to consider | 
      
  | 
  inlinestatic | 
Perform a bitwise NOT operation on a bitfield out = ~a 
a and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The bitfield to invert | 
| [in] | len | The number of bits in the bitfield | 
Definition at line 277 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically perform a bitwise NOT operation on a bitfield out = ~a 
a and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The bitfield to invert | 
| [in] | len | The number of bits in the bitfield | 
Definition at line 298 of file bitfield.h.
      
  | 
  inlinestatic | 
Check if the bet is set.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to check | 
Definition at line 127 of file bitfield.h.
      
  | 
  inlinestatic | 
Perform a bitwise OR operation on two bitfields out = a | b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 146 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically perform a bitwise OR operation on two bitfields out = a | b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 168 of file bitfield.h.
| unsigned bf_popcnt | ( | const uint8_t | field[], | 
| size_t | size | ||
| ) | 
Count set bits in the bitfield.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
      
  | 
  inlinestatic | 
Set the bit to 1.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to set | 
Definition at line 55 of file bitfield.h.
| void bf_set_all | ( | uint8_t | field[], | 
| size_t | size | ||
| ) | 
Set all bits in the bitfield to 1.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
      
  | 
  inlinestatic | 
Atomically set all bits in the bitfield to 1.
| [in] | field | The bitfield | 
| [in] | size | The number of bits in the bitfield | 
Definition at line 354 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically set the bit to 1.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to set | 
Definition at line 66 of file bitfield.h.
      
  | 
  inlinestatic | 
Toggle the bit.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to toggle | 
Definition at line 103 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically toggle the bit.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to toggle | 
Definition at line 114 of file bitfield.h.
      
  | 
  inlinestatic | 
Clear the bit.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to clear | 
Definition at line 79 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically clear the bit.
| [in,out] | field | The bitfield | 
| [in] | idx | The number of the bit to clear | 
Definition at line 90 of file bitfield.h.
      
  | 
  inlinestatic | 
Perform a bitwise XOR operation on two bitfields out = a ^ b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 234 of file bitfield.h.
      
  | 
  inlinestatic | 
Atomically perform a bitwise XOR operation on two bitfields out = a ^ b 
a, b and out must be at least len bits| [out] | out | The resulting bitfield | 
| [in] | a | The first bitfield | 
| [in] | b | The second bitfield | 
| [in] | len | The number of bits in the bitfields | 
Definition at line 256 of file bitfield.h.