---
name: "rte_common.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_common.h"
---

# rte\_common.h(3)

## NAME

rte\_common.h

## SYNOPSIS

`#include <assert.h>`\
 `#include <limits.h>`\
 `#include <stdint.h>`\
 `#include <stdalign.h>`\
 `#include <rte_config.h>`\
 `#include <rte_os.h>`\

### Macros

\#define **\_\_rte\_aligned**(a)   \_\_attribute\_\_((\_\_aligned\_\_(a)))\
 \#define **\_\_rte\_packed**   \_\_attribute\_\_((\_\_packed\_\_))\
 \#define **\_\_rte\_may\_alias**   \_\_attribute\_\_((\_\_may\_alias\_\_))\
 \#define **RTE\_DEPRECATED**(x)\
 \#define **\_\_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)   (void)(x)\
 \#define **\_\_rte\_format\_printf**(format\_index,  first\_arg)   	\_\_attribute\_\_((format(printf, format\_index, first\_arg)))\
 \#define **\_\_rte\_section**(name)   	\_\_attribute\_\_((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)   static void \_\_attribute\_\_((constructor(RTE\_PRIO(prio)), used)) func(void)\
 \#define **RTE\_INIT**(func)   	**RTE\_INIT\_PRIO**(func, LAST)\
 \#define **RTE\_FINI\_PRIO**(func,  prio)   static void \_\_attribute\_\_((destructor(RTE\_PRIO(prio)), used)) func(void)\
 \#define **RTE\_FINI**(func)   	**RTE\_FINI\_PRIO**(func, LAST)\
 \#define **\_\_rte\_noreturn**   \_\_attribute\_\_((noreturn))\
 \#define **\_\_rte\_unreachable**()   \_\_assume(0)\
 \#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)   \_\_assume(condition)\
 \#define **\_\_rte\_no\_asan**\
 \#define **RTE\_PTR\_ADD**(ptr,  x)   ((void\*)((uintptr\_t)(ptr) + (x)))\
 \#define **RTE\_PTR\_SUB**(ptr,  x)   ((void \*)((uintptr\_t)(ptr) - (x)))\
 \#define **RTE\_PTR\_DIFF**(ptr1,  ptr2)   ((uintptr\_t)(ptr1) - (uintptr\_t)(ptr2))\
 \#define **RTE\_CAST\_FIELD**(var,  field,  type)   	(\*(type \*)((uintptr\_t)(var) + **offsetof**(typeof(\*(var)), field)))\
 \#define **RTE\_PTR\_ALIGN\_FLOOR**(ptr,  align)   	((typeof(ptr))**RTE\_ALIGN\_FLOOR**((uintptr\_t)(ptr), align))\
 \#define **RTE\_ALIGN\_FLOOR**(val,  align)   	(typeof(val))((val) & (~((typeof(val))((align) - 1))))\
 \#define **RTE\_PTR\_ALIGN\_CEIL**(ptr,  align)   	**RTE\_PTR\_ALIGN\_FLOOR**((typeof(ptr))**RTE\_PTR\_ADD**(ptr, (align) - 1), align)\
 \#define **RTE\_ALIGN\_CEIL**(val,  align)   	**RTE\_ALIGN\_FLOOR**(((val) + ((typeof(val)) (align) - 1)), align)\
 \#define **RTE\_PTR\_ALIGN**(ptr,  align)   **RTE\_PTR\_ALIGN\_CEIL**(ptr, align)\
 \#define **RTE\_ALIGN**(val,  align)   **RTE\_ALIGN\_CEIL**(val, align)\
 \#define **RTE\_ALIGN\_MUL\_CEIL**(v,  mul)   	((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) \* (typeof(v))(mul))\
 \#define **RTE\_ALIGN\_MUL\_FLOOR**(v,  mul)   	(((v) / ((typeof(v))(mul))) \* (typeof(v))(mul))\
 \#define **RTE\_ALIGN\_MUL\_NEAR**(v,  mul)\
 \#define **RTE\_BUILD\_BUG\_ON**(condition)   do { static\_assert(!(condition), #condition); } while (0)\
 \#define **RTE\_CACHE\_LINE\_MASK**   (RTE\_CACHE\_LINE\_SIZE-1)\
 \#define **RTE\_CACHE\_LINE\_ROUNDUP**(size)   **RTE\_ALIGN\_CEIL**(size, RTE\_CACHE\_LINE\_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(\_\_COUNTER\_\_)\
 \#define **RTE\_MIN**(a,  b)\
 \#define **RTE\_MIN\_T**(a,  b,  t)   	((t)(a) \< (t)(b) ? (t)(a) : (t)(b))\
 \#define **RTE\_MAX**(a,  b)\
 \#define **RTE\_MAX\_T**(a,  b,  t)   	((t)(a) \> (t)(b) ? (t)(a) : (t)(b))\
 \#define **offsetof**(TYPE,  MEMBER)   \_\_builtin\_offsetof (TYPE, MEMBER)\
 \#define **container\_of**(ptr,  type,  member)\
 \#define **RTE\_SWAP**(a,  b)\
 \#define **RTE\_SIZEOF\_FIELD**(type,  field)   (sizeof(((type \*)0)-\>field))\
 \#define **RTE\_STR**(x)   \_RTE\_STR(x)\
 \#define **RTE\_FMT**(fmt, ...)   fmt '%.0s', \_\_VA\_ARGS\_\_ ''\
 \#define **RTE\_LEN2MASK**(ln,  tp)   	((tp)((uint64\_t)-1 \>\> (sizeof(uint64\_t) \* CHAR\_BIT - (ln))))\
 \#define **RTE\_DIM**(a)   (sizeof (a) / sizeof ((a)\[0\]))\

### 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\_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.

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

## Macro Definition Documentation

### #define \_\_rte\_aligned(a) \_\_attribute\_\_((\_\_aligned\_\_(a)))

Force type alignment

This macro should be used when alignment of a struct or union type is required. For toolchain compatibility it should appear between the {struct,union} keyword and tag. e.g.

struct **\_\_rte\_aligned(8)** tag { ... };

If alignment of an object/variable is required then this macro should not be used, instead prefer C11 alignas(a).

Definition at line **89** of file **rte\_common.h**.

### \_\_extension\_\_ struct rte\_vxlan\_gpe\_hdr \_\_rte\_packed \_\_attribute\_\_((\_\_packed\_\_))

Force a structure to be packed

Definition at line **108** 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 **117** of file **rte\_common.h**.

### #define RTE\_DEPRECATED(x)

Macro to mark macros and defines scheduled for removal

Definition at line **137** of file **rte\_common.h**.

### #define \_\_rte\_weak \_\_attribute\_\_((\_\_weak\_\_))

Mark a function or variable to a weak reference.

Definition at line **143** of file **rte\_common.h**.

### #define \_\_rte\_pure \_\_attribute\_\_((pure))

Mark a function to be pure.

Definition at line **151** 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 **160** of file **rte\_common.h**.

### #define \_\_rte\_unused \_\_attribute\_\_((\_\_unused\_\_))

short definition to mark a function parameter unused

Definition at line **171** of file **rte\_common.h**.

### #define \_\_rte\_restrict \_\_restrict

Mark pointer as restricted with regard to pointer aliasing.

Definition at line **178** of file **rte\_common.h**.

### #define RTE\_SET\_USED(x) (void)(x)

definition to mark a variable or function parameter as used so as to avoid a compiler warning

Definition at line **187** of file **rte\_common.h**.

### #define \_\_rte\_format\_printf(format\_index, first\_arg) \_\_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 **203** of file **rte\_common.h**.

### #define \_\_rte\_section(name) \_\_attribute\_\_((section(name)))

Specify data or function section/segment.

Definition at line **215** 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 **228** 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 **241** 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 **251** 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 **262** of file **rte\_common.h**.

### #define RTE\_INIT\_PRIO(func, prio) 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 **284** of file **rte\_common.h**.

### #define RTE\_INIT(func) 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 **316** of file **rte\_common.h**.

### #define RTE\_FINI\_PRIO(func, prio) 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 **330** of file **rte\_common.h**.

### #define RTE\_FINI(func) 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 **357** of file **rte\_common.h**.

### #define \_\_rte\_noreturn \_\_attribute\_\_((noreturn))

Hint never returning function

Definition at line **366** of file **rte\_common.h**.

### #define \_\_rte\_unreachable() \_\_assume(0)

Hint point in program never reached

Definition at line **375** 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 **404** of file **rte\_common.h**.

### #define \_\_rte\_always\_inline inline \_\_attribute\_\_((always\_inline))

Force a function to be inlined

Definition at line **413** of file **rte\_common.h**.

### #define \_\_rte\_noinline \_\_attribute\_\_((noinline))

Force a function to be noinlined

Definition at line **419** of file **rte\_common.h**.

### #define \_\_rte\_hot \_\_attribute\_\_((hot))

Hint function in the hot path

Definition at line **424** of file **rte\_common.h**.

### #define \_\_rte\_cold \_\_attribute\_\_((cold))

Hint function in the cold path

Definition at line **432** of file **rte\_common.h**.

### #define \_\_rte\_assume(condition) \_\_assume(condition)

Hint precondition

**Warning**

Depending on the compiler, any code in `condition` might be executed. This currently only occurs with GCC prior to version 13.

Definition at line **448** of file **rte\_common.h**.

### #define \_\_rte\_no\_asan

Disable AddressSanitizer on some code

Definition at line **461** of file **rte\_common.h**.

### #define RTE\_PTR\_ADD(ptr, x) ((void\*)((uintptr\_t)(ptr) + (x)))

add a byte-value offset to a pointer

Definition at line **469** of file **rte\_common.h**.

### #define RTE\_PTR\_SUB(ptr, x) ((void \*)((uintptr\_t)(ptr) - (x)))

subtract a byte-value offset from a pointer

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

### #define RTE\_PTR\_DIFF(ptr1, ptr2) ((uintptr\_t)(ptr1) - (uintptr\_t)(ptr2))

get the difference between two pointer values, i.e. how far apart in bytes are the locations they point two. It is assumed that ptr1 is greater than ptr2.

Definition at line **481** of file **rte\_common.h**.

### #define RTE\_CAST\_FIELD(var, field, type) (\*(type \*)((uintptr\_t)(var) + offsetof(typeof(\*(var)), field)))

Workaround to cast a const field of a structure to non-const type.

Definition at line **486** of file **rte\_common.h**.

### #define RTE\_PTR\_ALIGN\_FLOOR(ptr, align) ((typeof(ptr))RTE\_ALIGN\_FLOOR((uintptr\_t)(ptr), align))

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no higher than the first parameter. Second parameter must be a power-of-two value.

Definition at line **498** of file **rte\_common.h**.

### #define RTE\_ALIGN\_FLOOR(val, align) (typeof(val))((val) & (~((typeof(val))((align) - 1))))

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no bigger than the first parameter. Second parameter must be a power-of-two value.

Definition at line **507** of file **rte\_common.h**.

### #define RTE\_PTR\_ALIGN\_CEIL(ptr, align) RTE\_PTR\_ALIGN\_FLOOR((typeof(ptr))RTE\_PTR\_ADD(ptr, (align) - 1), align)

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no lower than the first parameter. Second parameter must be a power-of-two value.

Definition at line **516** of file **rte\_common.h**.

### #define RTE\_ALIGN\_CEIL(val, align) RTE\_ALIGN\_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value.

Definition at line **525** of file **rte\_common.h**.

### #define RTE\_PTR\_ALIGN(ptr, align) RTE\_PTR\_ALIGN\_CEIL(ptr, align)

Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as the first parameter, and point to an address no lower than the first parameter. Second parameter must be a power-of-two value. This function is the same as RTE\_PTR\_ALIGN\_CEIL

Definition at line **535** of file **rte\_common.h**.

### #define RTE\_ALIGN(val, align) RTE\_ALIGN\_CEIL(val, align)

Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value. This function is the same as RTE\_ALIGN\_CEIL

Definition at line **544** of file **rte\_common.h**.

### #define RTE\_ALIGN\_MUL\_CEIL(v, mul) ((((v) + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) \* (typeof(v))(mul))

Macro to align a value to the multiple of given value. The resultant value will be of the same type as the first parameter and will be no lower than the first parameter.

Definition at line **551** of file **rte\_common.h**.

### #define RTE\_ALIGN\_MUL\_FLOOR(v, mul) (((v) / ((typeof(v))(mul))) \* (typeof(v))(mul))

Macro to align a value to the multiple of given value. The resultant value will be of the same type as the first parameter and will be no higher than the first parameter.

Definition at line **559** of file **rte\_common.h**.

### #define RTE\_ALIGN\_MUL\_NEAR(v, mul)

**Value:**.PP

```
    __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;  \
    })
```

Macro to align value to the nearest multiple of the given value. The resultant value might be greater than or less than the first parameter whichever difference is the lowest.

Definition at line **567** of file **rte\_common.h**.

### #define RTE\_BUILD\_BUG\_ON(condition) do { static\_assert(!(condition), #condition); } while (0)

Triggers an error at compilation time if the condition is true.

The do { } while(0) exists to workaround a bug in clang (#55821) where it would not handle \_Static\_assert in a switch case.

Definition at line **604** of file **rte\_common.h**.

### #define RTE\_CACHE\_LINE\_MASK (RTE\_CACHE\_LINE\_SIZE-1)

Cache line mask.

Definition at line **609** of file **rte\_common.h**.

### #define RTE\_CACHE\_LINE\_ROUNDUP(size) RTE\_ALIGN\_CEIL(size, RTE\_CACHE\_LINE\_SIZE)

Return the first cache-aligned value greater or equal to size.

Definition at line **612** of file **rte\_common.h**.

### #define RTE\_CACHE\_LINE\_MIN\_SIZE 64

Cache line size in terms of log2 Minimum Cache line size.

Definition at line **624** of file **rte\_common.h**.

### #define \_\_rte\_cache\_aligned \_\_rte\_aligned(RTE\_CACHE\_LINE\_SIZE)

Force alignment to cache line.

Definition at line **627** of file **rte\_common.h**.

### #define \_\_rte\_cache\_min\_aligned \_\_rte\_aligned(RTE\_CACHE\_LINE\_MIN\_SIZE)

Force minimum cache line alignment.

Definition at line **630** of file **rte\_common.h**.

### #define RTE\_CACHE\_GUARD \_RTE\_CACHE\_GUARD\_HELPER1(\_\_COUNTER\_\_)

Empty cache lines, to guard against false sharing-like effects on systems with a next-N-lines hardware prefetcher.

Use as spacing between data accessed by different lcores, to prevent cache thrashing on hardware with speculative prefetching.

Definition at line **643** of file **rte\_common.h**.

### #define RTE\_MIN(a, b)

**Value:**.PP

```
    __extension__ ({ \
        typeof (a) _a = (a); \
        typeof (b) _b = (b); \
        _a < _b ? _a : _b; \
    })
```

Macro to return the minimum of two numbers

Definition at line **683** of file **rte\_common.h**.

### #define RTE\_MIN\_T(a, b, t) ((t)(a) \< (t)(b) ? (t)(a) : (t)(b))

Macro to return the minimum of two numbers

As opposed to RTE\_MIN, it does not use temporary variables so it is not safe if a or b is an expression. Yet it is guaranteed to be constant for use in static\_assert().

Definition at line **697** of file **rte\_common.h**.

### #define RTE\_MAX(a, b)

**Value:**.PP

```
    __extension__ ({ \
        typeof (a) _a = (a); \
        typeof (b) _b = (b); \
        _a > _b ? _a : _b; \
    })
```

Macro to return the maximum of two numbers

Definition at line **703** of file **rte\_common.h**.

### #define RTE\_MAX\_T(a, b, t) ((t)(a) \> (t)(b) ? (t)(a) : (t)(b))

Macro to return the maximum of two numbers

As opposed to RTE\_MAX, it does not use temporary variables so it is not safe if a or b is an expression. Yet it is guaranteed to be constant for use in static\_assert().

Definition at line **717** of file **rte\_common.h**.

### #define offsetof(TYPE, MEMBER) \_\_builtin\_offsetof (TYPE, MEMBER)

Return the offset of a field in a structure.

Definition at line **724** of file **rte\_common.h**.

### #define container\_of(ptr, type, member)

**Value:**.PP

```
            __extension__ ({        \
            const typeof(((type *)0)->member) *_ptr = (ptr); \
            __rte_unused type *_target_ptr =    \
                (type *)(ptr);              \
            (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
        })
```

Return pointer to the wrapping struct instance.

Example:

struct wrapper { ... struct child c; ... };

struct child \*x = obtain(...); struct wrapper \*w = **container\_of(x, struct wrapper, c)**;

Definition at line **746** of file **rte\_common.h**.

### #define RTE\_SWAP(a, b)

**Value:**.PP

```
    __extension__ ({ \
        typeof (a) _a = a; \
        a = b; \
        b = _a; \
    })
```

Swap two variables.

Definition at line **756** of file **rte\_common.h**.

### #define RTE\_SIZEOF\_FIELD(type, field) (sizeof(((type \*)0)-\>field))

Get 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 **773** of file **rte\_common.h**.

### #define RTE\_STR(x) \_RTE\_STR(x)

Take a macro value and get a string version of it

Definition at line **777** of file **rte\_common.h**.

### #define RTE\_FMT(fmt, ...) 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 **784** of file **rte\_common.h**.

### #define RTE\_LEN2MASK(ln, tp) ((tp)((uint64\_t)-1 \>\> (sizeof(uint64\_t) \* CHAR\_BIT - (ln))))

Mask value of type 'tp' for the first 'ln' bit set.

Definition at line **789** of file **rte\_common.h**.

### #define RTE\_DIM(a) (sizeof (a) / sizeof ((a)\[0\]))

Number of elements in the array.

Definition at line **793** of file **rte\_common.h**.

## Typedef Documentation

### typedef uint64\_t phys\_addr\_t

Physical address

Definition at line **648** of file **rte\_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 **658** of file **rte\_common.h**.

## Function Documentation

### static 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 checked \
 *align* The power-of-two value to which the ptr should be aligned

**Returns**

True(1) where the pointer is correctly aligned, false(0) otherwise

Definition at line **586** of file **rte\_common.h**.

### 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\_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 application \
 *format* 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 **666** of file **rte\_common.h**.

### \_\_extension\_\_ typedef uint8\_t RTE\_MARKER8\[0\]

Marker for 1B alignment in a structure.

Definition at line **668** of file **rte\_common.h**.

### \_\_extension\_\_ typedef uint16\_t RTE\_MARKER16\[0\]

Marker for 2B alignment in a structure.

Definition at line **670** of file **rte\_common.h**.

### \_\_extension\_\_ typedef uint32\_t RTE\_MARKER32\[0\]

Marker for 4B alignment in a structure.

Definition at line **672** of file **rte\_common.h**.

### \_\_extension\_\_ typedef uint64\_t RTE\_MARKER64\[0\]

Marker for 8B alignment in a structure.

Definition at line **674** of file **rte\_common.h**.

## Author

Generated automatically by Doxygen for DPDK from the source code.
