[PATCH v2 5/5] vhost: enhance virtqueue access lock asserts
David Marchand
david.marchand at redhat.com
Mon Feb 26 16:46:49 CET 2024
On Mon, Feb 19, 2024 at 11:52 AM Thomas Monjalon <thomas at monjalon.net> wrote:
>
> 05/12/2023 10:45, David Marchand:
> > +#define VHOST_USER_ASSERT_LOCK(dev, vq, id) do { \
> > + RTE_BUILD_BUG_ON(!vhost_message_handlers[id].lock_all_qps); \
> > + vq_assert_lock(dev, vq); \
> > +} while (0)
>
> Since "eal: enhance compile-time checks using C11 assert",
> it is not allowed to have non-constant check in RTE_BUILD_BUG_ON:
>
> lib/vhost/vhost_user.c:413:25: note: in expansion of macro 'VHOST_USER_ASSERT_LOCK'
> lib/vhost/vhost_user.c: In function 'vhost_user_set_vring_addr':
> lib/eal/include/rte_common.h:518:56: error: expression in static assertion is not constant
> #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0)
>
> I suppose we can make this check at compile-time with few adjustments.
> For -rc1, I am dropping this patch.
Iiuc, an array content is not constant (from a compiler pov) unless
the elements are integers.
I suspect there is some gcc-specific implementation that could work,
since with the previous implementation of RTE_BUILD_BUG_ON, this check
was working with both gcc and clang...
But I could not find how to.
I have an alternate solution using enums with the existing macros..
I'll post a new revision.
--
David Marchand
More information about the dev
mailing list