.TH "rte_bitops.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_bitops.h
.SH SYNOPSIS
.br
.PP
\fR#include <stdint\&.h>\fP
.br
\fR#include <rte_compat\&.h>\fP
.br
\fR#include <rte_debug\&.h>\fP
.br
\fR#include <rte_stdatomic\&.h>\fP
.br

.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBRTE_BIT64\fP(nr)"
.br
.ti -1c
.RI "#define \fBRTE_BIT32\fP(nr)"
.br
.ti -1c
.RI "#define \fBRTE_SHIFT_VAL32\fP(val,  nr)"
.br
.ti -1c
.RI "#define \fBRTE_SHIFT_VAL64\fP(val,  nr)"
.br
.ti -1c
.RI "#define \fBRTE_GENMASK32\fP(high,  low)"
.br
.ti -1c
.RI "#define \fBRTE_GENMASK64\fP(high,  low)"
.br
.ti -1c
.RI "#define \fBRTE_FIELD_GET32\fP(mask,  reg)"
.br
.ti -1c
.RI "#define \fBRTE_FIELD_GET64\fP(mask,  reg)"
.br
.ti -1c
.RI "#define \fBrte_bit_test\fP(addr,  nr)"
.br
.ti -1c
.RI "#define \fBrte_bit_set\fP(addr,  nr)"
.br
.ti -1c
.RI "#define \fBrte_bit_clear\fP(addr,  nr)"
.br
.ti -1c
.RI "#define \fBrte_bit_assign\fP(addr,  nr,  value)"
.br
.ti -1c
.RI "#define \fBrte_bit_flip\fP(addr,  nr)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_test\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_set\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_clear\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_assign\fP(addr,  nr,  value,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_flip\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_test_and_set\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_test_and_clear\fP(addr,  nr,  memory_order)"
.br
.ti -1c
.RI "#define \fBrte_bit_atomic_test_and_assign\fP(addr,  nr,  value,  memory_order)"
.br
.ti -1c
.RI "#define \fBRTE_IS_POWER_OF_2\fP(n)"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "static uint32_t \fBrte_bit_relaxed_get32\fP (unsigned int nr, volatile uint32_t *addr)"
.br
.ti -1c
.RI "static void \fBrte_bit_relaxed_set32\fP (unsigned int nr, volatile uint32_t *addr)"
.br
.ti -1c
.RI "static void \fBrte_bit_relaxed_clear32\fP (unsigned int nr, volatile uint32_t *addr)"
.br
.ti -1c
.RI "static uint32_t \fBrte_bit_relaxed_test_and_set32\fP (unsigned int nr, volatile uint32_t *addr)"
.br
.ti -1c
.RI "static uint32_t \fBrte_bit_relaxed_test_and_clear32\fP (unsigned int nr, volatile uint32_t *addr)"
.br
.ti -1c
.RI "static uint64_t \fBrte_bit_relaxed_get64\fP (unsigned int nr, volatile uint64_t *addr)"
.br
.ti -1c
.RI "static void \fBrte_bit_relaxed_set64\fP (unsigned int nr, volatile uint64_t *addr)"
.br
.ti -1c
.RI "static void \fBrte_bit_relaxed_clear64\fP (unsigned int nr, volatile uint64_t *addr)"
.br
.ti -1c
.RI "static uint64_t \fBrte_bit_relaxed_test_and_set64\fP (unsigned int nr, volatile uint64_t *addr)"
.br
.ti -1c
.RI "static uint64_t \fBrte_bit_relaxed_test_and_clear64\fP (unsigned int nr, volatile uint64_t *addr)"
.br
.ti -1c
.RI "static unsigned int \fBrte_clz32\fP (uint32_t v)"
.br
.ti -1c
.RI "static unsigned int \fBrte_clz64\fP (uint64_t v)"
.br
.ti -1c
.RI "static unsigned int \fBrte_ctz32\fP (uint32_t v)"
.br
.ti -1c
.RI "static unsigned int \fBrte_ctz64\fP (uint64_t v)"
.br
.ti -1c
.RI "static unsigned int \fBrte_popcount32\fP (uint32_t v)"
.br
.ti -1c
.RI "static unsigned int \fBrte_popcount64\fP (uint64_t v)"
.br
.ti -1c
.RI "static __rte_experimental unsigned int \fBrte_ffs32\fP (uint32_t v)"
.br
.ti -1c
.RI "static __rte_experimental unsigned int \fBrte_ffs64\fP (uint64_t v)"
.br
.ti -1c
.RI "static uint32_t \fBrte_combine32ms1b\fP (uint32_t x)"
.br
.ti -1c
.RI "static uint64_t \fBrte_combine64ms1b\fP (uint64_t v)"
.br
.ti -1c
.RI "static uint32_t \fBrte_bsf32\fP (uint32_t v)"
.br
.ti -1c
.RI "static int \fBrte_bsf32_safe\fP (uint32_t v, uint32_t *pos)"
.br
.ti -1c
.RI "static uint32_t \fBrte_bsf64\fP (uint64_t v)"
.br
.ti -1c
.RI "static int \fBrte_bsf64_safe\fP (uint64_t v, uint32_t *pos)"
.br
.ti -1c
.RI "static uint32_t \fBrte_fls_u32\fP (uint32_t x)"
.br
.ti -1c
.RI "static uint32_t \fBrte_fls_u64\fP (uint64_t x)"
.br
.ti -1c
.RI "static int \fBrte_is_power_of_2\fP (uint32_t n)"
.br
.ti -1c
.RI "static uint32_t \fBrte_align32pow2\fP (uint32_t x)"
.br
.ti -1c
.RI "static uint32_t \fBrte_align32prevpow2\fP (uint32_t x)"
.br
.ti -1c
.RI "static uint64_t \fBrte_align64pow2\fP (uint64_t v)"
.br
.ti -1c
.RI "static uint64_t \fBrte_align64prevpow2\fP (uint64_t v)"
.br
.ti -1c
.RI "static uint32_t \fBrte_log2_u32\fP (uint32_t v)"
.br
.ti -1c
.RI "static uint32_t \fBrte_log2_u64\fP (uint64_t v)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Bit Operations

.PP
This file provides functionality for low-level, single-word arithmetic and bit-level operations, such as counting or setting individual bits\&. 
.PP
Definition in file \fBrte_bitops\&.h\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define RTE_BIT64( nr)"
\fBValue:\fP
.nf
(UINT64_C(1) << (nr))
.PP
.fi
Get the uint64_t value for a specified bit set\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The bit number in range of 0 to 63\&. 
.RE
.PP

.PP
Definition at line \fB36\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_BIT32( nr)"
\fBValue:\fP
.nf
(UINT32_C(1) << (nr))
.PP
.fi
Get the uint32_t value for a specified bit set\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The bit number in range of 0 to 31\&. 
.RE
.PP

.PP
Definition at line \fB44\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_SHIFT_VAL32( val,  nr)"
\fBValue:\fP
.nf
(UINT32_C(val) << (nr))
.PP
.fi
Get the uint32_t shifted value\&.

.PP
\fBParameters\fP
.RS 4
\fIval\fP The value to be shifted\&. 
.br
\fInr\fP The shift number in range of 0 to (32 - width of val)\&. 
.RE
.PP

.PP
Definition at line \fB54\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_SHIFT_VAL64( val,  nr)"
\fBValue:\fP
.nf
(UINT64_C(val) << (nr))
.PP
.fi
Get the uint64_t shifted value\&.

.PP
\fBParameters\fP
.RS 4
\fIval\fP The value to be shifted\&. 
.br
\fInr\fP The shift number in range of 0 to (64 - width of val)\&. 
.RE
.PP

.PP
Definition at line \fB64\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_GENMASK32( high,  low)"
\fBValue:\fP
.nf
        (((~UINT32_C(0)) << (low)) & (~UINT32_C(0) >> (31u \- (high))))
.PP
.fi
Generate a contiguous 32-bit mask starting at bit position low and ending at position high\&.

.PP
\fBParameters\fP
.RS 4
\fIhigh\fP High bit position\&. 
.br
\fIlow\fP Low bit position\&. 
.RE
.PP

.PP
Definition at line \fB75\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_GENMASK64( high,  low)"
\fBValue:\fP
.nf
        (((~UINT64_C(0)) << (low)) & (~UINT64_C(0) >> (63u \- (high))))
.PP
.fi
Generate a contiguous 64-bit mask starting at bit position low and ending at position high\&.

.PP
\fBParameters\fP
.RS 4
\fIhigh\fP High bit position\&. 
.br
\fIlow\fP Low bit position\&. 
.RE
.PP

.PP
Definition at line \fB87\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_FIELD_GET32( mask,  reg)"
\fBValue:\fP
.nf
        ((typeof(mask))(((reg) & (mask)) >> rte_ctz32(mask)))
.PP
.fi
Extract a 32-bit field element\&.

.PP
\fBParameters\fP
.RS 4
\fImask\fP Shifted mask\&. 
.br
\fIreg\fP Value of entire bitfield\&. 
.RE
.PP

.PP
Definition at line \fB98\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_FIELD_GET64( mask,  reg)"
\fBValue:\fP
.nf
        ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask)))
.PP
.fi
Extract a 64-bit field element\&.

.PP
\fBParameters\fP
.RS 4
\fImask\fP Shifted mask\&. 
.br
\fIreg\fP Value of entire bitfield\&. 
.RE
.PP

.PP
Definition at line \fB109\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_test( addr,  nr)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Test bit in word\&.

.PP
Generic selection macro to test the value of a bit in a 32-bit or 64-bit word\&. The type of operation depends on the type of the \fRaddr\fP parameter\&.

.PP
This macro does not give any guarantees in regards to memory ordering or atomicity\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.RE
.PP

.PP
Definition at line \fB130\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_set( addr,  nr)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Set bit in word\&.

.PP
Generic selection macro to set a bit in a 32-bit or 64-bit word\&. The type of operation depends on the type of the \fRaddr\fP parameter\&.

.PP
This macro does not give any guarantees in regards to memory ordering or atomicity\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.RE
.PP

.PP
Definition at line \fB160\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_clear( addr,  nr)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Clear bit in word\&.

.PP
Generic selection macro to clear a bit in a 32-bit or 64-bit word\&. The type of operation depends on the type of the \fRaddr\fP parameter\&.

.PP
This macro does not give any guarantees in regards to memory ordering or atomicity\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.RE
.PP

.PP
Definition at line \fB186\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_assign( addr,  nr,  value)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Assign a value to a bit in word\&.

.PP
Generic selection macro to assign a value to a bit in a 32-bit or 64-bit word\&. The type of operation depends on the type of the \fRaddr\fP parameter\&.

.PP
This macro does not give any guarantees in regards to memory ordering or atomicity\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fIvalue\fP The new value of the bit - true for '1', or false for '0'\&. 
.RE
.PP

.PP
Definition at line \fB213\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_flip( addr,  nr)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Flip a bit in word\&.

.PP
Generic selection macro to change the value of a bit to '0' if '1' or '1' if '0' in a 32-bit or 64-bit word\&. The type of operation depends on the type of the \fRaddr\fP parameter\&.

.PP
This macro does not give any guarantees in regards to memory ordering or atomicity\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.RE
.PP

.PP
Definition at line \fB239\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_test( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Test if a particular bit in a word is set with a particular memory order\&.

.PP
Test a bit with the resulting memory load ordered as per the specified memory order\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to query\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns true if the bit is set, and false otherwise\&. 
.RE
.PP

.PP
Definition at line \fB266\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_set( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically set bit in word\&.

.PP
Generic selection macro to atomically set bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to '1', with the memory ordering as specified by \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP

.PP
Definition at line \fB295\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_clear( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically clear bit in word\&.

.PP
Generic selection macro to atomically set bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to '0', with the memory ordering as specified by \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP

.PP
Definition at line \fB320\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_assign( addr,  nr,  value,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically assign a value to bit in word\&.

.PP
Generic selection macro to atomically set bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to the value indicated by \fRvalue\fP, with the memory ordering as specified with \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fIvalue\fP The new value of the bit - true for '1', or false for '0'\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP

.PP
Definition at line \fB347\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_flip( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically flip bit in word\&.

.PP
Generic selection macro to atomically negate the value of the bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to the value indicated by \fRvalue\fP, with the memory ordering as specified with \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP

.PP
Definition at line \fB373\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_test_and_set( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically test and set a bit in word\&.

.PP
Generic selection macro to atomically test and set bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to '1', with the memory ordering as specified with \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns true if the bit was set, and false otherwise\&. 
.RE
.PP

.PP
Definition at line \fB400\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_test_and_clear( addr,  nr,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically test and clear a bit in word\&.

.PP
Generic selection macro to atomically test and clear bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP to '0', with the memory ordering as specified with \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns true if the bit was set, and false otherwise\&. 
.RE
.PP

.PP
Definition at line \fB427\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define rte_bit_atomic_test_and_assign( addr,  nr,  value,  memory_order)"
\fBValue:\fP
.nf
    _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)
.PP
.fi

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Atomically test and assign a bit in word\&.

.PP
Generic selection macro to atomically test and assign bit specified by \fRnr\fP in the word pointed to by \fRaddr\fP the value specified by \fRvalue\fP, with the memory ordering as specified with \fRmemory_order\fP\&.

.PP
\fBParameters\fP
.RS 4
\fIaddr\fP A pointer to the word to modify\&. 
.br
\fInr\fP The index of the bit\&. 
.br
\fIvalue\fP The new value of the bit - true for '1', or false for '0'\&. 
.br
\fImemory_order\fP The memory order to use\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns true if the bit was set, and false otherwise\&. 
.RE
.PP

.PP
Definition at line \fB457\fP of file \fBrte_bitops\&.h\fP\&.
.SS "#define RTE_IS_POWER_OF_2( n)"
\fBValue:\fP
.nf
((n) && !(((n) \- 1) & (n)))
.PP
.fi
Macro to return 1 if n is a power of 2, 0 otherwise 
.PP
Definition at line \fB1302\fP of file \fBrte_bitops\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "uint32_t rte_bit_relaxed_get32 (unsigned int nr, volatile uint32_t * addr)\fR [inline]\fP, \fR [static]\fP"
Get the target bit from a 32-bit value without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The target bit\&. 
.RE
.PP

.PP
Definition at line \fB674\fP of file \fBrte_bitops\&.h\fP\&.
.SS "void rte_bit_relaxed_set32 (unsigned int nr, volatile uint32_t * addr)\fR [inline]\fP, \fR [static]\fP"
Set the target bit in a 32-bit value to 1 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to set\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP

.PP
Definition at line \fB691\fP of file \fBrte_bitops\&.h\fP\&.
.SS "void rte_bit_relaxed_clear32 (unsigned int nr, volatile uint32_t * addr)\fR [inline]\fP, \fR [static]\fP"
Clear the target bit in a 32-bit value to 0 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to clear\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP

.PP
Definition at line \fB708\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_bit_relaxed_test_and_set32 (unsigned int nr, volatile uint32_t * addr)\fR [inline]\fP, \fR [static]\fP"
Return the original bit from a 32-bit value, then set it to 1 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get and set\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The original bit\&. 
.RE
.PP

.PP
Definition at line \fB728\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_bit_relaxed_test_and_clear32 (unsigned int nr, volatile uint32_t * addr)\fR [inline]\fP, \fR [static]\fP"
Return the original bit from a 32-bit value, then clear it to 0 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get and clear\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The original bit\&. 
.RE
.PP

.PP
Definition at line \fB750\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_bit_relaxed_get64 (unsigned int nr, volatile uint64_t * addr)\fR [inline]\fP, \fR [static]\fP"
Get the target bit from a 64-bit value without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The target bit\&. 
.RE
.PP

.PP
Definition at line \fB773\fP of file \fBrte_bitops\&.h\fP\&.
.SS "void rte_bit_relaxed_set64 (unsigned int nr, volatile uint64_t * addr)\fR [inline]\fP, \fR [static]\fP"
Set the target bit in a 64-bit value to 1 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to set\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP

.PP
Definition at line \fB790\fP of file \fBrte_bitops\&.h\fP\&.
.SS "void rte_bit_relaxed_clear64 (unsigned int nr, volatile uint64_t * addr)\fR [inline]\fP, \fR [static]\fP"
Clear the target bit in a 64-bit value to 0 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to clear\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP

.PP
Definition at line \fB807\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_bit_relaxed_test_and_set64 (unsigned int nr, volatile uint64_t * addr)\fR [inline]\fP, \fR [static]\fP"
Return the original bit from a 64-bit value, then set it to 1 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get and set\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The original bit\&. 
.RE
.PP

.PP
Definition at line \fB827\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_bit_relaxed_test_and_clear64 (unsigned int nr, volatile uint64_t * addr)\fR [inline]\fP, \fR [static]\fP"
Return the original bit from a 64-bit value, then clear it to 0 without memory ordering\&.

.PP
\fBParameters\fP
.RS 4
\fInr\fP The target bit to get and clear\&. 
.br
\fIaddr\fP The address holding the bit\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The original bit\&. 
.RE
.PP

.PP
Definition at line \fB849\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_clz32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of leading 0-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of leading zero bits\&. 
.RE
.PP

.PP
Definition at line \fB1020\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_clz64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of leading 0-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of leading zero bits\&. 
.RE
.PP

.PP
Definition at line \fB1034\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_ctz32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of trailing 0-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of trailing zero bits\&. 
.RE
.PP

.PP
Definition at line \fB1048\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_ctz64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of trailing 0-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of trailing zero bits\&. 
.RE
.PP

.PP
Definition at line \fB1062\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_popcount32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of 1-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of 1-bits\&. 
.RE
.PP

.PP
Definition at line \fB1076\fP of file \fBrte_bitops\&.h\fP\&.
.SS "unsigned int rte_popcount64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Get the count of 1-bits in v\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The count of 1-bits\&. 
.RE
.PP

.PP
Definition at line \fB1090\fP of file \fBrte_bitops\&.h\fP\&.
.SS "__rte_experimental unsigned int rte_ffs32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Search v from least significant bit (LSB) to the most significant bit (MSB) for a set bit (1)\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Bit index + 1 if a set bit is found, zero otherwise\&. 
.RE
.PP

.PP
Definition at line \fB1109\fP of file \fBrte_bitops\&.h\fP\&.
.SS "__rte_experimental unsigned int rte_ffs64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"

.PP
\fBWarning\fP
.RS 4
\fBEXPERIMENTAL:\fP this API may change without prior notice\&.
.RE
.PP
Search v from least significant bit (LSB) to the most significant bit (MSB) for a set bit (1)\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The value\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Bit index + 1 if a set bit is found, zero otherwise\&. 
.RE
.PP

.PP
Definition at line \fB1128\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_combine32ms1b (uint32_t x)\fR [inline]\fP, \fR [static]\fP"
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\&.

.PP
\fBParameters\fP
.RS 4
\fIx\fP The integer whose MSBs need to be combined with its LSBs 
.RE
.PP
\fBReturns\fP
.RS 4
The combined value\&. 
.RE
.PP

.PP
Definition at line \fB1146\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_combine64ms1b (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
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\&.

.PP
\fBParameters\fP
.RS 4
\fIv\fP The integer whose MSBs need to be combined with its LSBs 
.RE
.PP
\fBReturns\fP
.RS 4
The combined value\&. 
.RE
.PP

.PP
Definition at line \fB1168\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_bsf32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"
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\&. If the content of the input parameter is zero, then the content of the return value is undefined\&. 
.PP
\fBParameters\fP
.RS 4
\fIv\fP input parameter, should not be zero\&. 
.RE
.PP
\fBReturns\fP
.RS 4
least significant set bit in the input parameter\&. 
.RE
.PP

.PP
Definition at line \fB1192\fP of file \fBrte_bitops\&.h\fP\&.
.SS "int rte_bsf32_safe (uint32_t v, uint32_t * pos)\fR [inline]\fP, \fR [static]\fP"
Searches the input parameter for the least significant set bit (starting from zero)\&. Safe version (checks for input parameter being zero)\&.

.PP
\fBWarning\fP
.RS 4
\fRpos\fP must be a valid pointer\&. It is not checked!
.RE
.PP
\fBParameters\fP
.RS 4
\fIv\fP The input parameter\&. 
.br
\fIpos\fP If \fRv\fP was not 0, this value will contain position of least significant bit within the input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns 0 if \fRv\fP was 0, otherwise returns 1\&. 
.RE
.PP

.PP
Definition at line \fB1212\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_bsf64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
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\&. If the content of the input parameter is zero, then the content of the return value is undefined\&. 
.PP
\fBParameters\fP
.RS 4
\fIv\fP input parameter, should not be zero\&. 
.RE
.PP
\fBReturns\fP
.RS 4
least significant set bit in the input parameter\&. 
.RE
.PP

.PP
Definition at line \fB1233\fP of file \fBrte_bitops\&.h\fP\&.
.SS "int rte_bsf64_safe (uint64_t v, uint32_t * pos)\fR [inline]\fP, \fR [static]\fP"
Searches the input parameter for the least significant set bit (starting from zero)\&. Safe version (checks for input parameter being zero)\&.

.PP
\fBWarning\fP
.RS 4
\fRpos\fP must be a valid pointer\&. It is not checked!
.RE
.PP
\fBParameters\fP
.RS 4
\fIv\fP The input parameter\&. 
.br
\fIpos\fP If \fRv\fP was not 0, this value will contain position of least significant bit within the input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Returns 0 if \fRv\fP was 0, otherwise returns 1\&. 
.RE
.PP

.PP
Definition at line \fB1253\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_fls_u32 (uint32_t x)\fR [inline]\fP, \fR [static]\fP"
Return the last (most-significant) bit set\&.

.PP
\fBNote\fP
.RS 4
The last (most significant) bit is at position 32\&. 

.PP
rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32
.RE
.PP
\fBParameters\fP
.RS 4
\fIx\fP The input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The last (most-significant) bit set, or 0 if the input is 0\&. 
.RE
.PP

.PP
Definition at line \fB1274\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_fls_u64 (uint64_t x)\fR [inline]\fP, \fR [static]\fP"
Return the last (most-significant) bit set\&.

.PP
\fBNote\fP
.RS 4
The last (most significant) bit is at position 64\&. 

.PP
rte_fls_u64(0) = 0, rte_fls_u64(1) = 1, rte_fls_u64(0x8000000000000000) = 64
.RE
.PP
\fBParameters\fP
.RS 4
\fIx\fP The input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The last (most-significant) bit set, or 0 if the input is 0\&. 
.RE
.PP

.PP
Definition at line \fB1292\fP of file \fBrte_bitops\&.h\fP\&.
.SS "int rte_is_power_of_2 (uint32_t n)\fR [inline]\fP, \fR [static]\fP"
Returns true if n is a power of 2 
.PP
\fBParameters\fP
.RS 4
\fIn\fP Number to check 
.RE
.PP
\fBReturns\fP
.RS 4
1 if true, 0 otherwise 
.RE
.PP

.PP
Definition at line \fB1311\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_align32pow2 (uint32_t x)\fR [inline]\fP, \fR [static]\fP"
Aligns input parameter to the next power of 2

.PP
\fBParameters\fP
.RS 4
\fIx\fP The integer value to align
.RE
.PP
\fBReturns\fP
.RS 4
The smallest power of 2 which is greater than or equal to \fRx\fP\&. 
.RE
.PP

.PP
Definition at line \fB1326\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_align32prevpow2 (uint32_t x)\fR [inline]\fP, \fR [static]\fP"
Aligns input parameter to the previous power of 2

.PP
\fBParameters\fP
.RS 4
\fIx\fP The integer value to align
.RE
.PP
\fBReturns\fP
.RS 4
The greatest power of 2 which is smaller than or equal to \fRx\fP\&. 
.RE
.PP

.PP
Definition at line \fB1344\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_align64pow2 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Aligns 64b input parameter to the next power of 2

.PP
\fBParameters\fP
.RS 4
\fIv\fP The 64b value to align
.RE
.PP
\fBReturns\fP
.RS 4
The smallest power of 2 which is greater than or equal to \fRv\fP\&. 
.RE
.PP

.PP
Definition at line \fB1361\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint64_t rte_align64prevpow2 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Aligns 64b input parameter to the previous power of 2

.PP
\fBParameters\fP
.RS 4
\fIv\fP The 64b value to align
.RE
.PP
\fBReturns\fP
.RS 4
The greatest power of 2 which is smaller than or equal to \fRv\fP\&. 
.RE
.PP

.PP
Definition at line \fB1379\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_log2_u32 (uint32_t v)\fR [inline]\fP, \fR [static]\fP"
Return the rounded-up log2 of a integer\&.

.PP
\fBNote\fP
.RS 4
Contrary to the logarithm mathematical operation, rte_log2_u32(0) == 0 and not -inf\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIv\fP The input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The rounded-up log2 of the input, or 0 if the input is 0\&. 
.RE
.PP

.PP
Definition at line \fB1398\fP of file \fBrte_bitops\&.h\fP\&.
.SS "uint32_t rte_log2_u64 (uint64_t v)\fR [inline]\fP, \fR [static]\fP"
Return the rounded-up log2 of a 64-bit integer\&.

.PP
\fBNote\fP
.RS 4
Contrary to the logarithm mathematical operation, rte_log2_u64(0) == 0 and not -inf\&.
.RE
.PP
\fBParameters\fP
.RS 4
\fIv\fP The input parameter\&. 
.RE
.PP
\fBReturns\fP
.RS 4
The rounded-up log2 of the input, or 0 if the input is 0\&. 
.RE
.PP

.PP
Definition at line \fB1418\fP of file \fBrte_bitops\&.h\fP\&.
.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
