#include <rte_debug.h>
#include <rte_compat.h>
+/**
+ * Get the uint64_t value for a specified bit set.
+ *
+ * @param nr
+ * The bit number in range of 0 to 63.
+ */
+#define RTE_BIT64(nr) (UINT64_C(1) << (nr))
+
+/**
+ * Get the uint32_t value for a specified bit set.
+ *
+ * @param nr
+ * The bit number in range of 0 to 31.
+ */
+#define RTE_BIT32(nr) (UINT32_C(1) << (nr))
+
/*------------------------ 32-bit relaxed operations ------------------------*/
/**
{
RTE_ASSERT(nr < 32);
- uint32_t mask = UINT32_C(1) << nr;
+ uint32_t mask = RTE_BIT32(nr);
*addr = (*addr) | mask;
}
{
RTE_ASSERT(nr < 32);
- uint32_t mask = UINT32_C(1) << nr;
+ uint32_t mask = RTE_BIT32(nr);
*addr = (*addr) & (~mask);
}
{
RTE_ASSERT(nr < 32);
- uint32_t mask = UINT32_C(1) << nr;
+ uint32_t mask = RTE_BIT32(nr);
uint32_t val = *addr;
*addr = val | mask;
return val & mask;
{
RTE_ASSERT(nr < 32);
- uint32_t mask = UINT32_C(1) << nr;
+ uint32_t mask = RTE_BIT32(nr);
uint32_t val = *addr;
*addr = val & (~mask);
return val & mask;
{
RTE_ASSERT(nr < 64);
- uint64_t mask = UINT64_C(1) << nr;
+ uint64_t mask = RTE_BIT64(nr);
return (*addr) & mask;
}
{
RTE_ASSERT(nr < 64);
- uint64_t mask = UINT64_C(1) << nr;
+ uint64_t mask = RTE_BIT64(nr);
(*addr) = (*addr) | mask;
}
{
RTE_ASSERT(nr < 64);
- uint64_t mask = UINT64_C(1) << nr;
+ uint64_t mask = RTE_BIT64(nr);
*addr = (*addr) & (~mask);
}
{
RTE_ASSERT(nr < 64);
- uint64_t mask = UINT64_C(1) << nr;
+ uint64_t mask = RTE_BIT64(nr);
uint64_t val = *addr;
*addr = val | mask;
return val;
{
RTE_ASSERT(nr < 64);
- uint64_t mask = UINT64_C(1) << nr;
+ uint64_t mask = RTE_BIT64(nr);
uint64_t val = *addr;
*addr = val & (~mask);
return val & mask;