---
name: "rte_bitset.h"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_bitset.h"
---

# rte\_bitset.h(3)

## NAME

rte\_bitset.h

## SYNOPSIS

`#include <limits.h>`\
 `#include <stdbool.h>`\
 `#include <stddef.h>`\
 `#include <stdint.h>`\
 `#include <rte_bitops.h>`\
 `#include <rte_branch_prediction.h>`\
 `#include <rte_common.h>`\
 `#include <rte_compat.h>`\
 `#include <rte_debug.h>`\
 `#include <rte_memcpy.h>`\

### Macros

\#define **RTE\_BITSET\_WORD\_SIZE**   (sizeof(uint64\_t))\
 \#define **RTE\_BITSET\_WORD\_BITS**   (**RTE\_BITSET\_WORD\_SIZE** \* CHAR\_BIT)\
 \#define **RTE\_BITSET\_NUM\_WORDS**(size)   	((size + **RTE\_BITSET\_WORD\_BITS** - 1) / **RTE\_BITSET\_WORD\_BITS**)\
 \#define **RTE\_BITSET\_SIZE**(size)   	((size\_t)(**RTE\_BITSET\_NUM\_WORDS**(size) \* **RTE\_BITSET\_WORD\_SIZE**))\
 \#define **RTE\_BITSET\_DECLARE**(name,  size)   	uint64\_t name\[**RTE\_BITSET\_NUM\_WORDS**(size)\]\
 \#define **RTE\_BITSET\_FOREACH\_SET**(var,  bitset,  size)   	\_\_RTE\_BITSET\_FOREACH(var, bitset, size, 0, size, 0)\
 \#define **RTE\_BITSET\_FOREACH\_CLEAR**(var,  bitset,  size)   	\_\_RTE\_BITSET\_FOREACH(var, bitset, size, 0, size, \_\_RTE\_BITSET\_FIND\_FLAG\_FIND\_CLEAR)\
 \#define **RTE\_BITSET\_FOREACH\_SET\_RANGE**(var,  bitset,  size,  start\_bit,  len)   	\_\_RTE\_BITSET\_FOREACH(var, bitset, size, start\_bit, len, 0)\
 \#define **RTE\_BITSET\_FOREACH\_CLEAR\_RANGE**(var,  bitset,  size,  start\_bit,  len)   	\_\_RTE\_BITSET\_FOREACH(var, bitset, size, start\_bit, len, \_\_RTE\_BITSET\_FIND\_FLAG\_FIND\_CLEAR)\

### Functions

static \_\_rte\_experimental void **rte\_bitset\_init** (uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental bool **rte\_bitset\_test** (const uint64\_t \*bitset, size\_t bit\_num)\
 static \_\_rte\_experimental void **rte\_bitset\_set** (uint64\_t \*bitset, size\_t bit\_num)\
 static \_\_rte\_experimental void **rte\_bitset\_clear** (uint64\_t \*bitset, size\_t bit\_num)\
 static \_\_rte\_experimental void **rte\_bitset\_assign** (uint64\_t \*bitset, size\_t bit\_num, bool bit\_value)\
 static \_\_rte\_experimental void **rte\_bitset\_flip** (uint64\_t \*bitset, size\_t bit\_num)\
 static \_\_rte\_experimental bool **rte\_bitset\_atomic\_test** (const uint64\_t \*bitset, size\_t bit\_num, int memory\_order)\
 static \_\_rte\_experimental void **rte\_bitset\_atomic\_set** (uint64\_t \*bitset, size\_t bit\_num, int memory\_order)\
 static \_\_rte\_experimental void **rte\_bitset\_atomic\_clear** (uint64\_t \*bitset, size\_t bit\_num, int memory\_order)\
 static \_\_rte\_experimental void **rte\_bitset\_atomic\_assign** (uint64\_t \*bitset, size\_t bit\_num, bool bit\_value, int memory\_order)\
 static \_\_rte\_experimental void **rte\_bitset\_atomic\_flip** (uint64\_t \*bitset, size\_t bit\_num, int memory\_order)\
 static \_\_rte\_experimental void **rte\_bitset\_set\_all** (uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_clear\_all** (uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental size\_t **rte\_bitset\_count\_set** (const uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental size\_t **rte\_bitset\_count\_clear** (const uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_first\_set** (const uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_set** (const uint64\_t \*bitset, size\_t size, size\_t start\_bit, size\_t len)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_set\_wrap** (const uint64\_t \*bitset, size\_t size, size\_t start\_bit, size\_t len)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_first\_clear** (const uint64\_t \*bitset, size\_t size)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_clear** (const uint64\_t \*bitset, size\_t size, size\_t start\_bit, size\_t len)\
 static \_\_rte\_experimental ssize\_t **rte\_bitset\_find\_clear\_wrap** (const uint64\_t \*bitset, size\_t size, size\_t start\_bit, size\_t len)\
 static \_\_rte\_experimental void **rte\_bitset\_copy** (uint64\_t \***\_\_rte\_restrict** dst\_bitset, const uint64\_t \***\_\_rte\_restrict** src\_bitset, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_or** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset0, const uint64\_t \*src\_bitset1, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_and** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset0, const uint64\_t \*src\_bitset1, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_xor** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset0, const uint64\_t \*src\_bitset1, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_complement** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset, size\_t size)\
 static \_\_rte\_experimental void **rte\_bitset\_shift\_left** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset, size\_t size, size\_t shift\_bits)\
 static \_\_rte\_experimental void **rte\_bitset\_shift\_right** (uint64\_t \*dst\_bitset, const uint64\_t \*src\_bitset, size\_t size, size\_t shift\_bits)\
 static \_\_rte\_experimental bool **rte\_bitset\_equal** (const uint64\_t \*bitset\_a, const uint64\_t \*bitset\_b, size\_t size)\
 \_\_rte\_experimental ssize\_t **rte\_bitset\_to\_str** (const uint64\_t \*bitset, size\_t size, char \*buf, size\_t capacity)\

## Detailed Description

RTE Bitset

This file provides functions and macros for querying and manipulating sets of bits kept in arrays of `uint64_t-sized` elements.

The bits in a bitset are numbered from 0 to `size` - 1, with the lowest index being the least significant bit.

The bitset array must be properly aligned.

For optimal performance, the `size` parameter, required by many of the API's functions, should be a compile-time constant.

For large bitsets, the **rte\_bitmap.h** API may be more appropriate.

**Warning**

All functions modifying a bitset may overwrite any unused bits of the last word. Such unused bits are ignored by all functions reading bits.

Definition in file **rte\_bitset.h**.

## Macro Definition Documentation

### #define RTE\_BITSET\_WORD\_SIZE (sizeof(uint64\_t))

The size (in bytes) of each element in the array used to represent a bitset.

Definition at line **53** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_WORD\_BITS (RTE\_BITSET\_WORD\_SIZE \* CHAR\_BIT)

The size (in bits) of each element in the array used to represent a bitset.

Definition at line **59** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_NUM\_WORDS(size) ((size + RTE\_BITSET\_WORD\_BITS - 1) / RTE\_BITSET\_WORD\_BITS)

Computes the number of words required to store `size` bits.

Definition at line **64** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_SIZE(size) ((size\_t)(RTE\_BITSET\_NUM\_WORDS(size) \* RTE\_BITSET\_WORD\_SIZE))

Computes the amount of memory (in bytes) required to fit a bitset holding `size` bits.

Definition at line **71** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_DECLARE(name, size) uint64\_t name\[RTE\_BITSET\_NUM\_WORDS(size)\]

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Declare a bitset.

Declare (e.g., as a struct field) or define (e.g., as a stack variable) a bitset of the specified size.

**Parameters**

*size* The number of bits the bitset must be able to represent. Must be a compile-time constant. \
 *name* The field or variable name of the resulting definition.

Definition at line **104** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_FOREACH\_SET(var, bitset, size) \_\_RTE\_BITSET\_FOREACH(var, bitset, size, 0, size, 0)

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Iterate over all bits set.

This macro iterates over all bits set (i.e., all ones) in the bitset, in the forward direction (i.e., starting with the least significant '1').

**Parameters**

*var* An iterator variable of type `ssize_t`. For each successive iteration, this variable will hold the bit index of a set bit. \
 *bitset* A `const uint64_t *` pointer to the bitset array. \
 *size* The size of the bitset (in bits).

Definition at line **135** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_FOREACH\_CLEAR(var, bitset, size) \_\_RTE\_BITSET\_FOREACH(var, bitset, size, 0, size, \_\_RTE\_BITSET\_FIND\_FLAG\_FIND\_CLEAR)

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Iterate over all bits cleared.

This macro iterates over all bits cleared in the bitset, in the forward direction (i.e., starting with the lowest-indexed set bit).

**Parameters**

*var* An iterator variable of type `ssize_t`. For each successive iteration, this variable will hold the bit index of a cleared bit. \
 *bitset* A `const uint64_t *` pointer to the bitset array. \
 *size* The size of the bitset (in bits).

Definition at line **155** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_FOREACH\_SET\_RANGE(var, bitset, size, start\_bit, len) \_\_RTE\_BITSET\_FOREACH(var, bitset, size, start\_bit, len, 0)

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Iterate over all bits set within a range.

This macro iterates over all bits set (i.e., all ones) in the specified range, in the forward direction (i.e., starting with the least significant '1').

**Parameters**

*var* An iterator variable of type `ssize_t`. For each successive iteration, this variable will hold the bit index of a set bit. \
 *bitset* A `const uint64_t *` pointer to the bitset array. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The length (in bits) of the range. `start_bit` + `len` must be less than or equal to `size`.

Definition at line **181** of file **rte\_bitset.h**.

### #define RTE\_BITSET\_FOREACH\_CLEAR\_RANGE(var, bitset, size, start\_bit, len) \_\_RTE\_BITSET\_FOREACH(var, bitset, size, start\_bit, len, \_\_RTE\_BITSET\_FIND\_FLAG\_FIND\_CLEAR)

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Iterate over all cleared bits within a range.

This macro iterates over all bits cleared (i.e., all zeroes) in the specified range, in the forward direction (i.e., starting with the least significant '0').

**Parameters**

*var* An iterator variable of type `ssize_t`. For each successive iteration, this variable will hold the bit index of a set bit. \
 *bitset* A `const uint64_t *` pointer to the bitset array. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The length (in bits) of the range. `start_bit` + `len` must be less than or equal to `size`.

Definition at line **207** of file **rte\_bitset.h**.

## Function Documentation

### static \_\_rte\_experimental void rte\_bitset\_init (uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Initializes a bitset.

All bits are cleared.

In case all words in the bitset array are already set to zero by other means (e.g., at the time of memory allocation), this function need not be called.

**Parameters**

*bitset* A pointer to the array of bitset 64-bit words. \
 *size* The size of the bitset (in bits).

Definition at line **236** of file **rte\_bitset.h**.

### static \_\_rte\_experimental bool rte\_bitset\_test (const uint64\_t \* bitset, size\_t bit\_num)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Test if a bit is set.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* Index of the bit to test. Index 0 is the least significant bit.

**Returns**

Returns true if the bit is '1', and false if the bit is '0'.

Definition at line **256** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_set (uint64\_t \* bitset, size\_t bit\_num)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Set a bit in the bitset.

Bits are numbered from 0 to (size - 1) (inclusive).

The operation is not guaranteed to be atomic.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be set.

Definition at line **284** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_clear (uint64\_t \* bitset, size\_t bit\_num)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Clear a bit in the bitset.

Bits are numbered 0 to (size - 1) (inclusive).

The operation is not guaranteed to be atomic.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be cleared.

Definition at line **312** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_assign (uint64\_t \* bitset, size\_t bit\_num, bool bit\_value)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Set or clear a bit in the bitset.

Bits are numbered 0 to (size - 1) (inclusive).

The operation is not guaranteed to be atomic.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be set or cleared. \
 *bit\_value* Control if the bit should be set or cleared.

Definition at line **342** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_flip (uint64\_t \* bitset, size\_t bit\_num)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Change the value of a bit in the bitset.

Bits are numbered 0 to (size - 1) (inclusive).

The operation is not guaranteed to be atomic.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be flipped.

Definition at line **371** of file **rte\_bitset.h**.

### static \_\_rte\_experimental bool rte\_bitset\_atomic\_test (const uint64\_t \* bitset, size\_t bit\_num, int memory\_order)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Atomically test if a bit is set.

Atomically test if a bit in a bitset is set with the specified memory ordering.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* Index of the bit to test. Index 0 is the least significant bit. \
 *memory\_order* The memory order to use.

**Returns**

Returns true if the bit is '1', and false if the bit is '0'.

Definition at line **402** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_atomic\_set (uint64\_t \* bitset, size\_t bit\_num, int memory\_order)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Atomically set a bit in the bitset.

Set a bit in a bitset as an atomic operation, with the specified memory ordering.

**rte\_bitset\_atomic\_set()** is multi-thread safe, provided all threads acting in parallel on the same bitset does so through `rte_bitset_atomic_*`() functions.

Bits are numbered from 0 to (size - 1) (inclusive).

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be set. \
 *memory\_order* The memory order to use.

Definition at line **438** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_atomic\_clear (uint64\_t \* bitset, size\_t bit\_num, int memory\_order)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Atomically clear a bit in the bitset.

Clear a bit in a bitset as an atomic operation, with the specified memory ordering.

**rte\_bitset\_atomic\_clear()** is multi-thread safe, provided all threads acting in parallel on the same bitset does so through `rte_bitset_atomic_*`() functions.

Bits are numbered from 0 to (size - 1) (inclusive).

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be cleared. \
 *memory\_order* The memory order to use.

Definition at line **474** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_atomic\_assign (uint64\_t \* bitset, size\_t bit\_num, bool bit\_value, int memory\_order)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Atomically set or clear a bit in the bitset.

Assign a value to a bit in a bitset as an atomic operation, with the specified memory ordering.

**rte\_bitset\_atomic\_assign()** is multi-thread safe, provided all threads acting in parallel on the same bitset does so through `rte_bitset_atomic_*`() functions.

Bits are numbered from 0 to (size - 1) (inclusive).

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be set or cleared. \
 *bit\_value* Control if the bit should be set or cleared. \
 *memory\_order* The memory order to use.

Definition at line **512** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_atomic\_flip (uint64\_t \* bitset, size\_t bit\_num, int memory\_order)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Atomically change the value of a bit in the bitset.

Flip a bit in a bitset as an atomic operation, with the specified memory ordering.

**rte\_bitset\_atomic\_flip()** is multi-thread safe, provided all threads acting in parallel on the same bitset does so through `rte_bitset_atomic_*`() functions.

Bits are numbered from 0 to (size - 1) (inclusive).

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *bit\_num* The index of the bit to be flipped. \
 *memory\_order* The memory order to use.

Definition at line **549** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_set\_all (uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Set all bits in the bitset.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

Definition at line **574** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_clear\_all (uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Clear all bits in the bitset.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

Definition at line **592** of file **rte\_bitset.h**.

### static \_\_rte\_experimental size\_t rte\_bitset\_count\_set (const uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Count all set bits (also known as the *weight*).

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

**Returns**

Returns the number of '1' bits in the bitset.

Definition at line **618** of file **rte\_bitset.h**.

### static \_\_rte\_experimental size\_t rte\_bitset\_count\_clear (const uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Count all cleared bits.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

**Returns**

Returns the number of '0' bits in the bitset.

Definition at line **650** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_first\_set (const uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first bit set.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), and returns the index of the first '1'.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

**Returns**

Returns the index of the least significant '1', or -1 if all bits are '0'.

Definition at line **767** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_set (const uint64\_t \* bitset, size\_t size, size\_t start\_bit, size\_t len)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first bit set at offset.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), starting at an offset `start_bit` into the bitset, and returns the index of the first '1' encountered.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The number of bits to scan. `start_bit` + `len` must be less than or equal to `size`.

**Returns**

Returns the index of the least significant '1', or -1 if all bits are '0'.

Definition at line **803** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_set\_wrap (const uint64\_t \* bitset, size\_t size, size\_t start\_bit, size\_t len)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first bit set at offset, with wrap-around.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), starting at an offset `start_bit` into the bitset. If no '1' is encountered before the end of the bitset, the search will continue at index 0.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The number of bits to scan. `start_bit` + `len` must be less than or equal to `size`.

**Returns**

Returns the index of the least significant '1', or -1 if all bits are '0'.

Definition at line **842** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_first\_clear (const uint64\_t \* bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first cleared bit.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), and returns the index of the first '0'.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits).

**Returns**

Returns the index of the least significant '0', or -1 if all bits are '1'.

Definition at line **874** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_clear (const uint64\_t \* bitset, size\_t size, size\_t start\_bit, size\_t len)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first cleared bit at offset.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), starting at an offset `start_bit` into the bitset, and returns the index of the first '0' encountered.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The number of bits to scan. `start_bit` + `len` must be less than or equal to `size`.

**Returns**

Returns the index of the least significant '0', or -1 if all bits are '1'.

Definition at line **910** of file **rte\_bitset.h**.

### static \_\_rte\_experimental ssize\_t rte\_bitset\_find\_clear\_wrap (const uint64\_t \* bitset, size\_t size, size\_t start\_bit, size\_t len)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Find first cleared bit at offset, with wrap-around.

Scans the bitset in the forward direction (i.e., starting at the least significant bit), starting at an offset `start_bit` into the bitset. If no '0' is encountered before the end of the bitset, the search will continue at index 0.

**Parameters**

*bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitset (in bits). \
 *start\_bit* The index of the first bit to check. Must be less than `size`. \
 *len* The number of bits to scan. `start_bit` + `len` must be less than or equal to `size`.

**Returns**

Returns the index of the least significant '0', or -1 if all bits are '1'.

Definition at line **949** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_copy (uint64\_t \*\_\_rte\_restrict dst\_bitset, const uint64\_t \*\_\_rte\_restrict src\_bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Copy bitset.

Copy the bits of the `src_bitset` to the `dst_bitset`.

The bitsets may not overlap and must be of equal size.

**Parameters**

*dst\_bitset* A pointer to the array of words making up the bitset. \
 *src\_bitset* A pointer to the array of words making up the bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **982** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_or (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset0, const uint64\_t \* src\_bitset1, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Bitwise or two bitsets.

Perform a bitwise OR operation on all bits in the two equal-size bitsets `src_bitset0` and `src_bitset1`, and store the results in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset0* A pointer to the first source bitset. \
 *src\_bitset1* A pointer to the second source bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **1009** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_and (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset0, const uint64\_t \* src\_bitset1, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Bitwise and two bitsets.

Perform a bitwise AND operation on all bits in the two equal-size bitsets `src_bitset0` and `src_bitset1`, and store the result in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset0* A pointer to the first source bitset. \
 *src\_bitset1* A pointer to the second source bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **1039** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_xor (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset0, const uint64\_t \* src\_bitset1, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Bitwise xor two bitsets.

Perform a bitwise XOR operation on all bits in the two equal-size bitsets `src_bitset0` and `src_bitset1`, and store the result in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset0* A pointer to the first source bitset. \
 *src\_bitset1* A pointer to the second source bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **1069** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_complement (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Compute the bitwise complement of a bitset.

Flip every bit in the `src_bitset`, and store the result in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset* A pointer to the source bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **1096** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_shift\_left (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset, size\_t size, size\_t shift\_bits)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Shift bitset left.

Perform a logical shift left of (multiply) `src_bitset`, and store the result in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset* A pointer to the source bitset. \
 *size* The size of the bitsets (in bits). \
 *shift\_bits* The number of bits to shift the bitset.

Definition at line **1124** of file **rte\_bitset.h**.

### static \_\_rte\_experimental void rte\_bitset\_shift\_right (uint64\_t \* dst\_bitset, const uint64\_t \* src\_bitset, size\_t size, size\_t shift\_bits)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Shift bitset right.

Perform a logical shift right of (divide) `src_bitset`, and store the result in `dst_bitset`.

**Parameters**

*dst\_bitset* A pointer to the destination bitset. \
 *src\_bitset* A pointer to the source bitset. \
 *size* The size of the bitsets (in bits). \
 *shift\_bits* The number of bits to shift the bitset.

Definition at line **1169** of file **rte\_bitset.h**.

### static \_\_rte\_experimental bool rte\_bitset\_equal (const uint64\_t \* bitset\_a, const uint64\_t \* bitset\_b, size\_t size)` [inline]`, ` [static]`

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Compare two bitsets.

Compare two bitsets for equality.

**Parameters**

*bitset\_a* A pointer to the destination bitset. \
 *bitset\_b* A pointer to the source bitset. \
 *size* The size of the bitsets (in bits).

Definition at line **1222** of file **rte\_bitset.h**.

### \_\_rte\_experimental ssize\_t rte\_bitset\_to\_str (const uint64\_t \* bitset, size\_t size, char \* buf, size\_t capacity)

**Warning**

**EXPERIMENTAL:** this API may change without prior notice.

Converts a bitset to a string.

This function prints a string representation of the bitstring to the supplied buffer.

Each bit is represented either by '0' or '1' in the output, with the first (left-most) character in the output being the most significant bit. The resulting string is NUL terminated.

**Parameters**

*bitset* A pointer to the array of bitset 64-bit words. \
 *size* The number of bits the bitset represent. \
 *buf* A buffer to hold the output. \
 *capacity* The size of the buffer. Must be `size` + 1 or larger.

**Returns**

Returns the number of bytes written (i.e., `size` + 1), or -EINVAL in case the buffer capacity was too small.

## Author

Generated automatically by Doxygen for DPDK from the source code.
