| 150 | } |
| 151 | |
| 152 | static __inline bool |
| 153 | refcount_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 | |
| 179 | static __inline bool |
| 180 | refcount_release(volatile u_int *count) |
no test coverage detected