[PATCH v4] eventdev: ensure 16-byte alignment for events
Morten Brørup
mb at smartsharesystems.com
Sun Nov 12 09:30:24 CET 2023
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Sunday, 12 November 2023 01.01
>
> On Fri, 6 Oct 2023 11:29:32 +0100
> Bruce Richardson <bruce.richardson at intel.com> wrote:
>
> > diff --git a/lib/eventdev/rte_eventdev.c
> b/lib/eventdev/rte_eventdev.c
> > index 95373bbaad..adc9751cef 100644
> > --- a/lib/eventdev/rte_eventdev.c
> > +++ b/lib/eventdev/rte_eventdev.c
> > @@ -9,6 +9,7 @@
> > #include <errno.h>
> > #include <stdint.h>
> > #include <inttypes.h>
> > +#include <assert.h>
> >
> > #include <rte_string_fns.h>
> > #include <rte_log.h>
> > @@ -28,6 +29,8 @@
> > #include "eventdev_pmd.h"
> > #include "eventdev_trace.h"
> >
> > +static_assert(sizeof(struct rte_event) == 16, "Event structure size
> is not 16-bytes in size");
> > +
> > static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
>
> Please don't reinvent RTE_BUILD_BUG_ON().
> Instead fix that to be a static_assert()
I would say the opposite:
With our upgrade to the C11 standard, let's get rid of the RTE_BUILD_BUG_ON() workaround for the lack of static_assert() in older C standards.
Unfortunately, the static_assert(expression) variant without the "message" parameter, which would make our RTE_BUILD_BUG_ON() macro completely obsolete, requires C23. And I don't see how we can make this variant available with C11. So we probably have to wait until DPDK requires C23.
Until then, let's gradually phase out the DPDK-specific RTE_BUILD_BUG_ON() in favor of standard C's static_assert(), and live with the inconvenience of having to provide a message parameter for it.
Please also note that static_assert() can be used outside code blocks, which makes it handy for use in header files.
More information about the dev
mailing list