X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=urcu%2Frcuja.h;h=82e272bd4ede1aec436845aef287754dd1dab8b6;hb=b10c8ba83ff83cc8bed4bd62832020f9572e0e92;hp=aafa4cfd868b7dca0e1bd44121013cbaba116a86;hpb=99e6e3dc384b72322e7d180c622ee1249345a27c;p=userspace-rcu.git diff --git a/urcu/rcuja.h b/urcu/rcuja.h index aafa4cf..82e272b 100644 --- a/urcu/rcuja.h +++ b/urcu/rcuja.h @@ -6,7 +6,7 @@ * * Userspace RCU library - RCU Judy Array * - * Copyright 2012 - Mathieu Desnoyers + * Copyright 2012-2013 - Mathieu Desnoyers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,12 +25,10 @@ * Include this file _after_ including your URCU flavor. */ -#include #include #include #include #include -#include #ifdef __cplusplus extern "C" { @@ -58,6 +56,10 @@ void cds_ja_node_init(struct cds_ja_node *node) { } +/* + * Note: key UINT64_MAX is reserved internally for iteration. + */ + /* * cds_ja_lookup - look up by key. * @ja: the Judy array. @@ -204,7 +206,9 @@ int cds_ja_destroy(struct cds_ja *ja); */ #define cds_ja_for_each_key_rcu(ja, key, pos) \ for ((key) = 0; \ - ((pos) = cds_ja_lookup_above_equal(ja, key, &(key))); ) + ((key) != UINT64_MAX ? \ + ((pos) = cds_ja_lookup_above_equal(ja, key, &(key))) : 0); \ + (key)++) /* * cds_ja_for_each_key_prev_rcu: Iterate over all keys in descending order. @@ -218,8 +222,10 @@ int cds_ja_destroy(struct cds_ja *ja); * Safe against node removal during iteration. */ #define cds_ja_for_each_key_prev_rcu(ja, key, pos) \ - for ((key) = UINT64_MAX; \ - ((pos) = cds_ja_lookup_below_equal(ja, key, &(key))); ) + for ((key) = UINT64_MAX - 1; \ + ((key) != UINT64_MAX ? \ + ((pos) = cds_ja_lookup_below_equal(ja, key, &(key))) : 0); \ + (key)--) #ifdef __cplusplus }