On Wed, 16 Sep 2026 13:18:09 +0100
Anatoly Burakov <[email protected]> wrote:

> +/*
> + * Simplistic reference counter. Not thread-safe, not atomic.
> + */
> +struct ci_refcount {
> +     uint32_t count;
> +};
> +
> +/**
> + * Take a reference. Returns true if this is the first reference.
> + *
> + * @param ref
> + *   Reference count to acquire.
> + * @return
> + *   true if this is the first reference, false otherwise.
> + */
> +static inline bool
> +ci_refcount_acquire(struct ci_refcount *ref)
> +{
> +#ifdef CI_DEBUG
> +     if (ref->count == UINT32_MAX)
> +             rte_panic("ci_refcount overflow\n");
> +#endif
> +     return ref->count++ == 0;
> +}
> +

Would it help if EAL has a generic refcount?
I would make the refcount overflow/underflow still fatal, should never happen.

Reply via email to