8.2. bits — Bitwise operations¶
Source code: src/collections/bits.h
Test code: tst/collections/bits/main.c
Functions
-
static uint32_t
bits_mask_32(int width)¶ Create a bit mask of given width.
- Return
- The bit mask.
- Parameters
width: Width in bits.
-
static uint32_t
bits_insert_32(uint32_t dst, int position, int size, uint32_t src)¶ Insert given number of bits into another value at given position.
For example,
bits_insert_32(0xffffffff, 4, 8, 0x12)would return0xfffff12f.- Return
- The resulting value of the insertion.
- Parameters
dst: Value to insert into.position: Bit position, counted from LSB, indstwhere to insertsrc, 0-31.size: Number of bits to insert. 0-31.src: Value to insert into dst.
-
uint8_t
bits_reverse_8(uint8_t value)¶ Reverse the order of given 8 bits.
- Return
- Reversed bits.
-
uint16_t
bits_reverse_16(uint16_t value)¶ Reverse the order of given 16 bits.
- Return
- Reversed bits.
-
uint32_t
bits_reverse_32(uint32_t value)¶ Reverse the order of given 32 bits.
- Return
- Reversed bits.