> From: Bruce Richardson [mailto:[email protected]] > Sent: Friday, 6 October 2023 12.17 ev: ensure 16-byte alignment for events > > On Fri, Oct 06, 2023 at 12:13:54PM +0200, Morten Brørup wrote: > > > From: Bruce Richardson [mailto:[email protected]] > > > Sent: Friday, 6 October 2023 11.45 > > > > > > The event structure in DPDK is 16-bytes in size, and events are > > > regularly passed as parameters directly rather than being passed as > > > pointers. To help compiler optimize correctly, we can explicitly request > > > 16-byte alignment for events, which means that we should be able > > > to do aligned vector loads/stores (e.g. with SSE or Neon) when working > > > with those events. > > > > > > Signed-off-by: Bruce Richardson <[email protected]> > > > Acked-by: Morten Brørup <[email protected]> > > > Acked-by: Jerin Jacob <[email protected]> > > > > > > --- > > > > [...] > > > > > +_Static_assert(sizeof(struct rte_event) == 16, "Event structure size is > not 16-bytes in size"); > > > > Thank you for adding this extra check. We should have more of these. > > > > NB: _Static_assert is deprecated in C23 [1], so for forward compatibility, > you could use static_assert (which is available in <assert.h>) instead. Nice > to have; feel free to ignore this comment. > > > Is the availability in assert.h backward compatible with C11, since the > link you posted seems to imply that "static_assert" is only from C23 > onwards?
Yes, the link mentions "static_assert" being available for C11 as a convenience macro in assert.h. I had to read the link very carefully to get this. I guess I'm not the only one. :-) I don't object to moving it to the .c file. However, I think it's convenient for readability to have the static_assert close to the thing it checks, and/or close to any code that relies on the assumption it checks.

