Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/refcount.h
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | if (REFCOUNT_COUNT(old) == 1) | ||||
return (false); | return (false); | ||||
if (__predict_false(REFCOUNT_SATURATED(old))) | if (__predict_false(REFCOUNT_SATURATED(old))) | ||||
return (true); | return (true); | ||||
if (atomic_fcmpset_int(count, &old, old - 1)) | if (atomic_fcmpset_int(count, &old, old - 1)) | ||||
return (true); | return (true); | ||||
} | } | ||||
} | } | ||||
static __inline __result_use_check bool | |||||
refcount_release_if_gt(volatile u_int *count, u_int n) | |||||
{ | |||||
u_int old; | |||||
KASSERT(n > 0, | |||||
("refcount_release_if_gt: Use refcount_release for final ref")); | |||||
old = *count; | |||||
for (;;) { | |||||
if (REFCOUNT_COUNT(old) <= n) | |||||
return (false); | |||||
if (__predict_false(REFCOUNT_SATURATED(old))) | |||||
return (true); | |||||
if (atomic_fcmpset_int(count, &old, old - 1)) | |||||
return (true); | |||||
} | |||||
} | |||||
#endif /* ! __SYS_REFCOUNT_H__ */ | #endif /* ! __SYS_REFCOUNT_H__ */ |