diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-07-09 13:17:43 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-07-09 13:57:03 +0200 |
commit | dc390179c884ea295a42fa658b53188f93e8f17b (patch) | |
tree | e15e9d67fb0ccdb54938de12e7cb749e4b97e3a0 /testsuite/epoch01/test_main.c | |
parent | EPOCH(9): Avoid inline functions (diff) | |
download | rtems-libbsd-dc390179c884ea295a42fa658b53188f93e8f17b.tar.bz2 |
test/epoch01: Simplify
Diffstat (limited to '')
-rw-r--r-- | testsuite/epoch01/test_main.c | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/testsuite/epoch01/test_main.c b/testsuite/epoch01/test_main.c index 7f90fc5f..7088a126 100644 --- a/testsuite/epoch01/test_main.c +++ b/testsuite/epoch01/test_main.c @@ -202,6 +202,38 @@ test_list_callback(epoch_context_t ec) } } +static test_item * +test_remove_item(test_context *ctx, uint32_t item_counter[CPU_COUNT], + uint32_t *removals, size_t worker_index) +{ + test_item *prev; + test_item *item; + test_item *tmp; + test_item *rm; + + prev = NULL; + rm = NULL; + CK_SLIST_FOREACH_SAFE(item, &ctx->item_list, link, tmp) { + ++item_counter[item->index]; + + if (item->worker_index == worker_index) { + ++(*removals); + rm = item; + + if (prev != NULL) { + CK_SLIST_REMOVE_AFTER(prev, link); + } else { + CK_SLIST_REMOVE_HEAD(&ctx->item_list, + link); + } + } + + prev = item; + } + + return rm; +} + static void test_enter_list_op_exit_body(rtems_test_parallel_context *base, void *arg, size_t active_workers, size_t worker_index) @@ -219,34 +251,12 @@ test_enter_list_op_exit_body(rtems_test_parallel_context *base, void *arg, memset(item_counter, 0, sizeof(item_counter)); while (!rtems_test_parallel_stop_job(&ctx->base)) { - test_item *prev; - test_item *item; - test_item *tmp; test_item *rm; epoch_enter(e); ++counter; - - prev = NULL; - rm = NULL; - CK_SLIST_FOREACH_SAFE(item, &ctx->item_list, link, tmp) { - ++item_counter[item->index]; - - if (item->worker_index == worker_index) { - ++removals; - rm = item; - - if (prev != NULL) { - CK_SLIST_REMOVE_AFTER(prev, link); - } else { - CK_SLIST_REMOVE_HEAD(&ctx->item_list, - link); - } - } - - prev = item; - } - + rm = test_remove_item(ctx, item_counter, &removals, + worker_index); epoch_exit(e); if (rm != NULL) { @@ -318,34 +328,12 @@ test_enter_list_op_exit_preempt_body(rtems_test_parallel_context *base, while (!rtems_test_parallel_stop_job(&ctx->base)) { struct epoch_tracker et; - test_item *prev; - test_item *item; - test_item *tmp; test_item *rm; epoch_enter_preempt(e, &et); ++counter; - - prev = NULL; - rm = NULL; - CK_SLIST_FOREACH_SAFE(item, &ctx->item_list, link, tmp) { - ++item_counter[item->index]; - - if (item->worker_index == worker_index) { - ++removals; - rm = item; - - if (prev != NULL) { - CK_SLIST_REMOVE_AFTER(prev, link); - } else { - CK_SLIST_REMOVE_HEAD(&ctx->item_list, - link); - } - } - - prev = item; - } - + rm = test_remove_item(ctx, item_counter, &removals, + worker_index); epoch_exit_preempt(e, &et); if (rm != NULL) { |