Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157036250
D17616.id49310.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
691 B
Referenced Files
None
Subscribers
None
D17616.id49310.diff
View Options
Index: sys/sys/refcount.h
===================================================================
--- sys/sys/refcount.h
+++ sys/sys/refcount.h
@@ -55,6 +55,27 @@
atomic_add_int(count, 1);
}
+/*
+ * This functions returns true if the refcount was incremented. Else
+ * false is returned.
+ */
+static __inline __result_use_check bool
+refcount_acquire_unless_zero(volatile u_int *count)
+{
+ u_int c = *count;
+
+ KASSERT(c < UINT_MAX, ("refcount %p overflowed", count));
+
+ /* add one unless zero */
+ for (;;) {
+ if (c == 0)
+ break;
+ if (atomic_fcmpset_int(count, &c, c + 1))
+ break;
+ }
+ return (c != 0);
+}
+
static __inline int
refcount_release(volatile u_int *count)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 19, 1:51 AM (14 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33284537
Default Alt Text
D17616.id49310.diff (691 B)
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