X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Fbenchmark%2Ftest_urcu_lfq.c;h=2217760b0f9ae18f56ac887fb6a06f417b710ca4;hb=ce29b37132cef1c1c758e0862ac701e9bb756d29;hp=77ccb85b0e777714b624547b0d7a0986c1188fc7;hpb=61c3fb603104bda9e67c0690c1964e61a770d045;p=userspace-rcu.git diff --git a/tests/benchmark/test_urcu_lfq.c b/tests/benchmark/test_urcu_lfq.c index 77ccb85..2217760 100644 --- a/tests/benchmark/test_urcu_lfq.c +++ b/tests/benchmark/test_urcu_lfq.c @@ -1,24 +1,10 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// SPDX-FileCopyrightText: 2010 Paolo Bonzini +// +// SPDX-License-Identifier: GPL-2.0-or-later + /* - * test_urcu_lfq.c - * * Userspace RCU library - example RCU-based lock-free queue - * - * Copyright February 2010 - Mathieu Desnoyers - * Copyright February 2010 - Paolo Bonzini - * - * 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 @@ -31,10 +17,10 @@ #include #include #include -#include #include #include +#include #include #include "thread-id.h" @@ -78,7 +64,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -86,7 +72,7 @@ static void set_affinity(void) 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"); @@ -241,24 +227,24 @@ void *thr_dequeuer(void *_count) } static -void test_end(struct cds_lfq_queue_rcu *q, unsigned long long *nr_dequeues) +void test_end(unsigned long long *nr_dequeues_l) { struct cds_lfq_node_rcu *snode; do { - snode = cds_lfq_dequeue_rcu(q); + snode = cds_lfq_dequeue_rcu(&q); if (snode) { struct test *node; node = caa_container_of(snode, struct test, list); free(node); /* no more concurrent access */ - (*nr_dequeues)++; + (*nr_dequeues_l)++; } } while (snode); } static -void show_usage(int argc, char **argv) +void show_usage(char **argv) { printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", argv[0]); @@ -284,25 +270,25 @@ int main(int argc, char **argv) unsigned int i_thr; if (argc < 4) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[1], "%u", &nr_dequeuers); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[2], "%u", &nr_enqueuers); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[3], "%lu", &duration); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } @@ -312,7 +298,7 @@ int main(int argc, char **argv) switch (argv[i][1]) { case 'a': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } a = atoi(argv[++i]); @@ -322,14 +308,14 @@ int main(int argc, char **argv) break; case 'c': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } wdelay = atol(argv[++i]); @@ -402,9 +388,9 @@ int main(int argc, char **argv) tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; } - test_end(&q, &end_dequeues); + test_end(&end_dequeues); err = cds_lfq_destroy_rcu(&q); - assert(!err); + urcu_posix_assert(!err); printf_verbose("total number of enqueues : %llu, dequeues %llu\n", tot_enqueues, tot_dequeues);