rte_bitops.h(3)
โจ rte_bitops.h โจ
okay bestie, welcome to the little header that runs the whole bit-twiddling universe ๐
this is rte_bitops.h, and it lives in the Library Functions Manual. it's from rte_bitops.h(3), and honestly? she's iconic.
๐ธ NAME ๐ธ
rte_bitops.h โ no notes, that's the whole name, she needs no introduction ๐
๐ SYNOPSIS ๐
first things first, you gotta include the girlies:
#include <stdint.h>
#include <rte_compat.h>
#include <rte_debug.h>
#include <rte_stdatomic.h>
then you've got two whole squadrons: Macros and Functions. buckle up ๐ฆ
๐ซ Macros ๐ซ
#define RTE_BIT64(nr)
#define RTE_BIT32(nr)
#define RTE_SHIFT_VAL32(val, nr)
#define RTE_SHIFT_VAL64(val, nr)
#define RTE_GENMASK32(high, low)
#define RTE_GENMASK64(high, low)
#define RTE_FIELD_GET32(mask, reg)
#define RTE_FIELD_GET64(mask, reg)
#define rte_bit_test(addr, nr)
#define rte_bit_set(addr, nr)
#define rte_bit_clear(addr, nr)
#define rte_bit_assign(addr, nr, value)
#define rte_bit_flip(addr, nr)
#define rte_bit_atomic_test(addr, nr, memory_order)
#define rte_bit_atomic_set(addr, nr, memory_order)
#define rte_bit_atomic_clear(addr, nr, memory_order)
#define rte_bit_atomic_assign(addr, nr, value, memory_order)
#define rte_bit_atomic_flip(addr, nr, memory_order)
#define rte_bit_atomic_test_and_set(addr, nr, memory_order)
#define rte_bit_atomic_test_and_clear(addr, nr, memory_order)
#define rte_bit_atomic_test_and_assign(addr, nr, value, memory_order)
#define RTE_IS_POWER_OF_2(n)
๐ซ Functions ๐ซ
static uint32_t rte_bit_relaxed_get32 (unsigned int nr, volatile
uint32_t *addr)
static void rte_bit_relaxed_set32 (unsigned int nr, volatile uint32_t
*addr)
static void rte_bit_relaxed_clear32 (unsigned int nr, volatile uint32_t
*addr)
static uint32_t rte_bit_relaxed_test_and_set32 (unsigned int nr,
volatile uint32_t *addr)
static uint32_t rte_bit_relaxed_test_and_clear32 (unsigned int nr,
volatile uint32_t *addr)
static uint64_t rte_bit_relaxed_get64 (unsigned int nr, volatile
uint64_t *addr)
static void rte_bit_relaxed_set64 (unsigned int nr, volatile uint64_t
*addr)
static void rte_bit_relaxed_clear64 (unsigned int nr, volatile uint64_t
*addr)
static uint64_t rte_bit_relaxed_test_and_set64 (unsigned int nr,
volatile uint64_t *addr)
static uint64_t rte_bit_relaxed_test_and_clear64 (unsigned int nr,
volatile uint64_t *addr)
static unsigned int rte_clz32 (uint32_t v)
static unsigned int rte_clz64 (uint64_t v)
static unsigned int rte_ctz32 (uint32_t v)
static unsigned int rte_ctz64 (uint64_t v)
static unsigned int rte_popcount32 (uint32_t v)
static unsigned int rte_popcount64 (uint64_t v)
static __rte_experimental unsigned int rte_ffs32 (uint32_t v)
static __rte_experimental unsigned int rte_ffs64 (uint64_t v)
static uint32_t rte_combine32ms1b (uint32_t x)
static uint64_t rte_combine64ms1b (uint64_t v)
static uint32_t rte_bsf32 (uint32_t v)
static int rte_bsf32_safe (uint32_t v, uint32_t *pos)
static uint32_t rte_bsf64 (uint64_t v)
static int rte_bsf64_safe (uint64_t v, uint32_t *pos)
static uint32_t rte_fls_u32 (uint32_t x)
static uint32_t rte_fls_u64 (uint64_t x)
static int rte_is_power_of_2 (uint32_t n)
static uint32_t rte_align32pow2 (uint32_t x)
static uint32_t rte_align32prevpow2 (uint32_t x)
static uint64_t rte_align64pow2 (uint64_t v)
static uint64_t rte_align64prevpow2 (uint64_t v)
static uint32_t rte_log2_u32 (uint32_t v)
static uint32_t rte_log2_u64 (uint64_t v)
๐ง Detailed Description ๐ง
๐ Bit Operations ๐
so like, what even is this file?? it's your go-to for low-level, single-word arithmetic and bit-level shenanigans โ the little things like counting bits or flipping individual bits on and off, one at a time, no drama. ๐ฅ
Definition in file rte_bitops.h.
๐ Macro Definition Documentation ๐
๐ #define RTE_BIT64( nr) ๐
Value:
(UINT64_C(1) << (nr))
grabs you the uint64_t value with a specified bit set, bestie. one bit, one girl, iconic. โจ
Parameters
nrโ the bit number, and she's gotta be in range0to63. no rogue numbers allowed.
Definition at line 36 of file rte_bitops.h.
๐ #define RTE_BIT32( nr) ๐
Value:
(UINT32_C(1) << (nr))
same vibe, but for uint32_t โ get that value for a specified bit set ๐
Parameters
nrโ the bit number, range0to31. stay in your lane (affectionately).
Definition at line 44 of file rte_bitops.h.
๐ #define RTE_SHIFT_VAL32( val, nr) ๐
Value:
((uint32_t)(val) << (nr))
shifting time!! get the uint32_t shifted value, slay. ๐ซ
Parameters
valโ the value to be shifted.nrโ the shift number, range0to (32 - width ofval). yes, that's the actual rule, don't fight it.
Definition at line 54 of file rte_bitops.h.
๐ #define RTE_SHIFT_VAL64( val, nr) ๐
Value:
((uint64_t)(val) << (nr))
the 64-bit version of the shift moment, she's bigger and she knows it ๐
Parameters
valโ the value to be shifted.nrโ the shift number, range0to (64 - width ofval).
Definition at line 64 of file rte_bitops.h.
๐ #define RTE_GENMASK32( high, low) ๐
Value:
(((~UINT32_C(0)) << (low)) & (~UINT32_C(0) >> (31u - (high))))
generate a contiguous 32-bit mask, starting at bit position low and ending at position high. it's giving "make me a fence and make it cute." ๐ง๐
Parameters
highโ high bit position.lowโ low bit position.
Definition at line 75 of file rte_bitops.h.
๐ #define RTE_GENMASK64( high, low) ๐
Value:
(((~UINT64_C(0)) << (low)) & (~UINT64_C(0) >> (63u - (high))))
generate a contiguous 64-bit mask, from bit position low up to position high. the 64-bit glow-up of the mask above, no cap. ๐
Parameters
highโ high bit position.lowโ low bit position.
Definition at line 87 of file rte_bitops.h.
๐ #define RTE_FIELD_GET32( mask, reg) ๐
Value:
((typeof(mask))(((reg) & (mask)) >> rte_ctz32(mask)))
extract a 32-bit field element, bestie. reach in, grab your lil field, pull it out. ๐
Parameters
maskโ shifted mask.regโ value of entire bitfield.
Definition at line 98 of file rte_bitops.h.
๐ #define RTE_FIELD_GET64( mask, reg) ๐
Value:
((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask)))
extract a 64-bit field element. same energy, double the bits. โจ
Parameters
maskโ shifted mask.regโ value of entire bitfield.
Definition at line 109 of file rte_bitops.h.
๐ #define rte_bit_test( addr, nr) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_test32, \
const uint32_t *: __rte_bit_test32, \
volatile uint32_t *: __rte_bit_v_test32, \
const volatile uint32_t *: __rte_bit_v_test32, \
uint64_t *: __rte_bit_test64, \
const uint64_t *: __rte_bit_test64, \
volatile uint64_t *: __rte_bit_v_test64, \
const volatile uint64_t *: __rte_bit_v_test64) \
(addr, nr)
Warning โ EXPERIMENTAL: this API may change without prior notice. okay so she's experimental, meaning she might switch up on us, no cap. proceed accordingly ๐
test bit in word. it's a generic selection macro that tests the value of a bit inside a 32-bit or 64-bit word. which exact operation you get depends on the type of the addr parameter โ she reads the vibes and picks. ๐ฆ
this macro does not give any guarantees in regards to memory ordering or atomicity โ just so we're clear, bestie.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.
Definition at line 130 of file rte_bitops.h.
๐ #define rte_bit_set( addr, nr) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_set32, \
volatile uint32_t *: __rte_bit_v_set32, \
uint64_t *: __rte_bit_set64, \
volatile uint64_t *: __rte_bit_v_set64) \
(addr, nr)
Warning โ EXPERIMENTAL: this API may change without prior notice. yeah she's experimental too ๐
set bit in word. generic selection macro that sets a bit in a 32-bit or 64-bit word, and the operation type depends on the type of addr.
this macro does not give any guarantees in regards to memory ordering or atomicity. periodt.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.
Definition at line 160 of file rte_bitops.h.
๐ #define rte_bit_clear( addr, nr) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_clear32, \
volatile uint32_t *: __rte_bit_v_clear32, \
uint64_t *: __rte_bit_clear64, \
volatile uint64_t *: __rte_bit_v_clear64) \
(addr, nr)
Warning โ EXPERIMENTAL: this API may change without prior notice. (she's in her experimental era, respect it)
clear bit in word. generic selection macro that clears a bit in a 32-bit or 64-bit word, and again the operation type depends on the type of addr.
this macro does not give any guarantees in regards to memory ordering or atomicity.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.
Definition at line 186 of file rte_bitops.h.
๐ #define rte_bit_assign( addr, nr, value) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_assign32, \
volatile uint32_t *: __rte_bit_v_assign32, \
uint64_t *: __rte_bit_assign64, \
volatile uint64_t *: __rte_bit_v_assign64) \
(addr, nr, value)
Warning โ EXPERIMENTAL: this API may change without prior notice. ๐ (experimental, you've been warned)
assign a value to a bit in word. generic selection macro that assigns a value to a bit in a 32-bit or 64-bit word, depending on the type of addr.
this macro does not give any guarantees in regards to memory ordering or atomicity.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.valueโ the new value of the bit โtruefor'1', orfalsefor'0'.
Definition at line 213 of file rte_bitops.h.
๐ #define rte_bit_flip( addr, nr) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_flip32, \
volatile uint32_t *: __rte_bit_v_flip32, \
uint64_t *: __rte_bit_flip64, \
volatile uint64_t *: __rte_bit_v_flip64) \
(addr, nr)
Warning โ EXPERIMENTAL: this API may change without prior notice. โจ
flip a bit in word. generic selection macro that changes the value of a bit to '0' if it was '1', or to '1' if it was '0', in a 32-bit or 64-bit word. operation type depends on the type of addr โ main character energy, she adapts. ๐
this macro does not give any guarantees in regards to memory ordering or atomicity.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.
Definition at line 239 of file rte_bitops.h.
๐ #define rte_bit_atomic_test( addr, nr, memory_order) ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_test32, \
const uint32_t *: __rte_bit_atomic_test32, \
volatile uint32_t *: __rte_bit_atomic_v_test32, \
const volatile uint32_t *: __rte_bit_atomic_v_test32, \
uint64_t *: __rte_bit_atomic_test64, \
const uint64_t *: __rte_bit_atomic_test64, \
volatile uint64_t *: __rte_bit_atomic_v_test64, \
const volatile uint64_t *: __rte_bit_atomic_v_test64) \
(addr, nr, memory_order)
Warning โ EXPERIMENTAL: this API may change without prior notice. ๐ฅ
test if a particular bit in a word is set with a particular memory order. it tests a bit with the resulting memory load ordered as per the specified memory order โ so like, the memory ordering is your choice, bestie, she's flexible. ๐ธ
Parameters
addrโ a pointer to the word to query.nrโ the index of the bit.memory_orderโ the memory order to use.
- Returns โ
trueif the bit is set, andfalseotherwise.- Defined at line 266 of file
rte_bitops.h.
- Defined at line 266 of file
๐ธ #define rte_bit_atomic_set( addr, nr, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice. So likeโฆ don't build your whole personality on it staying the same, bestie ๐
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_set32, \
volatile uint32_t *: __rte_bit_atomic_v_set32, \
uint64_t *: __rte_bit_atomic_set64, \
volatile uint64_t *: __rte_bit_atomic_v_set64) \
(addr, nr, memory_order)
Atomically set bit in word. โจ
It's a generic selection macro that atomically sets the bit at index nr in the word that addr points to, flipping it to '1', using the memory ordering you picked out in memory_order. The way it just picks the right 32 or 64 helper for you based on the pointer type? Iconic. No cap. ๐
Parameters
addrโ a pointer to the word you wanna modify.nrโ the index of the bit.memory_orderโ the memory order to use.
Defined at line 295 of file rte_bitops.h.
๐ฆ #define rte_bit_atomic_clear( addr, nr, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_clear32, \
volatile uint32_t *: __rte_bit_atomic_v_clear32, \
uint64_t *: __rte_bit_atomic_clear64, \
volatile uint64_t *: __rte_bit_atomic_v_clear64) \
(addr, nr, memory_order)
Atomically clear bit in word. ๐งผ
Generic selection macro that atomically sets the bit at index nr in the word pointed to by addr to '0' (yes, the original says "set" here too, and honestly bestie we are reporting it exactly as it's written, not fixing it ๐
), with the memory ordering as specified by memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.memory_orderโ the memory order to use.
Defined at line 320 of file rte_bitops.h.
๐ #define rte_bit_atomic_assign( addr, nr, value, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_assign32, \
volatile uint32_t *: __rte_bit_atomic_v_assign32, \
uint64_t *: __rte_bit_atomic_assign64, \
volatile uint64_t *: __rte_bit_atomic_v_assign64) \
(addr, nr, value, memory_order)
Atomically assign a value to bit in word. ๐ซ
Generic selection macro that atomically sets the bit at index nr in the word pointed to by addr to whatever value says, using the memory ordering you specified with memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.valueโ the new value of the bit โtruefor'1', orfalsefor'0'.memory_orderโ the memory order to use.
Defined at line 347 of file rte_bitops.h.
๐ #define rte_bit_atomic_flip( addr, nr, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_flip32, \
volatile uint32_t *: __rte_bit_atomic_v_flip32, \
uint64_t *: __rte_bit_atomic_flip64, \
volatile uint64_t *: __rte_bit_atomic_v_flip64) \
(addr, nr, memory_order)
Atomically flip bit in word. ๐
Generic selection macro that atomically negates the value of the bit at index nr in the word pointed to by addr, to the value indicated by value (that's what it says, bestie โ we are not editorialising, just vibing โจ), with the memory ordering as specified with memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.memory_orderโ the memory order to use.
Defined at line 373 of file rte_bitops.h.
๐ #define rte_bit_atomic_test_and_set( addr, nr, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_test_and_set32, \
volatile uint32_t *: __rte_bit_atomic_v_test_and_set32, \
uint64_t *: __rte_bit_atomic_test_and_set64, \
volatile uint64_t *: __rte_bit_atomic_v_test_and_set64) \
(addr, nr, memory_order)
Atomically test and set a bit in word. ๐ซถ
Generic selection macro that atomically tests and sets the bit at index nr in the word pointed to by addr to '1', with the memory ordering as specified with memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.memory_orderโ the memory order to use.
Returns
true if the bit was set, and false otherwise.
Defined at line 400 of file rte_bitops.h.
๐ #define rte_bit_atomic_test_and_clear( addr, nr, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_test_and_clear32, \
volatile uint32_t *: __rte_bit_atomic_v_test_and_clear32, \
uint64_t *: __rte_bit_atomic_test_and_clear64, \
volatile uint64_t *: __rte_bit_atomic_v_test_and_clear64) \
(addr, nr, memory_order)
Atomically test and clear a bit in word. ๐ง
Generic selection macro that atomically tests and clears the bit at index nr in the word pointed to by addr to '0', with the memory ordering as specified with memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.memory_orderโ the memory order to use.
Returns
true if the bit was set, and false otherwise.
Defined at line 427 of file rte_bitops.h.
๐ #define rte_bit_atomic_test_and_assign( addr, nr, value, memory_order)
โ ๏ธ EXPERIMENTAL: this API may change without prior notice.
Value:
_Generic((addr), \
uint32_t *: __rte_bit_atomic_test_and_assign32, \
volatile uint32_t *: __rte_bit_atomic_v_test_and_assign32, \
uint64_t *: __rte_bit_atomic_test_and_assign64, \
volatile uint64_t *: __rte_bit_atomic_v_test_and_assign64) \
(addr, nr, value, memory_order)
Atomically test and assign a bit in word. ๐
Generic selection macro that atomically tests and assigns the bit at index nr in the word pointed to by addr the value specified by value, with the memory ordering as specified with memory_order.
Parameters
addrโ a pointer to the word to modify.nrโ the index of the bit.valueโ the new value of the bit โtruefor'1', orfalsefor'0'.memory_orderโ the memory order to use.
Returns
true if the bit was set, and false otherwise.
Defined at line 457 of file rte_bitops.h.
๐งฎ #define RTE_IS_POWER_OF_2( n)
Value:
((n) != 0 && (((n) - 1) & (n)) == 0)
Macro to return 1 if n is a power of 2, 0 otherwise. โญ
The way this one-liner just knows whether your number is a power of two? Ate. No crumbs. ๐
Defined at line 1302 of file rte_bitops.h.
๐ง Function Documentation
uint32_t rte_bit_relaxed_get32 (unsigned int nr, volatile uint32_t * addr)
[inline], [static]
Get the target bit from a 32-bit value without memory ordering. ๐
Parameters
nrโ the target bit to get.addrโ the address holding the bit.
Returns
The target bit.
Defined at line 674 of file rte_bitops.h.
void rte_bit_relaxed_set32 (unsigned int nr, volatile uint32_t * addr)
[inline], [static]
Set the target bit in a 32-bit value to 1 without memory ordering. โ
Parameters
nrโ the target bit to set.addrโ the address holding the bit.
Defined at line 691 of file rte_bitops.h.
void rte_bit_relaxed_clear32 (unsigned int nr, volatile uint32_t * addr)
[inline], [static]
Clear the target bit in a 32-bit value to 0 without memory ordering. ๐งฝ
Parameters
nrโ the target bit to clear.addrโ the address holding the bit.
Defined at line 708 of file rte_bitops.h.
uint32_t rte_bit_relaxed_test_and_set32 (unsigned int nr, volatile uint32_t * addr)
[inline], [static]
Return the original bit from a 32-bit value, then set it to 1 without memory ordering. ๐
Parameters
nrโ the target bit to get and set.addrโ the address holding the bit.
Returns
The original bit.
Defined at line 728 of file rte_bitops.h.
uint32_t rte_bit_relaxed_test_and_clear32 (unsigned int nr, volatile uint32_t * addr)
[inline], [static]
Return the original bit from a 32-bit value, then clear it to 0 without memory ordering. ๐ซง
Parameters
nrโ the target bit to get and clear.addrโ the address holding the bit.
Returns
The original bit.
Defined at line 750 of file rte_bitops.h.
uint64_t rte_bit_relaxed_get64 (unsigned int nr, volatile uint64_t * addr)
[inline], [static]
Get the target bit from a 64-bit value without memory ordering. ๐โจ
Parameters
nrโ the target bit to get.addrโ the address holding the bit.
Returns
The target bit.
Defined at line 773 of file rte_bitops.h.
void rte_bit_relaxed_set64 (unsigned int nr, volatile uint64_t * addr)
[inline], [static]
Set the target bit in a 64-bit value to 1 without memory ordering. โ โจ
Parameters
nrโ the target bit to set.addrโ the address holding the bit.
Defined at line 790 of file rte_bitops.h.
void rte_bit_relaxed_clear64 (unsigned int nr, volatile uint64_t * addr)
[inline], [static]
Clear the target bit in a 64-bit value to 0 without memory ordering. ๐งฝโจ
Parameters
nrโ the target bit to clear.addrโ the address holding the bit.
Defined at line 807 of file rte_bitops.h.
uint64_t rte_bit_relaxed_test_and_set64 (unsigned int nr, volatile uint64_t * addr)
[inline], [static]
Return the original bit from a 64-bit value, then set it to 1 without memory ordering. ๐โจ
Parameters
nrโ the target bit to get and set.addrโ the address holding the bit.
Returns
The original bit.
Defined at line 827 of file rte_bitops.h.
uint64_t rte_bit_relaxed_test_and_clear64 (unsigned int nr, volatile uint64_t * addr)
[inline], [static]
Return the original bit from a 64-bit value, then clear it to 0 without memory ordering. ๐ซงโจ
Parameters
nrโ the target bit to get and clear.addrโ the address holding the bit.
Returns
The original bit.
Defined at line 849 of file rte_bitops.h.
unsigned int rte_clz32 (uint32_t v)
[inline], [static]
Get the count of leading 0-bits in v. ๐ข
Parameters
vโ the value.
Returns
The count of leading zero bits.
Defined at line 1020 of file rte_bitops.h.
unsigned int rte_clz64 (uint64_t v)
[inline], [static]
Get the count of leading 0-bits in v. ๐ขโจ
Parameters
vโ the value.
Returns
The count of leading zero bits.
Defined at line 1034 of file rte_bitops.h.
unsigned int rte_ctz32 (uint32_t v)
[inline], [static]
Get the count of trailing 0-bits in v. ๐
Parameters
vโ the value.
Returns
The count of trailing zero bits.
Defined at line 1048 of file rte_bitops.h.
๐ซ rte_ctz64 ๐ซ
unsigned int rte_ctz64 (uint64_t v) [inline], [static]
okay bestie, this one counts your trailing 0-bits in v. like, how many zeros are chilling at the bottom before a 1 shows up. slay.
vโ the value, periodt.- Returns โ the count of trailing zero bits. ๐
Definition at line 1062 of file rte_bitops.h.
โจ rte_popcount32 โจ
unsigned int rte_popcount32 (uint32_t v) [inline], [static]
counting the 1-bits in v fr fr. the population count. it's giving census energy.
vโ the value.- Returns โ the count of 1-bits. ๐ธ
Definition at line 1076 of file rte_bitops.h.
๐ rte_popcount64 ๐
unsigned int rte_popcount64 (uint64_t v) [inline], [static]
same vibe as the 32 version but for your 64-bit bestie. counting 1-bits in v, iconic.
vโ the value.- Returns โ the count of 1-bits. โจ
Definition at line 1090 of file rte_bitops.h.
๐ฆ rte_ffs32 ๐ฆ
__rte_experimental unsigned int rte_ffs32 (uint32_t v) [inline], [static]
โ ๏ธ EXPERIMENTAL: this API may change without prior notice. like, it's still in its glow-up era, don't build your whole personality on it.
it searches v from the least significant bit (LSB) all the way up to the most significant bit (MSB) looking for a set bit (1). first one it finds? that's the moment.
vโ the value.- Returns โ bit index + 1 if a set bit is found, zero otherwise. ๐
Definition at line 1109 of file rte_bitops.h.
๐ rte_ffs64 ๐
__rte_experimental unsigned int rte_ffs64 (uint64_t v) [inline], [static]
โ ๏ธ EXPERIMENTAL: this API may change without prior notice. same disclaimer, still experimental, still cute.
searches v from the least significant bit (LSB) to the most significant bit (MSB) hunting for a set bit (1).
vโ the value.- Returns โ bit index + 1 if a set bit is found, zero otherwise. โญ
Definition at line 1128 of file rte_bitops.h.
๐ rte_combine32ms1b ๐
uint32_t rte_combine32ms1b (uint32_t x) [inline], [static]
okay so this one combines 32b inputs' most significant set bits into the least significant bits to construct a value with the same MSBs as x but all 1's under it. it's giving "smear the vibe downward" and honestly? obsessed.
xโ the integer whose MSBs need to be combined with its LSBs.- Returns โ the combined value. ๐ซถ
Definition at line 1146 of file rte_bitops.h.
๐ซ rte_combine64ms1b ๐ซ
uint64_t rte_combine64ms1b (uint64_t v) [inline], [static]
the 64b glow-up of the one above, no cap: combines 64b inputs' most significant set bits into the least significant bits to construct a value with the same MSBs as x but all 1's under it.
vโ the integer whose MSBs need to be combined with its LSBs.- Returns โ the combined value. ๐
Definition at line 1168 of file rte_bitops.h.
๐ฅ rte_bsf32 ๐ฅ
uint32_t rte_bsf32 (uint32_t v) [inline], [static]
searches the input parameter for the least significant set bit (starting from zero). if a least significant 1 bit is found, its bit index is returned. but bestie, listen โ if the content of the input parameter is zero, then the content of the return value is undefined. ๐ญ it's giving "don't do that".
vโ input parameter, should not be zero.- Returns โ least significant set bit in the input parameter.
Definition at line 1192 of file rte_bitops.h.
๐ญ rte_bsf32_safe ๐ญ
int rte_bsf32_safe (uint32_t v, uint32_t * pos) [inline], [static]
searches the input parameter for the least significant set bit (starting from zero). this is the safe version โ it actually checks whether the input parameter is zero, so it won't leave you on read like the other one.
โ ๏ธ pos must be a valid pointer. It is not checked! like, it will simply not catch that for you. that's on you, bestie.
vโ the input parameter.posโ ifvwas not0, this value will contain position of least significant bit within the input parameter.- Returns โ returns
0ifvwas0, otherwise returns1. โจ
Definition at line 1212 of file rte_bitops.h.
๐ง rte_bsf64 ๐ง
uint32_t rte_bsf64 (uint64_t v) [inline], [static]
searches the input parameter for the least significant set bit (starting from zero). if a least significant 1 bit is found, its bit index is returned. and if the content of the input parameter is zero? the content of the return value is undefined. yeah. same energy as the 32 one, just taller. ๐
vโ input parameter, should not be zero.- Returns โ least significant set bit in the input parameter.
Definition at line 1233 of file rte_bitops.h.
๐ rte_bsf64_safe ๐
int rte_bsf64_safe (uint64_t v, uint32_t * pos) [inline], [static]
searches the input parameter for the least significant set bit (starting from zero). safe version โ it checks for the input parameter being zero, so you get a real answer instead of chaos.
โ ๏ธ pos must be a valid pointer. It is not checked! once again, validating that pointer is a you problem.
vโ the input parameter.posโ ifvwas not0, this value will contain position of least significant bit within the input parameter.- Returns โ returns
0ifvwas0, otherwise returns1. ๐ธ
Definition at line 1253 of file rte_bitops.h.
๐ rte_fls_u32 ๐
uint32_t rte_fls_u32 (uint32_t x) [inline], [static]
returns the last (most-significant) bit set. main character bit, fr.
๐ Note: the last (most significant) bit is at position32.rte_fls_u32(0) = 0,rte_fls_u32(1) = 1,rte_fls_u32(0x80000000) = 32
xโ the input parameter.- Returns โ the last (most-significant) bit set, or
0if the input is0. โญ
Definition at line 1274 of file rte_bitops.h.
๐ฆ rte_fls_u64 ๐ฆ
uint32_t rte_fls_u64 (uint64_t x) [inline], [static]
returns the last (most-significant) bit set, but make it 64-bit.
๐ Note: the last (most significant) bit is at position64.rte_fls_u64(0) = 0,rte_fls_u64(1) = 1,rte_fls_u64(0x8000000000000000) = 64
xโ the input parameter.- Returns โ the last (most-significant) bit set, or
0if the input is0. ๐
Definition at line 1292 of file rte_bitops.h.
โจ rte_is_power_of_2 โจ
int rte_is_power_of_2 (uint32_t n) [inline], [static]
returns true if n is a power of 2. vibe check for powers of 2, basically.
nโ number to check.- Returns โ
1if true,0otherwise. ๐
Definition at line 1311 of file rte_bitops.h.
๐ rte_align32pow2 ๐
uint32_t rte_align32pow2 (uint32_t x) [inline], [static]
aligns the input parameter to the next power of 2. it's giving "round up to something tidy".
xโ the integer value to align.- Returns โ the smallest power of 2 which is greater than or equal to
x. ๐
Definition at line 1326 of file rte_bitops.h.
๐ rte_align32prevpow2 ๐
uint32_t rte_align32prevpow2 (uint32_t x) [inline], [static]
aligns the input parameter to the previous power of 2. going down instead of up, and honestly? sometimes that's the move.
xโ the integer value to align.- Returns โ the greatest power of 2 which is smaller than or equal to
x. ๐ซถ
Definition at line 1344 of file rte_bitops.h.
๐ฅ rte_align64pow2 ๐ฅ
uint64_t rte_align64pow2 (uint64_t v) [inline], [static]
aligns a 64b input parameter to the next power of 2.
vโ the 64b value to align.- Returns โ the smallest power of 2 which is greater than or equal to
v. โจ
Definition at line 1361 of file rte_bitops.h.
๐ซ rte_align64prevpow2 ๐ซ
uint64_t rte_align64prevpow2 (uint64_t v) [inline], [static]
aligns a 64b input parameter to the previous power of 2.
vโ the 64b value to align.- Returns โ the greatest power of 2 which is smaller than or equal to
v. ๐ธ
Definition at line 1379 of file rte_bitops.h.
๐ง rte_log2_u32 ๐ง
uint32_t rte_log2_u32 (uint32_t v) [inline], [static]
returns the rounded-up log2 of an integer. math class but make it cute.
๐ Note: contrary to the logarithm mathematical operation,rte_log2_u32(0) == 0and not-inf. like yeah, zero gets special treatment here, don't @ me.
vโ the input parameter.- Returns โ the rounded-up log2 of the input, or
0if the input is0. โญ
Definition at line 1398 of file rte_bitops.h.
๐ rte_log2_u64 ๐
uint32_t rte_log2_u64 (uint64_t v) [inline], [static]
returns the rounded-up log2 of a 64-bit integer. same math, bigger number, still adorable.
๐ Note: contrary to the logarithm mathematical operation,rte_log2_u64(0) == 0and not-inf. bestie, zero is still built different.
vโ the input parameter.- Returns โ the rounded-up log2 of the input, or
0if the input is0. ๐
Definition at line 1418 of file rte_bitops.h.
๐ AUTHOR ๐
Generated automatically by Doxygen for DPDK from the source code. ๐งโจ
and that's the whole page, bestie! ๐ every single one of these little inline baddies lives in rte_bitops.h, and this documentation came to you straight from DPDK, Version 25.11.3, as the manual page rte_bitops.h(3). go forth and bit-twiddle responsibly, ily, mwah ๐
๐
๐ฆ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 ยท BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms