Lines Matching +full:input +full:- +full:value

1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2019 Intel Corporation
11 * Generic, commonly-used macro and inline function definitions
107 * Check format string and its arguments at compile-time.
109 * GCC on Windows assumes MS-specific format string by default,
110 * even if the underlying stdio implementation is ANSI-compliant,
207 * add a byte-value offset to a pointer
212 * subtract a byte-value offset from a pointer
214 #define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x)))
221 #define RTE_PTR_DIFF(ptr1, ptr2) ((uintptr_t)(ptr1) - (uintptr_t)(ptr2))
224 * Workaround to cast a const field of a structure to non-const type.
233 * Macro to align a pointer to a given power-of-two. The resultant
236 * must be a power-of-two value.
242 * Macro to align a value to a given power-of-two. The resultant value
245 * power-of-two value.
248 (typeof(val))((val) & (~((typeof(val))((align) - 1))))
251 * Macro to align a pointer to a given power-of-two. The resultant
254 * must be a power-of-two value.
257 RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, (align) - 1), align)
260 * Macro to align a value to a given power-of-two. The resultant value
262 * than the first parameter. Second parameter must be a power-of-two
263 * value.
266 RTE_ALIGN_FLOOR(((val) + ((typeof(val)) (align) - 1)), align)
269 * Macro to align a pointer to a given power-of-two. The resultant
272 * must be a power-of-two value.
278 * Macro to align a value to a given power-of-two. The resultant
279 * value will be of the same type as the first parameter, and
281 * must be a power-of-two value.
287 * Macro to align a value to the multiple of given value. The resultant
288 * value will be of the same type as the first parameter and will be no lower
292 (((v + (typeof(v))(mul) - 1) / ((typeof(v))(mul))) * (typeof(v))(mul))
295 * Macro to align a value to the multiple of given value. The resultant
296 * value will be of the same type as the first parameter and will be no higher
303 * Macro to align value to the nearest multiple of the given value.
304 * The resultant value might be greater than or less than the first parameter
311 (ceil - v) > (v - floor) ? floor : ceil; \
315 * Checks if a pointer is aligned to a given power-of-two value
320 * The power-of-two value to which the ptr should be aligned
336 #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
341 #define RTE_CACHE_LINE_MASK (RTE_CACHE_LINE_SIZE-1)
343 /** Return the first cache-aligned value greater or equal to size. */
345 (RTE_CACHE_LINE_SIZE * ((size + RTE_CACHE_LINE_SIZE - 1) / \
370 #define RTE_BAD_PHYS_ADDR ((phys_addr_t)-1)
376 * is a direct mapping, i.e. the same value.
380 #define RTE_BAD_IOVA ((rte_iova_t)-1)
397 * significant bits to construct a value with the same MSBs as x
403 * The combined value.
419 * significant bits to construct a value with the same MSBs as x
425 * The combined value.
445 #define RTE_IS_POWER_OF_2(n) ((n) && !(((n) - 1) & (n)))
456 return n && !(n & (n - 1)); in rte_is_power_of_2()
460 * Aligns input parameter to the next power of 2
463 * The integer value to align
466 * Input parameter aligned to the next power of 2
471 x--; in rte_align32pow2()
478 * Aligns input parameter to the previous power of 2
481 * The integer value to align
484 * Input parameter aligned to the previous power of 2
491 return x - (x >> 1); in rte_align32prevpow2()
495 * Aligns 64b input parameter to the next power of 2
498 * The 64b value to align
501 * Input parameter aligned to the next power of 2
506 v--; in rte_align64pow2()
513 * Aligns 64b input parameter to the previous power of 2
516 * The 64b value to align
519 * Input parameter aligned to the previous power of 2
526 return v - (v >> 1); in rte_align64prevpow2()
554 * Searches the input parameter for the least significant set bit
557 * If the content of the input parameter is zero, then the content of the return
558 * value is undefined.
560 * input parameter, should not be zero.
562 * least significant set bit in the input parameter.
571 * Searches the input parameter for the least significant set bit
572 * (starting from zero). Safe version (checks for input parameter being zero).
577 * The input parameter.
579 * If ``v`` was not 0, this value will contain position of least significant
580 * bit within the input parameter.
595 * Return the rounded-up log2 of a integer.
598 * rte_log2_u32(0) == 0 and not -inf.
601 * The input parameter.
603 * The rounded-up log2 of the input, or 0 if the input is 0.
616 * Return the last (most-significant) bit set.
622 * The input parameter.
624 * The last (most-significant) bit set, or 0 if the input is 0.
629 return (x == 0) ? 0 : 32 - __builtin_clz(x); in rte_fls_u32()
633 * Searches the input parameter for the least significant set bit
636 * If the content of the input parameter is zero, then the content of the return
637 * value is undefined.
639 * input parameter, should not be zero.
641 * least significant set bit in the input parameter.
650 * Searches the input parameter for the least significant set bit
651 * (starting from zero). Safe version (checks for input parameter being zero).
656 * The input parameter.
658 * If ``v`` was not 0, this value will contain position of least significant
659 * bit within the input parameter.
674 * Return the last (most-significant) bit set.
681 * The input parameter.
683 * The last (most-significant) bit set, or 0 if the input is 0.
688 return (x == 0) ? 0 : 64 - __builtin_clzll(x); in rte_fls_u64()
692 * Return the rounded-up log2 of a 64-bit integer.
695 * rte_log2_u64(0) == 0 and not -inf.
698 * The input parameter.
700 * The rounded-up log2 of the input, or 0 if the input is 0.
733 const typeof(((type *)0)->member) *_ptr = (ptr); \
736 (type *)(((uintptr_t)_ptr) - offsetof(type, member)); \
750 #define RTE_SIZEOF_FIELD(type, field) (sizeof(((type *)0)->field))
753 /** Take a macro value and get a string version of it */
765 /** Mask value of type "tp" for the first "ln" bit set. */
767 ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))
773 * Converts a numeric string to the equivalent uint64_t value.
777 * If a negative number is passed in i.e. a string with the first non-black
778 * character being "-", zero is returned. Zero is also returned in the case of
795 if (*str == '-')
807 case 'G': case 'g': size *= 1024; /* fall-through */
808 case 'M': case 'm': size *= 1024; /* fall-through */
809 case 'K': case 'k': size *= 1024; /* fall-through */