projects
/
userspace-rcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: syscall-compat.h MacOSX support
[userspace-rcu.git]
/
urcu
/
ref.h
diff --git
a/urcu/ref.h
b/urcu/ref.h
index 2b803e5b68e4710606df29f128ff7f1637dc1472..e546da567120e086e5773950ac135d510900b4fc 100644
(file)
--- a/
urcu/ref.h
+++ b/
urcu/ref.h
@@
-34,24
+34,31
@@
static inline void urcu_ref_init(struct urcu_ref *ref)
urcu_ref_set(ref, 1);
}
urcu_ref_set(ref, 1);
}
-static inline void urcu_ref_get(struct urcu_ref *ref)
+static inline bool __attribute__((warn_unused_result))
+ urcu_ref_get_safe(struct urcu_ref *ref)
{
long old, _new, res;
old = uatomic_read(&ref->refcount);
for (;;) {
if (old == LONG_MAX) {
{
long old, _new, res;
old = uatomic_read(&ref->refcount);
for (;;) {
if (old == LONG_MAX) {
- abort();
+ return false; /* Failure. */
}
_new = old + 1;
res = uatomic_cmpxchg(&ref->refcount, old, _new);
if (res == old) {
}
_new = old + 1;
res = uatomic_cmpxchg(&ref->refcount, old, _new);
if (res == old) {
- return
;
+ return
true; /* Success. */
}
old = res;
}
}
}
old = res;
}
}
+static inline void urcu_ref_get(struct urcu_ref *ref)
+{
+ if (!urcu_ref_get_safe(ref))
+ abort();
+}
+
static inline void urcu_ref_put(struct urcu_ref *ref,
void (*release)(struct urcu_ref *))
{
static inline void urcu_ref_put(struct urcu_ref *ref,
void (*release)(struct urcu_ref *))
{
This page took
0.023285 seconds
and
4
git commands to generate.