[dpdk-dev] [PATCH v1 1/5] lib/eal: implement the family of rte bit operation APIs
Stephen Hemminger
stephen at networkplumber.org
Tue Oct 15 18:53:32 CEST 2019
On Tue, 15 Oct 2019 15:49:57 +0800
Joyce Kong <joyce.kong at arm.com> wrote:
> +static inline void
> +rte_set_bit(unsigned int nr, unsigned long *addr)
> +{
> + __atomic_fetch_or(addr, (1UL << nr), __ATOMIC_ACQ_REL);
> +}
> +
> +static inline void
> +rte_clear_bit(int nr, unsigned long *addr)
> +{
> + __atomic_fetch_and(addr, ~(1UL << nr), __ATOMIC_ACQ_REL);
> +}
> +
> +static inline int
> +rte_test_bit(int nr, unsigned long *addr)
> +{
> + int res;
> + rte_mb();
> + res = ((*addr) & (1UL << nr)) != 0;
> + rte_mb();
> +
> + return res;
> +}
> +
> +static inline int
> +rte_test_and_set_bit(int nr, unsigned long *addr)
> +{
> + unsigned long mask = (1UL << nr);
> +
> + return __atomic_fetch_or(addr, mask, __ATOMIC_ACQ_REL) & mask;
> +}
> +
> +static inline int
> +rte_test_and_clear_bit(int nr, unsigned long *addr)
> +{
> + unsigned long mask = (1UL << nr);
> +
> + return __atomic_fetch_and(addr, ~mask, __ATOMIC_ACQ_REL) & mask;
> +}
These functions need to be part of API, and have doxygen comments?
More information about the dev
mailing list