fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[urcu.git] / doc / examples / urcu-flavors / bp.c
index 64978fcef2f8f305e3c4f72078f99b415d98fc25..d42373386633f0a6c724d31a69c902a6ee1e058e 100644 (file)
@@ -1,20 +1,6 @@
-/*
- * Copyright (C) 2013  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// SPDX-FileCopyrightText: 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -22,7 +8,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 
-#include <urcu-bp.h>           /* Bulletproof RCU flavor */
+#include <urcu/urcu-bp.h>      /* Bulletproof RCU flavor */
 #include <urcu/rculist.h>      /* List example */
 #include <urcu/compiler.h>     /* For CAA_ARRAY_SIZE */
 
@@ -46,7 +32,7 @@ int add_node(uint64_t v)
 {
        struct mynode *node;
 
-       node = calloc(sizeof(*node), 1);
+       node = calloc(1, sizeof(*node));
        if (!node)
                return -1;
        node->value = v;
@@ -54,7 +40,7 @@ int add_node(uint64_t v)
        return 0;
 }
 
-int main(int argc, char **argv)
+int main(void)
 {
        uint64_t values[] = { 42, 36, 24, };
        unsigned int i;
@@ -81,7 +67,7 @@ int main(int argc, char **argv)
         * with rcu_read_lock() and rcu_read_unlock(). They can be
         * nested. Those are no-ops for the QSBR flavor.
         */
-       rcu_read_lock();
+       urcu_bp_read_lock();
 
        /*
         * RCU traversal of the linked list.
@@ -89,7 +75,7 @@ int main(int argc, char **argv)
        cds_list_for_each_entry_rcu(node, &mylist, node) {
                printf("Value: %" PRIu64 "\n", node->value);
        }
-       rcu_read_unlock();
+       urcu_bp_read_unlock();
 
        /*
         * Removing nodes from linked list. Safe against concurrent RCU
@@ -104,7 +90,7 @@ int main(int argc, char **argv)
                 * spawning any call_rcu() thread. It is slower though,
                 * since there is no batching.
                 */
-               synchronize_rcu();
+               urcu_bp_synchronize_rcu();
                free(node);
        }
 
This page took 0.02417 seconds and 4 git commands to generate.