Page MenuHomeFreeBSD

D17616.id49306.diff
No OneTemporary

D17616.id49306.diff

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 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

Mime Type
text/plain
Expires
Tue, May 19, 1:51 AM (15 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33284507
Default Alt Text
D17616.id49306.diff (672 B)

Event Timeline