|
Modules | |
| Atomic Bit Operations | |
Defines | |
| #define | bit_mask(ws, nr) (1 << ((nr) & ((ws) - 1))) |
| Generate a ws-bit mask with only bit nr set. | |
| #define | bit_word(ws, nr) ((nr) / (ws)) |
| Return the offset of the ws-bit word containing bit nr in a multi-word bitfield. | |
| #define | set_bit(nr, bitmap) |
| Set bit nr in bitmap. | |
| #define | clear_bit(nr, bitmap) |
| Clear bit nr in bitmap. | |
| #define | toggle_bit(nr, bitmap) |
| Toggle bit nr in bitmap. | |
| #define | test_bit(nr, bitmap) priv_test_bit_ws(nr, bitmap, 8 * sizeof(*(bitmap))) |
| Test bit nr in bitmap. | |
| #define | bit_word_reverse(word) compiler_brev(word) |
| Reverse the order of the bits in word. | |
| #define | bit_word_find_first_one_bit(word) compiler_ctz(word) |
| Find the first bit set in word, counting from the LSB. | |
| #define | bit_word_find_last_one_bit(word) (31 - compiler_clz(word)) |
| Find the last bit set in word, counting from the LSB. | |
| #define | bit_word_find_first_zero_bit(word) bit_word_find_first_one_bit(~word) |
| Find the first bit cleared in word, counting from the LSB. | |
| #define | bit_word_find_last_zero_bit(word) bit_word_find_last_one_bit(~word) |
| Find the last bit cleared in word, counting from the LSB. | |
Typedefs | |
| typedef uint8_t | bit_word_t |
| Optimum type for bit operations. | |
Functions | |
| static unsigned int | bit_array_find_first_one_bit (const bit_word_t *bitmap, unsigned int len) |
| Find the first bit set in bitmap, counting from the LSB of each word. | |
These bit operations are helper functions for accessing individual bits in a bitmaps. Most operations are defined for arbitrary-length bitmaps, but there may be architecture-specific constraints associated with e.g. the atomic operations.
| #define bit_mask | ( | ws, | |||
| nr | ) | (1 << ((nr) & ((ws) - 1))) |
| #define bit_word | ( | ws, | |||
| nr | ) | ((nr) / (ws)) |
| #define bit_word_find_first_one_bit | ( | word | ) | compiler_ctz(word) |
Find the first bit set in word, counting from the LSB.
Definition at line 180 of file bitops.h.
Referenced by bit_array_find_first_one_bit().
| #define bit_word_find_first_zero_bit | ( | word | ) | bit_word_find_first_one_bit(~word) |
| #define bit_word_find_last_one_bit | ( | word | ) | (31 - compiler_clz(word)) |
| #define bit_word_find_last_zero_bit | ( | word | ) | bit_word_find_last_one_bit(~word) |
| #define bit_word_reverse | ( | word | ) | compiler_brev(word) |
| #define clear_bit | ( | nr, | |||
| bitmap | ) |
do { \ unsigned int priv_bit_ws = 8 * sizeof(*(bitmap)); \ unsigned int priv_bit_nr = (nr); \ (bitmap)[bit_word(priv_bit_ws, priv_bit_nr)] \ &= ~bit_mask(priv_bit_ws, priv_bit_nr); \ } while (0)
Clear bit nr in bitmap.
bitmap may be of arbitrary length and type. The caller must ensure that nr is within the bounds of the bitmap.
Definition at line 112 of file bitops.h.
Referenced by atomic_clear_bit(), atomic_test_and_clear_bit(), and softirq_poll().
| #define set_bit | ( | nr, | |||
| bitmap | ) |
do { \ unsigned int priv_bit_ws = 8 * sizeof(*(bitmap)); \ unsigned int priv_bit_nr = (nr); \ (bitmap)[bit_word(priv_bit_ws, priv_bit_nr)] \ |= bit_mask(priv_bit_ws, priv_bit_nr); \ } while (0)
Set bit nr in bitmap.
bitmap may be of arbitrary length and type. The caller must ensure that nr is within the bounds of the bitmap.
Definition at line 98 of file bitops.h.
Referenced by atomic_set_bit(), atomic_test_and_set_bit(), and dataflash_detect().
| #define test_bit | ( | nr, | |||
| bitmap | ) | priv_test_bit_ws(nr, bitmap, 8 * sizeof(*(bitmap))) |
Test bit nr in bitmap.
bitmap may be of arbitrary length and type. The caller must ensure that nr is within the bounds of the bitmap.
| true | if the bit is set | |
| false | if the bit is clear |
Definition at line 167 of file bitops.h.
Referenced by atomic_test_and_clear_bit(), atomic_test_and_set_bit(), dataflash_detect(), spi_poll(), and spi_polled_is_buffer_op().
| #define toggle_bit | ( | nr, | |||
| bitmap | ) |
do { \ unsigned int priv_bit_ws = 8 * sizeof(*(bitmap)); \ unsigned int priv_bit_nr = (nr); \ (bitmap)[bit_word(priv_bit_ws, priv_bit_nr)] \ ^= bit_mask(priv_bit_ws, priv_bit_nr); \ } while (0)
Toggle bit nr in bitmap.
bitmap may be of arbitrary length and type. The caller must ensure that nr is within the bounds of the bitmap.
Definition at line 126 of file bitops.h.
Referenced by atomic_toggle_bit().
| typedef uint8_t bit_word_t |
| static unsigned int bit_array_find_first_one_bit | ( | const bit_word_t * | bitmap, | |
| unsigned int | len | |||
| ) | [inline, static] |
Find the first bit set in bitmap, counting from the LSB of each word.
| bitmap | An array of bit words making up a contiguous bitmap | |
| len | The length of bitmap in bits |
Definition at line 214 of file bitops.h.
References bit_word_find_first_one_bit, and div_ceil.
Referenced by softirq_poll().
1.6.3