summaryrefslogtreecommitdiffstats
path: root/src/vlib/threads.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 11:38:01 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:35:22 +0100
commit92ccf9bcd2692b4b415f31044560c735d639a35c (patch)
treef5308e25329d6853921b7ea4a74d5c3b6f149b25 /src/vlib/threads.h
parentfd8deb48c7ad63b47c5d7465ceefcadef0316f93 (diff)
vlib: convert foreach_vlib_main macro to be more gdb and clang-format friendly
Type: improvement Change-Id: I1152e58d7bfcb3c4347147f87a834d45ad51cdfe Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/threads.h')
-rw-r--r--src/vlib/threads.h33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index d715ebfff58..28a81f78712 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -237,29 +237,16 @@ typedef enum
void vlib_worker_thread_fork_fixup (vlib_fork_fixup_t which);
-#define foreach_vlib_main(body) \
- do \
- { \
- vlib_main_t **__vlib_mains = 0, *this_vlib_main; \
- int ii; \
- \
- for (ii = 0; ii < vec_len (vlib_global_main.vlib_mains); ii++) \
- { \
- this_vlib_main = vlib_global_main.vlib_mains[ii]; \
- ASSERT (ii == 0 || this_vlib_main->parked_at_barrier == 1); \
- if (this_vlib_main) \
- vec_add1 (__vlib_mains, this_vlib_main); \
- } \
- \
- for (ii = 0; ii < vec_len (__vlib_mains); ii++) \
- { \
- this_vlib_main = __vlib_mains[ii]; \
- /* body uses this_vlib_main... */ \
- (body); \
- } \
- vec_free (__vlib_mains); \
- } \
- while (0);
+#define foreach_vlib_main() \
+ for (vlib_main_t *ii = 0, *this_vlib_main = vlib_global_main.vlib_mains[0]; \
+ (ii - (vlib_main_t *) 0) < vec_len (vlib_global_main.vlib_mains); \
+ ii++, this_vlib_main = \
+ vlib_global_main.vlib_mains[ii - (vlib_main_t *) 0]) \
+ if (CLIB_ASSERT_ENABLE && \
+ !(ii == 0 || \
+ (this_vlib_main && this_vlib_main->parked_at_barrier == 1))) \
+ ASSERT (0); \
+ else if (this_vlib_main)
#define foreach_sched_policy \
_(SCHED_OTHER, OTHER, "other") \