vppinfra: add FOREACH_ARRAY_ELT macro

Type: improvement
Change-Id: Iac1b3a66176c9a38a161246159140f30a1c168da
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2023-03-16 16:34:30 +00:00
committed by Florin Coras
parent f39485ff6a
commit f8b61fb538
2 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,7 @@ ForEachMacros:
- 'vlib_foreach_rx_tx'
- 'foreach_vlib_main'
- 'foreach_set_bit_index'
- 'FOREACH_ARRAY_ELT'
- 'RTE_ETH_FOREACH_DEV'
StatementMacros:

View File

@ -74,6 +74,8 @@
#define BITS(x) (8*sizeof(x))
#define ARRAY_LEN(x) (sizeof (x)/sizeof (x[0]))
#define FOREACH_ARRAY_ELT(a, b) \
for (typeof ((b)[0]) *(a) = (b); (a) - (b) < ARRAY_LEN (b); (a)++)
#define _STRUCT_FIELD(t,f) (((t *) 0)->f)
#define STRUCT_OFFSET_OF(t,f) offsetof(t, f)