diff options
-rw-r--r-- | .clang-format | 1 | ||||
-rw-r--r-- | src/vppinfra/types.h | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format index 050505b168b..03568413bf8 100644 --- a/.clang-format +++ b/.clang-format @@ -20,6 +20,7 @@ ForEachMacros: - 'vec_foreach_index_backwards' - 'vec_foreach_pointer' - 'vlib_foreach_rx_tx' + - 'foreach_int' - 'foreach_vlib_main' - 'foreach_set_bit_index' - 'foreach_vlib_frame_bitmap_set_bit_index' diff --git a/src/vppinfra/types.h b/src/vppinfra/types.h index a3fbfcc845b..42217968dcc 100644 --- a/src/vppinfra/types.h +++ b/src/vppinfra/types.h @@ -196,6 +196,12 @@ typedef i64 i64u __attribute__ ((aligned (1), __may_alias__)); typedef word wordu __attribute__ ((aligned (1), __may_alias__)); typedef uword uwordu __attribute__ ((aligned (1), __may_alias__)); +#define foreach_int(__var, ...) \ + for (int __int_array[] = { __VA_ARGS__ }, *__int_ptr = __int_array, \ + __var = *__int_ptr; \ + __int_ptr - ARRAY_LEN (__int_array) < __int_array; \ + __var = *++__int_ptr) + #endif /* included_clib_types_h */ /* |