rte_common.h(3)
๐ rte_common.h ๐
okay bestie, welcome to the Library Functions Manual page for rte_common.h โจ this is the DPDK grab-bag header where all the generic, commonly-used macros and inline functions live. it's a long one so buckle up, we're doing this in parts ๐
๐ธ NAME ๐ธ
rte_common.h
โจ SYNOPSIS โจ
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdalign.h>
#include <rte_compat.h>
#include <rte_config.h>
#include <rte_os.h>
๐ง Macros
#define __rte_aligned(a)
#define __rte_packed (RTE_DEPRECATED(__rte_packed)
__attribute__((__packed__)))
#define __rte_packed_begin
#define __rte_may_alias __attribute__((__may_alias__))
#define RTE_DEPRECATED(x)
#define __rte_diagnostic_push _Pragma('GCC diagnostic push')
#define __rte_diagnostic_ignored_wcast_qual _Pragma('GCC diagnostic
ignored ยด-Wcast-qualยด')
#define __rte_weak RTE_DEPRECATED(__rte_weak)
__attribute__((__weak__))
#define __rte_pure __attribute__((pure))
#define __rte_used __attribute__((used))
#define __rte_unused __attribute__((__unused__))
#define __rte_restrict __restrict
#define RTE_SET_USED(x)
#define __rte_format_printf(format_index, first_arg)
#define __rte_section(name)
#define __rte_alloc_size(...)
#define __rte_alloc_align(argno)
#define __rte_malloc
#define __rte_dealloc(dealloc, argno)
#define RTE_INIT_PRIO(func, prio)
#define RTE_INIT(func)
#define RTE_FINI_PRIO(func, prio)
#define RTE_FINI(func)
#define __rte_noreturn __attribute__((noreturn))
#define __rte_unreachable()
#define __rte_warn_unused_result __attribute__((warn_unused_result))
#define __rte_always_inline inline __attribute__((always_inline))
#define __rte_noinline __attribute__((noinline))
#define __rte_hot __attribute__((hot))
#define __rte_cold __attribute__((cold))
#define __rte_assume(condition)
#define __rte_no_asan
#define RTE_PTR_ADD(ptr, x)
#define RTE_PTR_SUB(ptr, x)
#define RTE_PTR_DIFF(ptr1, ptr2)
#define RTE_PTR_UNQUAL(X)
#define RTE_CAST_PTR(type, ptr)
#define RTE_CAST_FIELD(var, field, type)
#define RTE_PTR_ALIGN_FLOOR(ptr, align)
#define RTE_ALIGN_FLOOR(val, align)
#define RTE_PTR_ALIGN_CEIL(ptr, align)
#define RTE_ALIGN_CEIL(val, align)
#define RTE_PTR_ALIGN(ptr, align)
#define RTE_ALIGN(val, align)
#define RTE_ALIGN_MUL_CEIL(v, mul)
#define RTE_ALIGN_MUL_FLOOR(v, mul)
#define RTE_ALIGN_MUL_NEAR(v, mul)
#define RTE_BUILD_BUG_ON(condition)
#define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
#define RTE_CACHE_LINE_ROUNDUP(size)
#define RTE_CACHE_LINE_MIN_SIZE 64
#define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE)
#define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
#define RTE_CACHE_GUARD _RTE_CACHE_GUARD_HELPER1(__LINE__)
#define RTE_MIN(a, b)
#define RTE_MIN_T(a, b, t)
#define RTE_MAX(a, b)
#define RTE_MAX_T(a, b, t)
#define offsetof(TYPE, MEMBER)
#define container_of(ptr, type, member)
#define RTE_SWAP(a, b)
#define RTE_SIZEOF_FIELD(type, field)
#define RTE_STR(x)
#define RTE_FMT(fmt, ...)
#define RTE_LEN2MASK(ln, tp)
#define RTE_DIM(a)
๐ Typedefs
typedef uint64_t phys_addr_t
typedef uint64_t rte_iova_t
๐ฆ Functions
static int rte_is_aligned (const void *const __rte_restrict ptr, const
unsigned int align)
uint64_t rte_str_to_size (const char *str)
__rte_experimental char * rte_size_to_str (char *buf, int buf_size,
uint64_t count, bool use_iec, const char *unit)
__rte_noreturn void rte_exit (int exit_code, const char *format,...)
__rte_format_printf(2
โญ Variables
__extension__ typedef void * RTE_MARKER [0]
__extension__ typedef uint8_t RTE_MARKER8 [0]
__extension__ typedef uint16_t RTE_MARKER16 [0]
__extension__ typedef uint32_t RTE_MARKER32 [0]
__extension__ typedef uint64_t RTE_MARKER64 [0]
๐ Detailed Description ๐
Generic, commonly-used macro and inline function definitions for DPDK. bestie it's literally the shared toolbox header ๐งฐโจ
Definition in file rte_common.h.
๐ Macro Definition Documentation ๐
๐ #define __rte_aligned( a)
Value:
__attribute__((__aligned__(a)))
Force type alignment ๐ช
Use this one when you need to align a struct or union type. For toolchain compatibility it should appear between the {struct,union} keyword and tag. e.g.
struct __rte_aligned(8) tag { ... };
If it's alignment of an object/variable you're after, then do not use this macro โ instead prefer C11 alignas(a).
Definition at line 121 of file rte_common.h.
๐ #define __rte_packed (RTE_DEPRECATED(__rte_packed) __attribute__((__packed__)))
Deprecated ๐
See also
__rte_packed_begin__rte_packed_end
Force a structure to be packed.
Definition at line 144 of file rte_common.h.
๐ #define __rte_packed_begin
Force a structure to be packed. Usage:
struct __rte_packed_begin mystruct { ... } __rte_packed_end;
union __rte_packed_begin myunion { ... } __rte_packed_end;
Note: alignment attributes when present should precede __rte_packed_begin.
Definition at line 158 of file rte_common.h.
๐ #define __rte_may_alias __attribute__((__may_alias__))
Macro to mark a type that is not subject to type-based aliasing rules ๐ป
Definition at line 168 of file rte_common.h.
๐ #define RTE_DEPRECATED( x)
Macro to mark macros and defines scheduled for removal ๐๏ธ
Definition at line 188 of file rte_common.h.
๐ #define __rte_diagnostic_push _Pragma('GCC diagnostic push')
Macros to cause the compiler to remember the state of the diagnostics as of each push, and restore to that point at each pop. ๐
Definition at line 196 of file rte_common.h.
๐ #define __rte_diagnostic_ignored_wcast_qual _Pragma('GCC diagnostic ignored ยด-Wcast-qualยด')
Macro to disable compiler warnings about removing a type qualifier from the target type ๐คซ
Definition at line 208 of file rte_common.h.
๐ #define __rte_weak RTE_DEPRECATED(__rte_weak) __attribute__((__weak__))
Mark a function or variable to a weak reference.
Definition at line 219 of file rte_common.h.
๐ #define __rte_pure __attribute__((pure))
Mark a function to be pure ๐ค
Definition at line 228 of file rte_common.h.
๐ #define __rte_used __attribute__((used))
Force symbol to be generated even if it appears to be unused.
Definition at line 237 of file rte_common.h.
๐ #define __rte_unused __attribute__((__unused__))
short definition to mark a function parameter unused.
Definition at line 248 of file rte_common.h.
๐ #define __rte_restrict __restrict
Mark pointer as restricted with regard to pointer aliasing.
Definition at line 255 of file rte_common.h.
๐ #define RTE_SET_USED( x)
Value:
(void)(x)
definition to mark a variable or function parameter as used so as to avoid a compiler warning ๐ซโ ๏ธ
Definition at line 264 of file rte_common.h.
๐ #define __rte_format_printf( format_index, first_arg)
Value:
__attribute__((format(printf, format_index, first_arg)))
Check format string and its arguments at compile-time ๐
GCC on Windows assumes MS-specific format string by default, even if the underlying stdio implementation is ANSI-compliant, so this must be overridden.
Definition at line 280 of file rte_common.h.
๐ #define __rte_section( name)
Value:
__attribute__((section(name)))
Specify data or function section/segment ๐ฆ
Definition at line 292 of file rte_common.h.
๐ #define __rte_alloc_size( ...)
Tells compiler that the function returns a value that points to memory, where the size is given by the one or two arguments. Used by compiler to validate object size.
Definition at line 305 of file rte_common.h.
๐ #define __rte_alloc_align( argno)
Tells the compiler that the function returns a value that points to memory aligned by a function argument.
Note: not enabled on Clang because it warns if align argument is zero.
Definition at line 318 of file rte_common.h.
๐ #define __rte_malloc
Tells the compiler this is a function like malloc and that the pointer returned cannot alias any other pointer (ie new memory) ๐
Definition at line 328 of file rte_common.h.
๐ #define __rte_dealloc( dealloc, argno)
With recent GCC versions also able to track that proper deallocator function is used for this pointer.
Definition at line 339 of file rte_common.h.
๐ #define RTE_INIT_PRIO( func, prio)
Value:
static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
Run function before main() with high priority ๐
Parameters
- func โ Constructor function.
- prio โ Priority number must be above 100. Lowest number is the first to run.
Definition at line 361 of file rte_common.h.
๐ #define RTE_INIT( func)
Value:
RTE_INIT_PRIO(func, LAST)
Run function before main() with low priority.
The constructor will be run after prioritized constructors.
Parameters
- func โ Constructor function.
Definition at line 393 of file rte_common.h.
๐ #define RTE_FINI_PRIO( func, prio)
Value:
static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
Run after main() with low priority ๐
Parameters
- func โ Destructor function name.
- prio โ Priority number must be above 100. Lowest number is the last to run.
Definition at line 407 of file rte_common.h.
๐ #define RTE_FINI( func)
Value:
RTE_FINI_PRIO(func, LAST)
Run after main() with high priority.
The destructor will be run before prioritized destructors.
Parameters
- func โ Destructor function name.
Definition at line 434 of file rte_common.h.
๐ #define __rte_noreturn __attribute__((noreturn))
Hint never returning function ๐ช
Definition at line 443 of file rte_common.h.
๐ #define __rte_unreachable()
Value:
__assume(0)
Hint point in program never reached ๐ป
Definition at line 452 of file rte_common.h.
๐ #define __rte_warn_unused_result __attribute__((warn_unused_result))
Issue a warning in case the function's return value is ignored.
The use of this attribute should be restricted to cases where ignoring the marked function's return value is almost always a bug. With GCC, some effort is required to make clear that ignoring the return value is intentional. The usual void-casting method to mark something unused as used does not suppress the warning with this compiler.
__rte_warn_unused_result int foo();
void ignore_foo_result(void) {
foo(); // generates a warning with all compilers
(void)foo(); // still generates the warning with GCC (but not clang)
int unused __rte_unused;
unused = foo(); // does the trick with all compilers
}
Definition at line 481 of file rte_common.h.
๐ #define __rte_always_inline inline __attribute__((always_inline))
Force a function to be inlined ๐โ๏ธ๐จ
Definition at line 490 of file rte_common.h.
๐ #define __rte_noinline __attribute__((noinline))
Force a function to be noinlined โ
and bestie, that's where part 1 wraps โ there's literally so much more coming in the next parts, don't go anywhere ๐
__rte_hot
Value:
__attribute__((hot))
Tells the compiler this function lives in the hot path โ aka the code that gets hammered constantly and deserves all the optimization love. ๐ฅ
Definition at line 499 of file rte_common.h.
__rte_cold
Value:
__attribute__((cold))
Opposite energy bestie: this one's for functions in the cold path โ the ones that barely ever run, so optimizers can stop stressing about them. ๐ง
Definition at line 508 of file rte_common.h.
__rte_assume(condition)
Value:
__assume(condition)
Hints a precondition to the compiler โ like "trust me, this is true, optimize accordingly." ๐
Warning โ ๏ธ Depending on the compiler, any code inside condition might actually get executed. This currently only occurs with GCC prior to version 13. So likeโฆ don't put side effects in there, okay? ๐ญ
Definition at line 533 of file rte_common.h.
__rte_no_asan
Disables AddressSanitizer on some code. Sometimes you just gotta tell the sanitizer to look away. ๐
Definition at line 546 of file rte_common.h.
RTE_PTR_ADD(ptr, x)
Value:
((void*)((uintptr_t)(ptr) + (x)))
Adds a byte-value offset to a pointer. Slide to the right, pointer edition. โก๏ธโจ
Definition at line 554 of file rte_common.h.
RTE_PTR_SUB(ptr, x)
Value:
((void *)((uintptr_t)(ptr) - (x)))
Subtracts a byte-value offset from a pointer. Sliding left this time. โฌ ๏ธ
Definition at line 559 of file rte_common.h.
RTE_PTR_DIFF(ptr1, ptr2)
Value:
((uintptr_t)(ptr1) - (uintptr_t)(ptr2))
Gets the difference between two pointer values โ literally how far apart in bytes the locations they point to are. It assumes that ptr1 is greater than ptr2, so no flipping the order on me bestie. ๐
Definition at line 566 of file rte_common.h.
RTE_PTR_UNQUAL(X)
Value:
((void *)(uintptr_t)(X))
Macro to discard qualifiers (like const, volatile, restrict) from a pointer, without the compiler being dramatic about it and emitting a warning. ๐
Definition at line 574 of file rte_common.h.
RTE_CAST_PTR(type, ptr)
Value:
((type)(uintptr_t)(ptr))
Casts a pointer to a specific type, no warning about discarding qualifiers. Clean. โจ
Warning โ ๏ธ When you cast a pointer to point to a larger type, the resulting pointer may be misaligned, and misalignment = undefined behavior. E.g.:
struct s { uint16_t a; uint8_t b; uint8_t c; uint8_t d; } v; uint16_t *
p = RTE_CAST_PTR(uint16_t *, &v.c); // "p" is not 16 bit aligned!
Like, look at &v.c โ that's not 16-bit aligned, so p is living on the edge. ๐
Definition at line 593 of file rte_common.h.
RTE_CAST_FIELD(var, field, type)
Value:
(*(type *)((uintptr_t)(var) + offsetof(typeof(*(var)), field)))
Workaround to cast a const field of a structure to a non-const type. Sneaky but legal-ish. ๐
Definition at line 598 of file rte_common.h.
RTE_PTR_ALIGN_FLOOR(ptr, align)
Value:
((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)(ptr), align))
Aligns a pointer to a given power-of-two. The result is a pointer of the same type as the first parameter, and it points to an address no higher than the first parameter. Second parameter must be a power-of-two value. โฌ๏ธ
Definition at line 610 of file rte_common.h.
RTE_ALIGN_FLOOR(val, align)
Value:
(typeof(val))((val) & (~((typeof(val))((align) - 1))))
Aligns a value to a given power-of-two. Result is the same type as the first parameter, and no bigger than it. Second parameter must be a power-of-two value. ๐งฎ
Definition at line 619 of file rte_common.h.
RTE_PTR_ALIGN_CEIL(ptr, align)
Value:
RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)
Aligns a pointer to a given power-of-two. Result is the same type as the first parameter and points to an address no lower than the first parameter. Second parameter must be a power-of-two value. โฌ๏ธ
Definition at line 628 of file rte_common.h.
RTE_ALIGN_CEIL(val, align)
Value:
RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)
Aligns a value to a given power-of-two. Same type as the first parameter, no lower than it. Second parameter must be a power-of-two value. ๐ธ
Definition at line 637 of file rte_common.h.
RTE_PTR_ALIGN(ptr, align)
Value:
RTE_PTR_ALIGN_CEIL(ptr, align)
Aligns a pointer to a given power-of-two. Result is the same type as the first parameter and points to an address no lower than the first parameter. Second parameter must be a power-of-two value. This one is literally the same as RTE_PTR_ALIGN_CEIL โ twins fr fr. ๐ฏ
Definition at line 647 of file rte_common.h.
RTE_ALIGN(val, align)
Value:
RTE_ALIGN_CEIL(val, align)
Aligns a value to a given power-of-two. Same type as the first parameter, no lower than it. Second parameter must be a power-of-two value. This one is the same as RTE_ALIGN_CEIL. โจ
Definition at line 656 of file rte_common.h.
RTE_ALIGN_MUL_CEIL(v, mul)
Value:
((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul))
Aligns a value to the multiple of a given value. Result is the same type as the first parameter and no lower than it. ๐
Definition at line 663 of file rte_common.h.
RTE_ALIGN_MUL_FLOOR(v, mul)
Value:
(((v) / ((typeof(v))(mul))) * (typeof(v))(mul))
Aligns a value to the multiple of a given value. Result is the same type as the first parameter and no higher than it. ๐
Definition at line 671 of file rte_common.h.
RTE_ALIGN_MUL_NEAR(v, mul)
Value:
__extension__ ({ \
typeof(v) ceil = RTE_ALIGN_MUL_CEIL(v, mul); \
typeof(v) floor = RTE_ALIGN_MUL_FLOOR(v, mul); \
(ceil - (v)) > ((v) - floor) ? floor : ceil; \
})
Aligns a value to the nearest multiple of the given value. Result might be greater than or less than the first parameter โ whichever difference is the lowest wins. Vibe-based rounding, but make it math. ๐ฏ
Definition at line 679 of file rte_common.h.
RTE_BUILD_BUG_ON(condition)
Value:
do { static_assert(!(condition), #condition); } while (0)
Triggers a compile-time error if condition is true. Catch it before it ships. ๐ฅ
The do { } while(0) is there to work around a bug in clang (#55821) where it wouldn't handle _Static_assert inside a switch case. Not us being extra โ the compiler made us. ๐ค
Definition at line 716 of file rte_common.h.
RTE_CACHE_LINE_MASK
Value:
(RTE_CACHE_LINE_SIZE-1)
The cache line mask. Masking era. ๐ญ
Definition at line 721 of file rte_common.h.
RTE_CACHE_LINE_ROUNDUP(size)
Value:
RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE)
Returns the first cache-aligned value greater than or equal to size. Rounding up with purpose. ๐
Definition at line 724 of file rte_common.h.
RTE_CACHE_LINE_MIN_SIZE
Value:
64
Cache line size in terms of log2 โ the minimum cache line size. ๐งฑ
Definition at line 736 of file rte_common.h.
__rte_cache_aligned
Value:
__rte_aligned(RTE_CACHE_LINE_SIZE)
Forces alignment to the cache line. No straddling, bestie. ๐ซ
Definition at line 739 of file rte_common.h.
__rte_cache_min_aligned
Value:
__rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
Forces the minimum cache line alignment. Slightly more chill than the full thing. ๐
Definition at line 742 of file rte_common.h.
RTE_CACHE_GUARD
Value:
_RTE_CACHE_GUARD_HELPER1(__LINE__)
Empty cache lines, used to guard against false-sharing-like effects on systems with a next-N-lines hardware prefetcher. ๐ก๏ธ
Use it as spacing between data accessed by different lcores, to prevent cache thrashing on hardware with speculative prefetching.
Note: Although COUNTER would be better for uniqueness, as of March 2026 it is not yet part of the C standard, so compilation would fail when building in pedantic mode. ๐
Definition at line 759 of file rte_common.h.
RTE_MIN(a, b)
Value:
__extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
})
Returns the minimum of two numbers. Lil baby of the pair. ๐
Definition at line 799 of file rte_common.h.
RTE_MIN_T(a, b, t)
Value:
((t)(a) < (t)(b) ? (t)(a) : (t)(b))
Returns the minimum of two numbers.
Unlike RTE_MIN, it doesn't use temporary variables, so it's not safe if a or b is an expression. But the trade-off is it's guaranteed to be constant for use in static_assert(). Pick your fighter. โ๏ธ
Definition at line 813 of file rte_common.h.
RTE_MAX(a, b)
Value:
__extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
})
Returns the maximum of two numbers. The big one. ๐
Definition at line 819 of file rte_common.h.
RTE_MAX_T(a, b, t)
Value:
((t)(a) > (t)(b) ? (t)(a) : (t)(b))
Returns the maximum of two numbers.
Just like its MIN sibling, it skips the temporary variables โ so it is not safe if a or b is an expression. But it is guaranteed constant for static_assert(). ๐
Definition at line 833 of file rte_common.h.
offsetof(TYPE, MEMBER)
Value:
__builtin_offsetof (TYPE, MEMBER)
Returns the offset of a field in a structure. Classic. ๐งญ
Definition at line 840 of file rte_common.h.
container_of(ptr, type, member)
Value:
__extension__ ({ \
const typeof(((type *)0)->member) *_ptr = (ptr); \
__rte_unused type *_target_ptr = \
(type *)(ptr); \
(type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
})
Returns a pointer to the wrapping struct instance โ you give it the pointer to a member, it gives you back the whole container. It's giving "find the parent from the kid." ๐ซถ
Example:
struct wrapper { ... struct child c; ... };
struct child *x = obtain(...); struct wrapper *w = container_of(x,
struct wrapper, c);
Definition at line 862 of file rte_common.h.
RTE_SWAP(a, b)
Value:
__extension__ ({ \
typeof (a) _a = a; \
a = b; \
b = _a; \
})
Swaps two variables. Trade offer: I receive your value, you receive mine. ๐
Definition at line 872 of file rte_common.h.
RTE_SIZEOF_FIELD(type, field)
Value:
(sizeof(((type *)0)->field))
Gets the size of a field in a structure. ๐
Parameters
typeโ the type of the structure.fieldโ the field in the structure.
Returns
The size of the field in the structure, in bytes.
Definition at line 889 of file rte_common.h.
RTE_STR(x)
Value:
_RTE_STR(x)
Takes a macro value and gets a string version of it. Macro โ string, glow-up complete. โจ
Definition at line 893 of file rte_common.h.
RTE_FMT(fmt, ...)
Value:
fmt "%.0s", __VA_ARGS__ ""
ISO C helpers to modify format strings using variadic macros. This is a replacement for the ", ## __VA_ARGS__" GNU extension. An empty s argument is appended to avoid a dangling comma. ๐
Definition at line 900 of file rte_common.h.
RTE_LEN2MASK(ln, tp)
Value:
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
Mask value of type tp for the first ln bits set. Bits go brrr. ๐
Definition at line 905 of file rte_common.h.
Last macro in the lineup, and she's iconic: #define RTE_DIM( a) โ value is exactly (sizeof (a) / sizeof ((a)[0])), and it gives you the number of elements in the array. Definition at line 909 of file rte_common.h. ๐
โจ
โจ Typedef Documentation โจ
typedef uint64_t phys_addr_tโ Physical address. Definition at line 764 of filerte_common.h. ๐typedef uint64_t rte_iova_tโ IO virtual address type. When the physical addressing mode (IOVA as PA) is in use, the translation from an IO virtual address (IOVA) to a physical address is a direct mapping, i.e. the same value. Otherwise, in virtual mode (IOVA as VA), an IOMMU may do the translation. Definition at line 774 of filerte_common.h. ๐ฆ
๐ Function Documentation ๐
rte_is_aligned() โ alignment check, bestie ๐
int rte_is_aligned (const void *const __rte_restrict ptr, const unsigned int align) [inline], [static]
Checks if a pointer is aligned to a given power-of-two value.
Parameters:
ptrโ The pointer whose alignment is to be checkedalignโ The power-of-two value to which theptrshould be aligned
Returns: True(1) where the pointer is correctly aligned, false(0) otherwise
Definition at line 698 of file rte_common.h.
rte_str_to_size() โ numeric string glow-up ๐งฎ
uint64_t rte_str_to_size (const char * str)
Converts a numeric string to the equivalent uint64_t value. As well as straight number conversion, also recognises the suffixes k, m and g for kilobytes, megabytes and gigabytes respectively.
If a negative number is passed in i.e. a string with the first non-black character being "-", zero is returned. Zero is also returned in the case of an error with the strtoull call in the function.
Parameters:
strโ String containing number to convert.
Returns: Number.
rte_size_to_str() โ human-readable, experimental era ๐
Warning: EXPERIMENTAL: this API may change without prior notice.
__rte_experimental char * rte_size_to_str (char * buf, int buf_size, uint64_t count, bool use_iec, const char * unit)
Converts the uint64_t value provided to a human-readable string. It null-terminates the string, truncating the data if needed. An optional unit (like "B") can be provided as a string. It will be appended to the number, and a space will be inserted before the unit if needed.
Sample outputs: (1) "use_iec" disabled, (2) "use_iec" enabled, (3) "use_iec" enabled and "B" as unit.
0 : "0", "0", "0 B"
700 : "700", "700", "700 B"
1000 : "1.00 k", "1000", "1000 B"
1024 : "1.02 k", "1.00 ki", "1.00 kiB"
21474836480 : "21.5 G", "20.0 Gi", "20.0 GiB"
109951162777600 : "110 T", "100 Ti", "100 TiB"
Parameters:
bufโ Buffer to write the string to.buf_sizeโ Size of the buffer.countโ Number to convert.use_iecโ If true, use IEC units (1024-based), otherwise use SI units (1000-based).unitโ Unit to append to the string (Like"B"for bytes). Can beNULL.
Returns: buf on success, NULL if the buffer is too small.
rte_exit() โ immediate exit, no cap ๐ญ
__rte_noreturn void rte_exit (int exit_code, const char * format, ...)
Function to terminate the application immediately, printing an error message and returning the exit_code back to the shell.
This function never returns.
Parameters:
exit_codeโ The exit code to be returned by the applicationformatโ The format string to be used for printing the message. This can include printf format characters which will be expanded using any further parameters to the function.
๐ธ Variable Documentation ๐ธ
__extension__ typedef void* RTE_MARKER[0]โ Generic marker for any place in a structure. Definition at line 782 of filerte_common.h. ๐__extension__ typedef uint8_t RTE_MARKER8[0]โ Marker for 1B alignment in a structure. Definition at line 784 of filerte_common.h. ๐__extension__ typedef uint16_t RTE_MARKER16[0]โ Marker for 2B alignment in a structure. Definition at line 786 of filerte_common.h. ๐__extension__ typedef uint32_t RTE_MARKER32[0]โ Marker for 4B alignment in a structure. Definition at line 788 of filerte_common.h. ๐__extension__ typedef uint64_t RTE_MARKER64[0]โ Marker for 8B alignment in a structure. Definition at line 790 of filerte_common.h. ๐
๐ Author ๐
Generated automatically by Doxygen for DPDK from the source code. ๐ซถ
And that's the whole page, bestie. This one is from DPDK version 25.11.3, and it's the manual page for rte_common.h(3). Now go forth and use these macros responsibly. ๐โจ๐ฆ
๐ฆ 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