[dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs
Stephen Hemminger
stephen at networkplumber.org
Sat Dec 21 19:08:56 CET 2019
On Sat, 21 Dec 2019 16:07:23 +0000
Honnappa Nagarahalli <Honnappa.Nagarahalli at arm.com> wrote:
> Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro:
>
> #define RTE_GET_BIT(nr, var, ret, memorder) \
> ({ \
> if (sizeof(var) == sizeof(uint32_t)) { \
> uint32_t mask1 = 1U << (nr)%32; \
> ret = __atomic_load_n(&var, (memorder)) & mask1;\
> } \
> else {\
> uint64_t mask2 = 1UL << (nr)%64;\
> ret = __atomic_load_n(&var, (memorder)) & mask2;\
> } \
> })
Follow on if you want to do it as macros, then use typeof() to make the
mask any size.
More information about the dev
mailing list