|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Arrays of bits in plain memory, without atomicity or locking. More...
Files | |
| file | bitmap.h |
| Header file for the bitmap API. | |
Macros | |
| #define | SYS_BITMAP_SIZE(num_bits) |
Number of bytes of a bitmap with num_bits bits. | |
| #define | SYS_BITMAP_DEFINE(name, num_bits) |
| Define a bitmap. | |
| #define | SYS_BITMAP_FOR_EACH_SET_BIT(bitmap, num_bits, bit) |
| Iterate over the set bits of a bitmap, in ascending order. | |
Functions | |
| static bool | sys_bitmap_test_bit (const uint8_t *bitmap, size_t bit) |
| Test a bit. | |
| static void | sys_bitmap_set_bit (uint8_t *bitmap, size_t bit) |
| Set a bit. | |
| static void | sys_bitmap_clear_bit (uint8_t *bitmap, size_t bit) |
| Clear a bit. | |
| static void | sys_bitmap_set_bit_to (uint8_t *bitmap, size_t bit, bool val) |
| Set a bit to a given value. | |
| static bool | sys_bitmap_test_and_set_bit (uint8_t *bitmap, size_t bit) |
| Set a bit and return its old value. | |
| static bool | sys_bitmap_test_and_clear_bit (uint8_t *bitmap, size_t bit) |
| Clear a bit and return its old value. | |
| size_t | sys_bitmap_find_next_set (const uint8_t *bitmap, size_t num_bits, size_t start) |
| Find the next set bit. | |
| size_t | sys_bitmap_find_next_clear (const uint8_t *bitmap, size_t num_bits, size_t start) |
| Find the next cleared bit. | |
| size_t | sys_bitmap_count_set (const uint8_t *bitmap, size_t num_bits) |
| Count the set bits. | |
Arrays of bits in plain memory, without atomicity or locking.
Bit n of a bitmap is bit n % 8 of byte n / 8, where bit 0 of a byte is its least significant bit. This is the layout of little-endian bit masks in protocol messages, so these functions also work on such byte arrays. They take no lock: the caller serializes access. The single-bit functions do not check bounds; the caller passes them only bit numbers below the size of the bitmap.
| #define SYS_BITMAP_DEFINE | ( | name, | |
| num_bits ) |
#include <zephyr/sys/bitmap.h>
Define a bitmap.
Defines an array of bytes that holds at least num_bits bits. At file scope the bits start cleared; inside a function they start uninitialized. A num_bits of 0 defines a zero-length array, a GNU C extension.
| name | Name of the bitmap. |
| num_bits | Number of bits. |
| #define SYS_BITMAP_FOR_EACH_SET_BIT | ( | bitmap, | |
| num_bits, | |||
| bit ) |
#include <zephyr/sys/bitmap.h>
Iterate over the set bits of a bitmap, in ascending order.
| bitmap | Bitmap. |
| num_bits | Number of bits in the bitmap. |
| bit | Variable of type size_t that holds the number of the current bit. |
| #define SYS_BITMAP_SIZE | ( | num_bits | ) |
#include <zephyr/sys/bitmap.h>
Number of bytes of a bitmap with num_bits bits.
| num_bits | Number of bits. |
|
inlinestatic |
#include <zephyr/sys/bitmap.h>
Clear a bit.
| bitmap | Bitmap. |
| bit | Bit number, starting from 0. |
| size_t sys_bitmap_count_set | ( | const uint8_t * | bitmap, |
| size_t | num_bits ) |
#include <zephyr/sys/bitmap.h>
Count the set bits.
| bitmap | Bitmap. |
| num_bits | Number of bits in the bitmap. |
num_bits. | size_t sys_bitmap_find_next_clear | ( | const uint8_t * | bitmap, |
| size_t | num_bits, | ||
| size_t | start ) |
#include <zephyr/sys/bitmap.h>
Find the next cleared bit.
| bitmap | Bitmap. |
| num_bits | Number of bits in the bitmap. |
| start | Bit number to start the search from. |
start, or num_bits if there is none. | size_t sys_bitmap_find_next_set | ( | const uint8_t * | bitmap, |
| size_t | num_bits, | ||
| size_t | start ) |
#include <zephyr/sys/bitmap.h>
Find the next set bit.
| bitmap | Bitmap. |
| num_bits | Number of bits in the bitmap. |
| start | Bit number to start the search from. |
start, or num_bits if there is none.
|
inlinestatic |
#include <zephyr/sys/bitmap.h>
Set a bit to a given value.
| bitmap | Bitmap. |
| bit | Bit number, starting from 0. |
| val | true to set the bit, false to clear it. |
#include <zephyr/sys/bitmap.h>
Clear a bit and return its old value.
| bitmap | Bitmap. |
| bit | Bit number, starting from 0. |
#include <zephyr/sys/bitmap.h>
Set a bit and return its old value.
| bitmap | Bitmap. |
| bit | Bit number, starting from 0. |