[PATCH v4] eventdev: ensure 16-byte alignment for events

Stephen Hemminger stephen at networkplumber.org
Mon Nov 13 00:31:46 CET 2023


On Sun, 12 Nov 2023 09:30:24 +0100
Morten Brørup <mb at smartsharesystems.com> wrote:

> > > +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.

If you look at my RFC, the message is just as good as the one in this code.
It ends up being stringified version of the expression. Which is more exact than the wording used in some other places.


More information about the dev mailing list