* @file
*
* Generic, commonly-used macro and inline function definitions
- * for Intel DPDK.
+ * for DPDK.
*/
#ifdef __cplusplus
#define asm __asm__
#endif
+#ifdef RTE_ARCH_STRICT_ALIGN
+typedef uint64_t unaligned_uint64_t __attribute__ ((aligned(1)));
+typedef uint32_t unaligned_uint32_t __attribute__ ((aligned(1)));
+typedef uint16_t unaligned_uint16_t __attribute__ ((aligned(1)));
+#else
+typedef uint64_t unaligned_uint64_t;
+typedef uint32_t unaligned_uint32_t;
+typedef uint16_t unaligned_uint16_t;
+#endif
+
+/**
+ * Force alignment
+ */
+#define __rte_aligned(a) __attribute__((__aligned__(a)))
+
+/**
+ * Force a structure to be packed
+ */
+#define __rte_packed __attribute__((__packed__))
+
+/******* Macro to mark functions and fields scheduled for removal *****/
+#define __rte_deprecated __attribute__((__deprecated__))
+
/*********** Macros to eliminate unused variable warnings ********/
/**
/*********** Macros/static functions for doing alignment ********/
-/**
- * Function which rounds an unsigned int down to a given power-of-two value.
- * Takes uintptr_t types as parameters, as this type of operation is most
- * commonly done for pointer alignment. (See also RTE_ALIGN_FLOOR,
- * RTE_ALIGN_CEIL, RTE_ALIGN, RTE_PTR_ALIGN_FLOOR, RTE_PTR_ALIGN_CEL,
- * RTE_PTR_ALIGN macros)
- * @param ptr
- * The value to be rounded down
- * @param align
- * The power-of-two of which the result must be a multiple.
- * @return
- * Function returns a properly aligned value where align is a power-of-two.
- * If align is not a power-of-two, result will be incorrect.
- */
-static inline uintptr_t
-rte_align_floor_int(uintptr_t ptr, uintptr_t align)
-{
- return (ptr & ~(align - 1));
-}
/**
* Macro to align a pointer to a given power-of-two. The resultant
* must be a power-of-two value.
*/
#define RTE_PTR_ALIGN_FLOOR(ptr, align) \
- (typeof(ptr))rte_align_floor_int((uintptr_t)ptr, align)
+ ((typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align))
/**
* Macro to align a value to a given power-of-two. The resultant value
/**
* Aligns 64b input parameter to the next power of 2
*
- * @param x
- * The 64b value to algin
+ * @param v
+ * The 64b value to align
*
* @return
* Input parameter aligned to the next power of 2
/**
* Macro to return the minimum of two numbers
*/
-#define RTE_MIN(a, b) ({ \
+#define RTE_MIN(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a < _b ? _a : _b; \
/**
* Macro to return the maximum of two numbers
*/
-#define RTE_MAX(a, b) ({ \
+#define RTE_MAX(a, b) \
+ __extension__ ({ \
typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; \
static inline uint32_t
rte_bsf32(uint32_t v)
{
- return (__builtin_ctz(v));
+ return __builtin_ctz(v);
}
#ifndef offsetof
/** Take a macro value and get a string version of it */
#define RTE_STR(x) _RTE_STR(x)
-/** Mask value of type <tp> for the first <ln> bit set. */
+/** Mask value of type "tp" for the first "ln" bit set. */
#define RTE_LEN2MASK(ln, tp) \
((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln))))