Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106953579
D17616.id49433.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D17616.id49433.diff
View Options
Index: sys/sys/refcount.h
===================================================================
--- sys/sys/refcount.h
+++ sys/sys/refcount.h
@@ -62,7 +62,7 @@
atomic_thread_fence_rel();
old = atomic_fetchadd_int(count, -1);
- KASSERT(old > 0, ("negative refcount %p", count));
+ KASSERT(old > 0, ("refcount %p is zero", count));
if (old > 1)
return (0);
@@ -77,15 +77,19 @@
}
/*
+ * This functions returns non-zero if the refcount was
+ * incremented. Else zero is returned.
+ *
* A temporary hack until refcount_* APIs are sorted out.
*/
-static __inline int
+static __inline __result_use_check int
refcount_acquire_if_not_zero(volatile u_int *count)
{
u_int old;
old = *count;
for (;;) {
+ KASSERT(old < UINT_MAX, ("refcount %p overflowed", count));
if (old == 0)
return (0);
if (atomic_fcmpset_int(count, &old, old + 1))
@@ -93,13 +97,14 @@
}
}
-static __inline int
+static __inline __result_use_check int
refcount_release_if_not_last(volatile u_int *count)
{
u_int old;
old = *count;
for (;;) {
+ KASSERT(old > 0, ("refcount %p is zero", count));
if (old == 1)
return (0);
if (atomic_fcmpset_int(count, &old, old - 1))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 12:26 AM (4 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15727694
Default Alt Text
D17616.id49433.diff (1 KB)
Attached To
Mode
D17616: Add missing function attributes and assert for refcount_acquire_if_not_zero() and refcount_acquire_if_not_last()
Attached
Detach File
Event Timeline
Log In to Comment