On Mon,  9 Mar 2020 17:54:05 +0800
Joyce Kong <joyce.k...@arm.com> wrote:

> /**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
> + *
> + * Return the original bit from a 64-bit value, then clear it to 0 without
> + * memory ordering.
> + *
> + * @param nr
> + *   The target bit to get and clear.
> + * @param addr
> + *   The address holding the bit.
> + * @return
> + *   The original bit.
> + */
> +__rte_experimental
> +static inline uint64_t
> +rte_test_and_clear_bit64_relaxed(unsigned int nr, volatile uint64_t *addr)
> +{
> +     RTE_ASSERT(nr < 64);
> +
> +     uint64_t mask = UINT64_C(1) << nr;
> +     uint64_t val = *addr;
> +     *addr = (*addr) & (~mask);
> +     return val & mask;
> +}
> +

This is not thread safe. You should use the existing GCC builtins.

Reply via email to