|
DPDK
2.0.0
|
#include <stdint.h>#include <stdlib.h>#include <ctype.h>#include <errno.h>#include <limits.h>Macros | |
| #define | __rte_unused __attribute__((__unused__)) |
| #define | RTE_SET_USED(x) (void)(x) |
| #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_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_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) |
| #define | RTE_MIN(a, b) |
| #define | RTE_MAX(a, b) |
| #define | offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) |
| #define | RTE_STR(x) _RTE_STR(x) |
| #define | RTE_LEN2MASK(ln, tp) ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln)))) |
| #define | RTE_DIM(a) (sizeof (a) / sizeof ((a)[0])) |
Functions | |
| static int | rte_is_aligned (void *ptr, unsigned align) |
| static int | rte_is_power_of_2 (uint32_t n) |
| static uint32_t | rte_align32pow2 (uint32_t x) |
| static uint64_t | rte_align64pow2 (uint64_t v) |
| static uint32_t | rte_bsf32 (uint32_t v) |
| static uint64_t | rte_str_to_size (const char *str) |
| void | rte_exit (int exit_code, const char *format,...) |
Generic, commonly-used macro and inline function definitions for Intel DPDK.
| #define __rte_unused __attribute__((__unused__)) |
short definition to mark a function parameter unused
| #define offsetof | ( | TYPE, | |
| MEMBER | |||
| ) | __builtin_offsetof (TYPE, MEMBER) |
Return the offset of a field in a structure.
| #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
| #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.
| #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.
| #define RTE_BUILD_BUG_ON | ( | condition | ) | ((void)sizeof(char[1 - 2*!!(condition)])) |
Triggers an error at compilation time if the condition is true.
| #define RTE_DIM | ( | a | ) | (sizeof (a) / sizeof ((a)[0])) |
Number of elements in the array.
| #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.
| #define RTE_MAX | ( | a, | |
| b | |||
| ) |
Macro to return the maximum of two numbers
| #define RTE_MIN | ( | a, | |
| b | |||
| ) |
Macro to return the minimum of two numbers
| #define RTE_PTR_ADD | ( | ptr, | |
| x | |||
| ) | ((void*)((uintptr_t)(ptr) + (x))) |
add a byte-value offset from a pointer
| #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
| #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.
| #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.
| #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.
| #define RTE_PTR_SUB | ( | ptr, | |
| x | |||
| ) | ((void*)((uintptr_t)ptr - (x))) |
subtract a byte-value offset from a pointer
| #define RTE_SET_USED | ( | x | ) | (void)(x) |
definition to mark a variable or function parameter as used so as to avoid a compiler warning
| #define RTE_STR | ( | x | ) | _RTE_STR(x) |
Take a macro value and get a string version of it
|
inlinestatic |
Aligns input parameter to the next power of 2
| x | The integer value to algin |
|
inlinestatic |
Aligns 64b input parameter to the next power of 2
| x | The 64b value to algin |
|
inlinestatic |
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.
| v | input parameter, should not be zero. |
| 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
| 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. |
|
inlinestatic |
Checks if a pointer is aligned to a given power-of-two value
| ptr | The pointer whose alignment is to be checked |
| align | The power-of-two value to which the ptr should be aligned |
|
inlinestatic |
Returns true if n is a power of 2
| n | Number to check |
|
inlinestatic |
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.
| str | String containing number to convert. |
1.8.1.2