summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-12-13 21:47:40 +0100
committerDave Barach <openvpp@barachs.net>2020-12-14 12:14:21 +0000
commitb2c31b685fd2cf28436ca32bc93e23eb24c74878 (patch)
treedc0a1b1ff784445b2cbb0f9b2c07b5bcb4f5a5d0 /src/vppinfra
parent62c25abaa3e93be5815172d391295a6ab0390122 (diff)
misc: move to new pool_foreach macros
Type: refactor Change-Id: Ie67dc579e88132ddb1ee4a34cb69f96920101772 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/graph.c4
-rw-r--r--src/vppinfra/pmalloc.c4
-rw-r--r--src/vppinfra/pool.h18
-rw-r--r--src/vppinfra/test_pool_iterate.c6
-rw-r--r--src/vppinfra/test_tw_timer.c96
-rw-r--r--src/vppinfra/timing_wheel.c12
6 files changed, 70 insertions, 70 deletions
diff --git a/src/vppinfra/graph.c b/src/vppinfra/graph.c
index 3f8a3e8423e..4c92f8ef45f 100644
--- a/src/vppinfra/graph.c
+++ b/src/vppinfra/graph.c
@@ -160,14 +160,14 @@ format_graph (u8 * s, va_list * args)
s = format (s, "graph %d nodes", pool_elts (g->nodes));
/* *INDENT-OFF* */
- pool_foreach (n, g->nodes, ({
+ pool_foreach (n, g->nodes) {
s = format (s, "\n%U", format_white_space, indent + 2);
s = format (s, "%U -> ", format_graph_node, g, n - g->nodes);
vec_foreach (l, n->next.links)
s = format (s, "%U (%d), ",
format_graph_node, g, l->node_index,
l->distance);
- }));
+ }
/* *INDENT-ON* */
return s;
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index b92dbf35d92..546a4fe336b 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -643,7 +643,7 @@ format_pmalloc (u8 * s, va_list * va)
/* *INDENT-OFF* */
- pool_foreach (a, pm->arenas,
+ pool_foreach (a, pm->arenas)
{
u32 *page_index;
s = format (s, "\n%Uarena '%s' pages %u subpage-size %U numa-node %u",
@@ -659,7 +659,7 @@ format_pmalloc (u8 * s, va_list * va)
s = format (s, "\n%U%U", format_white_space, indent + 4,
format_pmalloc_page, pp, verbose);
}
- });
+ }
/* *INDENT-ON* */
return s;
diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h
index d7be8cb1f01..116c1cd1321 100644
--- a/src/vppinfra/pool.h
+++ b/src/vppinfra/pool.h
@@ -524,14 +524,14 @@ do { \
vec_foreach() (or plain for-loop) to walk the active index vector.
*/
-#define pool_foreach2(VAR,POOL) \
+#define pool_foreach(VAR,POOL) \
if (POOL) \
for (VAR = POOL + pool_get_first_index (POOL); \
VAR < vec_end (POOL); \
VAR = POOL + pool_get_next_index (POOL, VAR - POOL))
-#define pool_foreach(VAR,POOL,BODY) \
- pool_foreach2(VAR,POOL) \
+#define pool_foreach_old(VAR,POOL,BODY) \
+ pool_foreach(VAR,POOL) \
{ BODY; }
/** Returns pointer to element at given index.
@@ -566,15 +566,15 @@ do { \
_pool_var(rv); \
})
-#define pool_foreach_index2(i,v) \
+#define pool_foreach_index(i,v) \
if (v) \
for (i = pool_get_first_index (v); \
i < vec_len (v); \
i = pool_get_next_index (v, i)) \
/** Iterate pool by index. */
-#define pool_foreach_index(i,v,body) \
- pool_foreach_index2 (i,v) \
+#define pool_foreach_index_old(i,v,body) \
+ pool_foreach_index (i,v) \
{ body; }
/**
@@ -589,10 +589,10 @@ do { \
{ \
uword *_pool_var(ii), *_pool_var(dv) = NULL; \
\
- pool_foreach((VAR), (POOL), \
- ({ \
+ pool_foreach((VAR), (POOL)) \
+ { \
vec_add1(_pool_var(dv), (VAR) - (POOL)); \
- })); \
+ } \
vec_foreach(_pool_var(ii), _pool_var(dv)) \
{ \
(VAR) = pool_elt_at_index((POOL), *_pool_var(ii)); \
diff --git a/src/vppinfra/test_pool_iterate.c b/src/vppinfra/test_pool_iterate.c
index 4e8e2dfa15f..bcbd235ba71 100644
--- a/src/vppinfra/test_pool_iterate.c
+++ b/src/vppinfra/test_pool_iterate.c
@@ -78,8 +78,8 @@ main (int argc, char *argv[])
while (next != ~0);
/* *INDENT-OFF* */
- pool_foreach (junk, tp,
- ({
+ pool_foreach (junk, tp)
+ {
int is_free;
is_free = pool_is_free_index (tp, junk - tp);
@@ -93,7 +93,7 @@ main (int argc, char *argv[])
if (i != 1 && i != 65)
clib_warning ("oops, busy index %d reported free", i);
}
- }));
+ }
/* *INDENT-ON* */
return 0;
diff --git a/src/vppinfra/test_tw_timer.c b/src/vppinfra/test_tw_timer.c
index 499cc017ba1..47e5e49bf1f 100644
--- a/src/vppinfra/test_tw_timer.c
+++ b/src/vppinfra/test_tw_timer.c
@@ -317,13 +317,13 @@ test2_single (tw_timer_test_main_t * tm)
j = 0;
vec_reset_length (deleted_indices);
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
tw_timer_stop_2t_1w_2048sl (&tm->single_wheel, e->stop_timer_handle);
vec_add1 (deleted_indices, e - tm->test_elts);
if (++j >= tm->ntimers / 4)
goto del_and_re_add;
- }));
+ }
/* *INDENT-ON* */
del_and_re_add:
@@ -375,12 +375,12 @@ test2_single (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -456,13 +456,13 @@ test2_double (tw_timer_test_main_t * tm)
j = 0;
vec_reset_length (deleted_indices);
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
tw_timer_stop_16t_2w_512sl (&tm->double_wheel, e->stop_timer_handle);
vec_add1 (deleted_indices, e - tm->test_elts);
if (++j >= tm->ntimers / 4)
goto del_and_re_add;
- }));
+ }
/* *INDENT-ON* */
del_and_re_add:
@@ -513,12 +513,12 @@ test2_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -591,8 +591,8 @@ test2_double_updates (tw_timer_test_main_t * tm)
j = 0;
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
expiration_time = get_expiration_time (tm);
max_expiration_time = clib_max (expiration_time, max_expiration_time);
e->expected_to_expire = expiration_time
@@ -601,7 +601,7 @@ test2_double_updates (tw_timer_test_main_t * tm)
expiration_time);
if (++j >= tm->ntimers / 4)
goto done;
- }));
+ }
/* *INDENT-ON* */
done:
@@ -624,12 +624,12 @@ test2_double_updates (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -707,13 +707,13 @@ test2_triple (tw_timer_test_main_t * tm)
j = 0;
vec_reset_length (deleted_indices);
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
tw_timer_stop_4t_3w_256sl (&tm->triple_wheel, e->stop_timer_handle);
vec_add1 (deleted_indices, e - tm->test_elts);
if (++j >= tm->ntimers / 4)
goto del_and_re_add;
- }));
+ }
/* *INDENT-ON* */
del_and_re_add:
@@ -764,12 +764,12 @@ test2_triple (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -847,14 +847,14 @@ test2_triple_ov (tw_timer_test_main_t * tm)
j = 0;
vec_reset_length (deleted_indices);
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
tw_timer_stop_1t_3w_1024sl_ov (&tm->triple_ov_wheel,
e->stop_timer_handle);
vec_add1 (deleted_indices, e - tm->test_elts);
if (++j >= tm->ntimers / 4)
goto del_and_re_add;
- }));
+ }
/* *INDENT-ON* */
del_and_re_add:
@@ -905,8 +905,8 @@ test2_triple_ov (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
TWT (tw_timer) * t;
fformat (stdout, "[%d] expected to expire %d\n",
@@ -914,7 +914,7 @@ test2_triple_ov (tw_timer_test_main_t * tm)
e->expected_to_expire);
t = pool_elt_at_index (tm->triple_ov_wheel.timers, e->stop_timer_handle);
fformat (stdout, " expiration_time %lld\n", t->expiration_time);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -973,12 +973,12 @@ test1_single (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat(stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
fformat (stdout,
@@ -1031,12 +1031,12 @@ test1_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat(stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
fformat (stdout,
@@ -1089,12 +1089,12 @@ test1_two_timer_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat(stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
fformat (stdout,
@@ -1169,12 +1169,12 @@ test3_triple_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -1253,12 +1253,12 @@ test4_double_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
@@ -1337,12 +1337,12 @@ test5_double (tw_timer_test_main_t * tm)
pool_elts (tm->test_elts));
/* *INDENT-OFF* */
- pool_foreach (e, tm->test_elts,
- ({
+ pool_foreach (e, tm->test_elts)
+ {
fformat (stdout, "[%d] expected to expire %d\n",
e - tm->test_elts,
e->expected_to_expire);
- }));
+ }
/* *INDENT-ON* */
pool_free (tm->test_elts);
diff --git a/src/vppinfra/timing_wheel.c b/src/vppinfra/timing_wheel.c
index bbf3012ffd8..a6c476b2cfa 100644
--- a/src/vppinfra/timing_wheel.c
+++ b/src/vppinfra/timing_wheel.c
@@ -314,10 +314,10 @@ timing_wheel_insert (timing_wheel_t * w, u64 insert_cpu_time, u32 user_data)
{
timing_wheel_overflow_elt_t *oe;
/* *INDENT-OFF* */
- pool_foreach (oe, w->overflow_pool, ({
+ pool_foreach (oe, w->overflow_pool) {
if (oe->user_data == user_data)
pool_put (w->overflow_pool, oe);
- }));
+ }
/* *INDENT-ON* */
}
@@ -398,8 +398,8 @@ timing_wheel_next_expiring_elt_time (timing_wheel_t * w)
min_t = w->cpu_time_base + min_dt;
/* *INDENT-OFF* */
- pool_foreach (oe, w->overflow_pool,
- ({ min_t = clib_min (min_t, oe->cpu_time); }));
+ pool_foreach (oe, w->overflow_pool)
+ { min_t = clib_min (min_t, oe->cpu_time); }
/* *INDENT-ON* */
done:
@@ -503,7 +503,7 @@ advance_cpu_time_base (timing_wheel_t * w, u32 * expired_user_data)
{
timing_wheel_overflow_elt_t *oe;
/* *INDENT-OFF* */
- pool_foreach (oe, w->overflow_pool, ({
+ pool_foreach (oe, w->overflow_pool) {
/* It fits now into 32 bits. */
if (0 == ((oe->cpu_time - w->cpu_time_base) >> BITS (e->cpu_time_relative_to_base)))
{
@@ -520,7 +520,7 @@ advance_cpu_time_base (timing_wheel_t * w, u32 * expired_user_data)
timing_wheel_insert_helper (w, oe->cpu_time, oe->user_data);
pool_put (w->overflow_pool, oe);
}
- }));
+ }
/* *INDENT-ON* */
}
return expired_user_data;