+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) {
+ return false; /* Failure. */
+ }
+ _new = old + 1;
+ res = uatomic_cmpxchg(&ref->refcount, old, _new);
+ if (res == old) {
+ return true; /* Success. */
+ }
+ old = res;
+ }
+}
+