X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Fbenchmark%2Ftest_urcu_hash_rw.c;h=b76603e6742db7f702ed38d46cd6c73fac4bfff3;hp=8802b9cd0a621d1d07fee0f4e7bfe368f0a287b6;hb=HEAD;hpb=f5ab766ee2c8300cb00ca5878b1cb464f960a66d diff --git a/tests/benchmark/test_urcu_hash_rw.c b/tests/benchmark/test_urcu_hash_rw.c index 8802b9c..b76603e 100644 --- a/tests/benchmark/test_urcu_hash_rw.c +++ b/tests/benchmark/test_urcu_hash_rw.c @@ -1,26 +1,11 @@ +// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: GPL-2.0-or-later + /* - * test_urcu_hash_rw.c - * * Userspace RCU library - test program - * - * Copyright 2009-2012 - Mathieu Desnoyers - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #include "test_urcu_hash.h" enum urcu_hash_addremove { @@ -31,7 +16,7 @@ enum urcu_hash_addremove { static enum urcu_hash_addremove addremove; /* 1: add, -1 remove, 0: random */ -void test_hash_rw_sigusr1_handler(int signo) +void test_hash_rw_sigusr1_handler(int signo __attribute__((unused))) { switch (addremove) { case AR_ADD: @@ -49,7 +34,7 @@ void test_hash_rw_sigusr1_handler(int signo) } } -void test_hash_rw_sigusr2_handler(int signo) +void test_hash_rw_sigusr2_handler(int signo __attribute__((unused))) { char msg[1] = { 0x42 }; ssize_t ret; @@ -74,10 +59,7 @@ void *test_hash_rw_thr_reader(void *_count) rcu_register_thread(); - while (!test_go) - { - } - cmm_smp_mb(); + wait_until_go(); for (;;) { rcu_read_lock(); @@ -121,7 +103,6 @@ void *test_hash_rw_thr_reader(void *_count) void *test_hash_rw_thr_writer(void *_count) { struct lfht_test_node *node; - struct cds_lfht_node *ret_node; struct cds_lfht_iter iter; struct wr_count *count = _count; int ret; @@ -135,12 +116,11 @@ void *test_hash_rw_thr_writer(void *_count) rcu_register_thread(); - while (!test_go) - { - } - cmm_smp_mb(); + wait_until_go(); for (;;) { + struct cds_lfht_node *ret_node = NULL; + if ((addremove == AR_ADD || add_only) || (addremove == AR_RANDOM && rand_r(&URCU_TLS(rand_lookup)) & 1)) { node = malloc(sizeof(struct lfht_test_node)); @@ -231,7 +211,6 @@ void *test_hash_rw_thr_writer(void *_count) int test_hash_rw_populate_hash(void) { struct lfht_test_node *node; - struct cds_lfht_node *ret_node; if (!init_populate) return 0; @@ -247,6 +226,8 @@ int test_hash_rw_populate_hash(void) } while (URCU_TLS(nr_add) < init_populate) { + struct cds_lfht_node *ret_node = NULL; + node = malloc(sizeof(struct lfht_test_node)); lfht_test_node_init(node, (void *)(((unsigned long) rand_r(&URCU_TLS(rand_lookup)) % init_pool_size) + init_pool_offset),