Public headers: use SPDX identifiers
[userspace-rcu.git] / include / urcu / rculfhash.h
index 8586e1da371f86e2c19518f60a8cef69e6db691e..8385cd90a1d9f03c641bd2216bf6e852773ccbb9 100644 (file)
@@ -1,28 +1,14 @@
+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+// SPDX-FileCopyrightText: 2011 Lai Jiangshan <laijs@cn.fujitsu.com>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
 #ifndef _URCU_RCULFHASH_H
 #define _URCU_RCULFHASH_H
 
 /*
- * urcu/rculfhash.h
- *
  * Userspace RCU library - Lock-Free RCU Hash Table
  *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright 2011 - Lai Jiangshan <laijs@cn.fujitsu.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
- *
  * For use with URCU_API_MAP (API mapping of liburcu), include this file
  * _after_ including your URCU flavor.
  */
@@ -247,16 +233,16 @@ struct cds_lfht *cds_lfht_new(unsigned long init_size,
  *
  * Return 0 on success, negative error value on error.
 
+ * Threads calling this API need to be registered RCU read-side threads.
+ *
  * Prior to liburcu 0.10:
- * - Threads calling this API need to be registered RCU read-side
- *   threads.
  * - cds_lfht_destroy should *not* be called from a RCU read-side
  *   critical section. It should *not* be called from a call_rcu thread
  *   context neither.
  *
  * Starting from liburcu 0.10, rculfhash implements its own worker
- * thread to handle resize operations, which removes RCU requirements on
- * cds_lfht_destroy.
+ * thread to handle resize operations, which removes the above RCU
+ * read-side critical section requirement on cds_lfht_destroy.
  */
 extern
 int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr);
@@ -544,24 +530,27 @@ void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size);
                cds_lfht_next_duplicate(ht, match, key, iter),          \
                        node = cds_lfht_iter_get_node(iter))
 
+#define cds_lfht_entry(ptr, type, member)                              \
+       caa_container_of_check_null(ptr, type, member)
+
 #define cds_lfht_for_each_entry(ht, iter, pos, member)                 \
        for (cds_lfht_first(ht, iter),                                  \
-                       pos = caa_container_of(cds_lfht_iter_get_node(iter), \
-                                       __typeof__(*(pos)), member);    \
-               cds_lfht_iter_get_node(iter) != NULL;                   \
+                       pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \
+                               __typeof__(*(pos)), member);            \
+               pos != NULL;                                            \
                cds_lfht_next(ht, iter),                                \
-                       pos = caa_container_of(cds_lfht_iter_get_node(iter), \
-                                       __typeof__(*(pos)), member))
+                       pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \
+                               __typeof__(*(pos)), member))
 
 #define cds_lfht_for_each_entry_duplicate(ht, hash, match, key,                \
                                iter, pos, member)                      \
        for (cds_lfht_lookup(ht, hash, match, key, iter),               \
-                       pos = caa_container_of(cds_lfht_iter_get_node(iter), \
-                                       __typeof__(*(pos)), member);    \
-               cds_lfht_iter_get_node(iter) != NULL;                   \
+                       pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \
+                               __typeof__(*(pos)), member);            \
+               pos != NULL;                                            \
                cds_lfht_next_duplicate(ht, match, key, iter),          \
-                       pos = caa_container_of(cds_lfht_iter_get_node(iter), \
-                                       __typeof__(*(pos)), member))
+                       pos = cds_lfht_entry(cds_lfht_iter_get_node(iter), \
+                               __typeof__(*(pos)), member))
 
 #ifdef __cplusplus
 }
This page took 0.024114 seconds and 4 git commands to generate.