+// SPDX-FileCopyrightText: 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: GPL-2.0-or-later
+
/*
- * test_urcu_hash.c
- *
* Userspace RCU library - test program
- *
- * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
- *
- * 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.
*/
#include "test_urcu_hash.h"
struct cds_lfht *test_ht;
-volatile int test_go, test_stop;
-
unsigned long wdelay;
unsigned long duration;
void set_affinity(void)
{
-#if HAVE_SCHED_SETAFFINITY
+#ifdef HAVE_SCHED_SETAFFINITY
cpu_set_t mask;
int cpu, ret;
#endif /* HAVE_SCHED_SETAFFINITY */
if (!use_affinity)
return;
-#if HAVE_SCHED_SETAFFINITY
+#ifdef HAVE_SCHED_SETAFFINITY
ret = pthread_mutex_lock(&affinity_mutex);
if (ret) {
perror("Error in pthread mutex lock");
{
if (caa_unlikely(key1_len != key2_len))
return -1;
- assert(key1_len == sizeof(unsigned long));
+ urcu_posix_assert(key1_len == sizeof(unsigned long));
if (key1 == key2)
return 0;
else
}
static
-void *thr_count(void *arg)
+void *thr_count(void *arg __attribute__((unused)))
{
printf_verbose("thread_begin %s, tid %lu\n",
"counter", urcu_get_thread_id());
int ret;
ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter));
- assert(!ret);
+ urcu_posix_assert(!ret);
call_rcu(&node->head, free_node_cb);
count++;
}
}
static
-void show_usage(int argc, char **argv)
+void show_usage(char **argv)
{
printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
argv[0]);
long long nr_leaked;
if (argc < 4) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
err = sscanf(argv[1], "%u", &nr_readers);
if (err != 1) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
err = sscanf(argv[2], "%u", &nr_writers);
if (err != 1) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
err = sscanf(argv[3], "%lu", &duration);
if (err != 1) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'a':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'c':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'd':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'h':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'm':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'n':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
break;
case 'B':
if (argc < i + 2) {
- show_usage(argc, argv);
+ show_usage(argv);
mainret = 1;
goto end;
}
*/
rcu_register_thread();
ret = (get_populate_hash_cb())();
- assert(!ret);
+ urcu_posix_assert(!ret);
rcu_thread_offline();
cmm_smp_mb();
- test_go = 1;
+ begin_test();
remain = duration;
do {
remain = sleep(remain);
} while (remain > 0);
- test_stop = 1;
+ end_test();
end_pthread_join:
for (i_thr = 0; i_thr < nr_readers_created; i_thr++) {
}
{
char msg[1] = { 0x42 };
- ssize_t ret;
+ ssize_t sret;
do {
- ret = write(count_pipe[1], msg, 1); /* wakeup thread */
- } while (ret == -1L && errno == EINTR);
+ sret = write(count_pipe[1], msg, 1); /* wakeup thread */
+ } while (sret == -1L && errno == EINTR);
}
err = pthread_join(tid_count, &tret);
if (err != 0) {