MCPcopy Create free account
hub / github.com/F-Stack/f-stack / refcount_releasen

Function refcount_releasen

freebsd/sys/refcount.h:152–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152static __inline bool
153refcount_releasen(volatile u_int *count, u_int n)
154{
155 u_int old;
156
157 KASSERT(n < REFCOUNT_SATURATION_VALUE / 2,
158 ("refcount_releasen: n=%u too large", n));
159
160 atomic_thread_fence_rel();
161 old = atomic_fetchadd_int(count, -n);
162 if (__predict_false(old < n || REFCOUNT_SATURATED(old))) {
163 _refcount_update_saturated(count);
164 return (false);
165 }
166 if (old > n)
167 return (false);
168
169 /*
170 * Last reference. Signal the user to call the destructor.
171 *
172 * Ensure that the destructor sees all updates. This synchronizes with
173 * release fences from all routines which drop the count.
174 */
175 atomic_thread_fence_acq();
176 return (true);
177}
178
179static __inline bool
180refcount_release(volatile u_int *count)

Callers 2

refcount_releaseFunction · 0.85
lim_freenFunction · 0.85

Calls 4

atomic_thread_fence_relFunction · 0.50
atomic_fetchadd_intFunction · 0.50
atomic_thread_fence_acqFunction · 0.50

Tested by

no test coverage detected