free_range_cb);
}
-struct cds_ja_range *cds_ja_range_add(struct cds_ja *ja,
+int cds_ja_range_add(struct cds_ja *ja,
uint64_t start, /* inclusive */
uint64_t end, /* inclusive */
void *priv)
old_range = caa_container_of(old_node, struct cds_ja_range, ja_node);
switch (CMM_LOAD_SHARED(old_range->type)) {
case CDS_JA_RANGE_ALLOCATED:
- return NULL;
+ return -EEXIST;
case CDS_JA_RANGE_FREE:
break;
case CDS_JA_RANGE_REMOVED:
switch (CMM_LOAD_SHARED(old_range->type)) {
case CDS_JA_RANGE_ALLOCATED:
case CDS_JA_RANGE_FREE: /* fall-through */
- return NULL;
+ return -EEXIST;
case CDS_JA_RANGE_REMOVED:
goto retry;
}
rcu_free_range(ja, old_range);
- return new_range;
+ return 0;
}
int cds_ja_range_del(struct cds_ja *ja, struct cds_ja_range *range)
end = tmp;
}
rcu_read_lock();
- range = cds_ja_range_add(test_ja, start, end, NULL);
- if (!range) {
- fprintf(stderr, "Error in cds_ja_range_add\n");
+ ret = cds_ja_range_add(test_ja, start, end, NULL);
+ if (ret) {
+ if (ret == -EEXIST) {
+ URCU_TLS(nr_addexist)++;
+ } else {
+ assert(0);
+ }
} else {
URCU_TLS(nr_add)++;
}
key = (unsigned long) iter;
key *= key_mul;
rcu_read_lock();
- range = cds_ja_range_add(test_ja, key, key, NULL);
+ ret = cds_ja_range_add(test_ja, key, key, NULL);
URCU_TLS(nr_add)++;
URCU_TLS(nr_writes)++;
rcu_read_unlock();
- if (!range) {
- fprintf(stderr, "Error adding range %" PRIu64 "\n",
- key);
+ if (ret) {
+ fprintf(stderr, "Error (%d) adding range %" PRIu64 "\n",
+ ret, key);
assert(0);
}
}
void cds_ja_range_unlock(struct cds_ja_range *range);
-struct cds_ja_range *cds_ja_range_add(struct cds_ja *ja,
+int cds_ja_range_add(struct cds_ja *ja,
uint64_t start, /* inclusive */
uint64_t end, /* inclusive */
void *priv);